Name Description Size
ChangeLog.md 96132
jaricom.c jaricom.c This file was part of the Independent JPEG Group's software: Developed 1997-2009 by Guido Vollbeding. libjpeg-turbo Modifications: 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 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. 5132
jcapimin.c jcapimin.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1998, Thomas G. Lane. Modified 2003-2010 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains application interface code for the compression half of the JPEG library. These are the "minimum" API routines that may be needed in either the normal full-compression case or the transcoding-only case. Most of the routines intended to be called directly by an application are in this file or in jcapistd.c. But also see jcparam.c for parameter-setup helper routines, jcomapi.c for routines shared by compression and decompression, and jctrans.c for the transcoding case. 9659
jcapistd.c jcapistd.c Copyright (C) 1994-1996, Thomas G. Lane. This file is part of the Independent JPEG Group's software. For conditions of distribution and use, see the accompanying README.ijg file. This file contains application interface code for the compression half of the JPEG library. These are the "standard" API routines that are used in the normal full-compression case. They are not used by a transcoding-only application. Note that if an application links in jpeg_start_compress, it will end up linking in the entire compressor. We thus must separate this file from jcapimin.c to avoid linking the whole compression library into a transcoder. 5903
jcarith.c jcarith.c This file was part of the Independent JPEG Group's software: Developed 1997-2009 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2015, 2018, 2021-2022, 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 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. 29668
jccoefct.c jccoefct.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1997, Thomas G. Lane. It was modified by The libjpeg-turbo Project to include only code and information relevant to libjpeg-turbo. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the coefficient buffer controller for compression. This controller is the top level of the JPEG compressor proper. The coefficient buffer lies between forward-DCT and entropy encoding steps. 17271
jccolext.c jccolext.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2009-2012, 2015, 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains input colorspace conversion routines. 4605
jccolor.c jccolor.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2009-2012, 2015, 2022, D. R. Commander. Copyright (C) 2014, MIPS Technologies, Inc., California. For conditions of distribution and use, see the accompanying README.ijg file. This file contains input colorspace conversion routines. 23998
jcdctmgr.c jcdctmgr.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 1999-2006, MIYASAKA Masaru. Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2011, 2014-2015, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the forward-DCT management logic. This code selects a particular DCT implementation to be used, and it performs related housekeeping chores including coefficient quantization. 22364
jchuff.c jchuff.c 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, 2018-2022, D. R. Commander. Copyright (C) 2015, Matthieu Darbois. Copyright (C) 2018, Matthias Räncker. Copyright (C) 2020, Arm Limited. For conditions of distribution and use, see the accompanying README.ijg file. This file contains Huffman entropy encoding routines. Much of the complexity here has to do with supporting output suspension. If the data destination module demands suspension, we want to be able to 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. 36659
jchuff.h jchuff.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains declarations for Huffman entropy encoding routines that are shared between the sequential encoder (jchuff.c) and the progressive encoder (jcphuff.c). No other modules need to see these. 1857
jcicc.c jcicc.c Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman. Copyright (C) 2017, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file provides code to write International Color Consortium (ICC) device profiles embedded in JFIF JPEG image files. The ICC has defined a standard for including such data in JPEG "APP2" markers. The code given here does not know anything about the internal structure of the ICC profile data; it just knows how to embed the profile data in a JPEG file while writing it. 4072
jcinit.c jcinit.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains initialization logic for the JPEG compressor. This routine is in charge of selecting the modules to be executed and making an initialization call to each one. Logically, this code belongs in jcmaster.c. It's split out because linking this routine implies linking the entire compression library. For a transcoding-only application, we want to be able to use jcmaster.c without linking in the whole library. 2565
jcmainct.c jcmainct.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. It was modified by The libjpeg-turbo Project to include only code relevant to libjpeg-turbo. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the main buffer controller for compression. The main buffer lies between the pre-processor and the JPEG compressor proper; it holds downsampled data in the JPEG colorspace. 5221
jcmarker.c jcmarker.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1998, Thomas G. Lane. Modified 2003-2010 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2010, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains routines to write JPEG datastream markers. 17532
jcmaster.c jcmaster.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. Modified 2003-2010 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2010, 2016, 2018, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains master control logic for the JPEG compressor. These routines are concerned with parameter validation, initial setup, and inter-pass control (determining the number of passes and the work to be done in each pass). 21959
jcomapi.c jcomapi.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1997, Thomas G. Lane. It was modified by The libjpeg-turbo Project to include only code relevant to libjpeg-turbo. For conditions of distribution and use, see the accompanying README.ijg file. This file contains application interface routines that are used for both compression and decompression. 3239
jconfig.h Version ID for the JPEG library. Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". 1097
jconfigint.h libjpeg-turbo build number 1216
jcparam.c jcparam.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1998, Thomas G. Lane. Modified 2003-2008 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2009-2011, 2018, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains optional default-setting code for the JPEG compressor. Applications do not have to use this file, but those that don't use it must know a lot more about the innards of the JPEG code. 18203
jcphuff.c jcphuff.c This file was part of the Independent JPEG Group's software: Copyright (C) 1995-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2011, 2015, 2018, 2021-2022, D. R. Commander. Copyright (C) 2016, 2018, 2022, Matthieu Darbois. Copyright (C) 2020, Arm Limited. Copyright (C) 2021, Alex Richardson. For conditions of distribution and use, see the accompanying README.ijg file. This file contains Huffman entropy encoding routines for progressive JPEG. We do not support output suspension in this module, since the library currently does not allow multiple-scan files to be written with output suspension. 33656
jcprepct.c jcprepct.c This file is part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the compression preprocessing controller. This controller manages the color conversion, downsampling, and edge expansion steps. Most of the complexity here is associated with buffering input rows as required by the downsampler. See the comments at the head of jcsample.c for the downsampler's needs. 12965
jcsample.c jcsample.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2014, MIPS Technologies, Inc., California. Copyright (C) 2015, 2019, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains downsampling routines. Downsampling input data is counted in "row groups". A row group is defined to be max_v_samp_factor pixel rows of each component, from which the downsampler produces v_samp_factor sample rows. A single row group is processed in each call to the downsampler module. The downsampler is responsible for edge-expansion of its output data to fill an integral number of DCT blocks horizontally. The source buffer may be modified if it is helpful for this purpose (the source buffer is allocated wide enough to correspond to the desired output width). The caller (the prep controller) is responsible for vertical padding. The downsampler may request "context rows" by setting need_context_rows during startup. In this case, the input arrays will contain at least one row group's worth of pixels above and below the passed-in data; the caller will create dummy rows at image top and bottom by replicating the first or last real pixel row. An excellent reference for image resampling is Digital Image Warping, George Wolberg, 1990. Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. The downsampling algorithm used here is a simple average of the source pixels covered by the output pixel. The hi-falutin sampling literature refers to this as a "box filter". In general the characteristics of a box filter are not very good, but for the specific cases we normally use (1:1 and 2:1 ratios) the box is equivalent to a "triangle filter" which is not nearly so bad. If you intend to use other sampling ratios, you'd be well advised to improve this code. A simple input-smoothing capability is provided. This is mainly intended for cleaning up color-dithered GIF input files (if you find it inadequate, we suggest using an external filtering program such as pnmconvol). When enabled, each input pixel P is replaced by a weighted sum of itself and its eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, where SF = (smoothing_factor / 1024). Currently, smoothing is only supported for 2h2v sampling factors. 19156
jctrans.c jctrans.c This file was part of the Independent JPEG Group's software: Copyright (C) 1995-1998, Thomas G. Lane. Modified 2000-2009 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2020, 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains library routines for transcoding compression, that is, writing raw DCT coefficient arrays to an output JPEG file. The routines in jcapimin.c will also be needed by a transcoder. 14940
jdapimin.c jdapimin.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1998, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2016, 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains application interface code for the decompression half of the JPEG library. These are the "minimum" API routines that may be needed in either the normal full-decompression case or the transcoding-only case. Most of the routines intended to be called directly by an application are in this file or in jdapistd.c. But also see jcomapi.c for routines shared by compression and decompression, and jdtrans.c for the transcoding case. 13240
jdapistd.c jdapistd.c 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-2020, 2022, D. R. Commander. Copyright (C) 2015, Google, Inc. For conditions of distribution and use, see the accompanying README.ijg file. This file contains application interface code for the decompression half of the JPEG library. These are the "standard" API routines that are used in the normal full-decompression case. They are not used by a transcoding-only application. Note that if an application links in jpeg_start_decompress, it will end up linking in the entire decompressor. We thus must separate this file from jdapimin.c to avoid linking the whole decompression library into a transcoder. 25518
jdarith.c jdarith.c This file was part of the Independent JPEG Group's software: Developed 1997-2015 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2015-2020, 2022, 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 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. 25539
jdatadst.c jdatadst.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. Modified 2009-2012 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2013, 2016, 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains compression data destination routines for the case of emitting JPEG data to memory or to a file (or any stdio stream). While these routines are sufficient for most applications, some will want to use a different destination manager. IMPORTANT: we assume that fwrite() will correctly transcribe an array of JOCTETs into 8-bit-wide elements on external storage. If char is wider than 8 bits on your machine, you may need to do some tweaking. 9557
jdatasrc.c jdatasrc.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. Modified 2009-2011 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2013, 2016, 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains decompression data source routines for the case of reading JPEG data from memory or from a file (or any stdio stream). While these routines are sufficient for most applications, some will want to use a different source manager. IMPORTANT: we assume that fread() will correctly transcribe an array of JOCTETs from 8-bit-wide elements on external storage. If char is wider than 8 bits on your machine, you may need to do some tweaking. 10288
jdcoefct.c jdcoefct.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2010, 2015-2016, 2019-2020, 2022, D. R. Commander. Copyright (C) 2015, 2020, Google, Inc. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the coefficient buffer controller for decompression. This controller is the top level of the JPEG decompressor proper. The coefficient buffer lies between entropy decoding and inverse-DCT steps. In buffered-image mode, this controller is the interface between input-oriented processing and output-oriented processing. Also, the input side (only) is used when reading a file for transcoding. 34033
jdcoefct.h jdcoefct.h This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2020, Google, Inc. For conditions of distribution and use, see the accompanying README.ijg file. 2704
jdcol565.c jdcol565.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. Modifications: Copyright (C) 2013, Linaro Limited. Copyright (C) 2014-2015, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains output colorspace conversion routines. 11665
jdcolext.c jdcolext.c 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, 2015, 2023, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains output colorspace conversion routines. 4397
jdcolor.c jdcolor.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. Modified 2011 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2009, 2011-2012, 2014-2015, D. R. Commander. Copyright (C) 2013, Linaro Limited. For conditions of distribution and use, see the accompanying README.ijg file. This file contains output colorspace conversion routines. 28525
jdct.h jdct.h This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2015, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This include file contains common declarations for the forward and inverse DCT modules. These declarations are private to the DCT managers (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. The individual DCT algorithms are kept in separate files to ease machine-dependent tuning (e.g., assembly coding). 9708
jddctmgr.c jddctmgr.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. Modified 2002-2010 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2010, 2015, 2022, D. R. Commander. Copyright (C) 2013, MIPS Technologies, Inc., California. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the inverse-DCT management logic. This code selects a particular IDCT implementation to be used, and it performs related housekeeping chores. No code in this file is executed per IDCT step, only during output pass setup. Note that the IDCT routines are responsible for performing coefficient dequantization as well as the IDCT proper. This module sets up the dequantization multiplier table needed by the IDCT routine. 11423
jdhuff.c jdhuff.c 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, 2018-2019, D. R. Commander. Copyright (C) 2018, Matthias Räncker. For conditions of distribution and use, see the accompanying README.ijg file. This file contains Huffman entropy decoding routines. Much of the complexity here has to do with supporting input suspension. If the data source module demands suspension, we want to be able to 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 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. 26644
jdhuff.h jdhuff.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2010-2011, 2015-2016, 2021, D. R. Commander. Copyright (C) 2018, Matthias Räncker. For conditions of distribution and use, see the accompanying README.ijg file. This file contains declarations for Huffman entropy decoding routines that are shared between the sequential decoder (jdhuff.c) and the progressive decoder (jdphuff.c). No other modules need to see these. 9795
jdicc.c jdicc.c Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman. Copyright (C) 2017, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file provides code to read International Color Consortium (ICC) device profiles embedded in JFIF JPEG image files. The ICC has defined a standard for including such data in JPEG "APP2" markers. The code given here does not know anything about the internal structure of the ICC profile data; it just knows how to get the profile data from a JPEG file while reading it. 5409
jdinput.c jdinput.c 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, 2018, 2022, D. R. Commander. Copyright (C) 2015, Google, Inc. For conditions of distribution and use, see the accompanying README.ijg file. This file contains input control logic for the JPEG decompressor. These routines are concerned with controlling the decompressor's input processing (marker reading and coefficient decoding). The actual input reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. 14585
jdmainct.c jdmainct.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2010, 2016, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the main buffer controller for decompression. The main buffer lies between the JPEG decompressor proper and the post-processor; it holds downsampled data in the JPEG colorspace. Note that this code is bypassed in raw-data mode, since the application supplies the equivalent of the main buffer in that case. 19797
jdmainct.h jdmainct.h This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. For conditions of distribution and use, see the accompanying README.ijg file. 2448
jdmarker.c jdmarker.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1998, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2012, 2015, 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains routines to decode JPEG datastream markers. Most of the complexity arises from our desire to support input suspension: if not all of the data for a marker is available, we must exit back to the application. On resumption, we reprocess the marker. 42216
jdmaster.c jdmaster.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. Modified 2002-2009 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2009-2011, 2016, 2019, 2022, D. R. Commander. Copyright (C) 2013, Linaro Limited. Copyright (C) 2015, Google, Inc. For conditions of distribution and use, see the accompanying README.ijg file. This file contains master control logic for the JPEG decompressor. These routines are concerned with selecting the modules to be executed and with determining the number of passes and the work to be done in each pass. 27460
jdmaster.h jdmaster.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1995, Thomas G. Lane. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the master control structure for the JPEG decompressor. 788
jdmerge.c jdmerge.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander. Copyright (C) 2013, Linaro Limited. For conditions of distribution and use, see the accompanying README.ijg file. This file contains code for merged upsampling/color conversion. This file combines functions from jdsample.c and jdcolor.c; read those files first to understand what's going on. When the chroma components are to be upsampled by simple replication (ie, box filtering), we can save some work in color conversion by calculating all the output pixels corresponding to a pair of chroma samples at one time. In the conversion equations R = Y + K1 * Cr G = Y + K2 * Cb + K3 * Cr B = Y + K4 * Cb only the Y term varies among the group of pixels corresponding to a pair of chroma samples, so the rest of the terms can be calculated just once. At typical sampling ratios, this eliminates half or three-quarters of the multiplications needed for color conversion. This file currently provides implementations for the following cases: YCbCr => RGB color conversion only. Sampling ratios of 2h1v or 2h2v. No scaling needed at upsample time. Corner-aligned (non-CCIR601) sampling alignment. Other special cases could be added, but in most applications these are the only common cases. (For uncommon cases we fall back on the more general code in jdsample.c and jdcolor.c.) 19780
jdmerge.h jdmerge.h This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. 1630
jdmrg565.c jdmrg565.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2013, Linaro Limited. Copyright (C) 2014-2015, 2018, 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains code for merged upsampling/color conversion. 11030
jdmrgext.c jdmrgext.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2011, 2015, 2020, 2023, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains code for merged upsampling/color conversion. 5847
jdphuff.c jdphuff.c 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, 2018-2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains Huffman entropy decoding routines for progressive JPEG. Much of the complexity here has to do with supporting input suspension. If the data source module demands suspension, we want to be able to 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 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. 22173
jdpostct.c jdpostct.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. It was modified by The libjpeg-turbo Project to include only code relevant to libjpeg-turbo. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the decompression postprocessing controller. This controller manages the upsampling, color conversion, and color quantization/reduction steps; specifically, it controls the buffering between upsample/color conversion and color quantization/reduction. If no color quantization/reduction is required, then this module has no work to do, and it just hands off to the upsample/color conversion code. An integrated upsample/convert/quantize process would replace this module entirely. 10948
jdsample.c jdsample.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2010, 2015-2016, D. R. Commander. Copyright (C) 2014, MIPS Technologies, Inc., California. Copyright (C) 2015, Google, Inc. Copyright (C) 2019-2020, Arm Limited. For conditions of distribution and use, see the accompanying README.ijg file. This file contains upsampling routines. Upsampling input data is counted in "row groups". A row group is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) sample rows of each component. Upsampling will normally produce max_v_samp_factor pixel rows from each row group (but this could vary if the upsampler is applying a scale factor of its own). An excellent reference for image resampling is Digital Image Warping, George Wolberg, 1990. Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. 18058
jdsample.h jdsample.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. For conditions of distribution and use, see the accompanying README.ijg file. 1725
jdtrans.c jdtrans.c This file was part of the Independent JPEG Group's software: Copyright (C) 1995-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains library routines for transcoding decompression, that is, reading raw DCT coefficient arrays from an input JPEG file. The routines in jdapimin.c will also be needed by a transcoder. 5461
jerror.c jerror.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1998, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains simple error-reporting and trace-message routines. These are suitable for Unix-like systems and others where writing to stderr is the right thing to do. Many applications will want to replace some or all of these routines. If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, you get a Windows-specific hack to display error messages in a dialog box. It ain't much, but it beats dropping error messages into the bit bucket, which is what happens to output to stderr under most Windows C compilers. These routines are used by both the compression and decompression code. 7929
jerror.h jerror.h This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1997, Thomas G. Lane. Modified 1997-2009 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2014, 2017, 2021-2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file defines the error and message codes for the JPEG library. Edit this file to add new codes, or to translate the message strings to some other language. A set of error-reporting macros are defined too. Some applications using the JPEG library may wish to include this file to get the error codes and/or the macros. 15864
jfdctflt.c jfdctflt.c Copyright (C) 1994-1996, Thomas G. Lane. This file is part of the Independent JPEG Group's software. For conditions of distribution and use, see the accompanying README.ijg file. This file contains a floating-point implementation of the forward DCT (Discrete Cosine Transform). This implementation should be more accurate than either of the integer DCT implementations. However, it may not give the same results on all machines because of differences in roundoff behavior. Speed will depend on the hardware's floating point capacity. A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT on each column. Direct algorithms are also available, but they are much more complex and seem not to be any faster when reduced to code. This implementation is based on Arai, Agui, and Nakajima's algorithm for scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in Japanese, but the algorithm is described in the Pennebaker & Mitchell JPEG textbook (see REFERENCES section in file README.ijg). The following code is based directly on figure 4-8 in P&M. While an 8-point DCT cannot be done in less than 11 multiplies, it is possible to arrange the computation so that many of the multiplies are simple scalings of the final outputs. These multiplies can then be folded into the multiplications or divisions by the JPEG quantization table entries. The AA&N method leaves only 5 multiplies and 29 adds to be done in the DCT itself. The primary disadvantage of this method is that with a fixed-point implementation, accuracy is lost due to imprecise representation of the scaled quantization values. However, that problem does not arise if we use floating point arithmetic. 5588
jfdctfst.c jfdctfst.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2015, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains a fast, not so accurate integer implementation of the forward DCT (Discrete Cosine Transform). A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT on each column. Direct algorithms are also available, but they are much more complex and seem not to be any faster when reduced to code. This implementation is based on Arai, Agui, and Nakajima's algorithm for scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in Japanese, but the algorithm is described in the Pennebaker & Mitchell JPEG textbook (see REFERENCES section in file README.ijg). The following code is based directly on figure 4-8 in P&M. While an 8-point DCT cannot be done in less than 11 multiplies, it is possible to arrange the computation so that many of the multiplies are simple scalings of the final outputs. These multiplies can then be folded into the multiplications or divisions by the JPEG quantization table entries. The AA&N method leaves only 5 multiplies and 29 adds to be done in the DCT itself. The primary disadvantage of this method is that with fixed-point math, accuracy is lost due to imprecise representation of the scaled quantization values. The smaller the quantization table entry, the less precise the scaled value, so this implementation does worse with high- quality-setting files than with low-quality ones. 7792
jfdctint.c jfdctint.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2015, 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains a slower but more accurate integer implementation of the forward DCT (Discrete Cosine Transform). A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT on each column. Direct algorithms are also available, but they are much more complex and seem not to be any faster when reduced to code. This implementation is based on an algorithm described in C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. The primary algorithm described there uses 11 multiplies and 29 adds. We use their alternate method with 12 multiplies and 32 adds. The advantage of this method is that no data path contains more than one multiplication; this allows a very simple and accurate implementation in scaled fixed-point arithmetic, with a minimal number of shifts. 11508
jidctflt.c jidctflt.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1998, Thomas G. Lane. Modified 2010 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2014, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains a floating-point implementation of the inverse DCT (Discrete Cosine Transform). In the IJG code, this routine must also perform dequantization of the input coefficients. This implementation should be more accurate than either of the integer IDCT implementations. However, it may not give the same results on all machines because of differences in roundoff behavior. Speed will depend on the hardware's floating point capacity. A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT on each row (or vice versa, but it's more convenient to emit a row at a time). Direct algorithms are also available, but they are much more complex and seem not to be any faster when reduced to code. This implementation is based on Arai, Agui, and Nakajima's algorithm for scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in Japanese, but the algorithm is described in the Pennebaker & Mitchell JPEG textbook (see REFERENCES section in file README.ijg). The following code is based directly on figure 4-8 in P&M. While an 8-point DCT cannot be done in less than 11 multiplies, it is possible to arrange the computation so that many of the multiplies are simple scalings of the final outputs. These multiplies can then be folded into the multiplications or divisions by the JPEG quantization table entries. The AA&N method leaves only 5 multiplies and 29 adds to be done in the DCT itself. The primary disadvantage of this method is that with a fixed-point implementation, accuracy is lost due to imprecise representation of the scaled quantization values. However, that problem does not arise if we use floating point arithmetic. 8729
jidctfst.c jidctfst.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1998, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2015, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains a fast, not so accurate integer implementation of the inverse DCT (Discrete Cosine Transform). In the IJG code, this routine must also perform dequantization of the input coefficients. A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT on each row (or vice versa, but it's more convenient to emit a row at a time). Direct algorithms are also available, but they are much more complex and seem not to be any faster when reduced to code. This implementation is based on Arai, Agui, and Nakajima's algorithm for scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in Japanese, but the algorithm is described in the Pennebaker & Mitchell JPEG textbook (see REFERENCES section in file README.ijg). The following code is based directly on figure 4-8 in P&M. While an 8-point DCT cannot be done in less than 11 multiplies, it is possible to arrange the computation so that many of the multiplies are simple scalings of the final outputs. These multiplies can then be folded into the multiplications or divisions by the JPEG quantization table entries. The AA&N method leaves only 5 multiplies and 29 adds to be done in the DCT itself. The primary disadvantage of this method is that with fixed-point math, accuracy is lost due to imprecise representation of the scaled quantization values. The smaller the quantization table entry, the less precise the scaled value, so this implementation does worse with high- quality-setting files than with low-quality ones. 13554
jidctint.c jidctint.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1998, Thomas G. Lane. Modification developed 2002-2018 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2015, 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains a slower but more accurate integer implementation of the inverse DCT (Discrete Cosine Transform). In the IJG code, this routine must also perform dequantization of the input coefficients. A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT on each row (or vice versa, but it's more convenient to emit a row at a time). Direct algorithms are also available, but they are much more complex and seem not to be any faster when reduced to code. This implementation is based on an algorithm described in C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. The primary algorithm described there uses 11 multiplies and 29 adds. We use their alternate method with 12 multiplies and 32 adds. The advantage of this method is that no data path contains more than one multiplication; this allows a very simple and accurate implementation in scaled fixed-point arithmetic, with a minimal number of shifts. We also provide IDCT routines with various output sample block sizes for direct resolution reduction or enlargement without additional resampling: NxN (N=1...16) pixels for one 8x8 input DCT block. For N<8 we simply take the corresponding low-frequency coefficients of the 8x8 input DCT block and apply an NxN point IDCT on the sub-block to yield the downscaled outputs. This can be seen as direct low-pass downsampling from the DCT domain point of view rather than the usual spatial domain point of view, yielding significant computational savings and results at least as good as common bilinear (averaging) spatial downsampling. For N>8 we apply a partial NxN IDCT on the 8 input coefficients as lower frequencies and higher frequencies assumed to be zero. It turns out that the computational effort is similar to the 8x8 IDCT regarding the output size. Furthermore, the scaling and descaling is the same for all IDCT sizes. CAUTION: We rely on the FIX() macro except for the N=1,2,4,8 cases since there would be too many additional constants to pre-calculate. 106254
jidctred.c jidctred.c This file was part of the Independent JPEG Group's software: Copyright (C) 1994-1998, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2015, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains inverse-DCT routines that produce reduced-size output: either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step with an 8-to-4 step that produces the four averages of two adjacent outputs (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). These steps were derived by computing the corresponding values at the end of the normal LL&M code, then simplifying as much as possible. 1x1 is trivial: just take the DC coefficient divided by 8. See jidctint.c for additional comments. 14528
jinclude.h jinclude.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1994, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file exists to provide a single place to fix any problems with including the wrong system include files. (Common problems are taken care of by the standard jconfig symbols, but on really weird systems you may have to edit this file.) NOTE: this file is NOT intended to be included by applications using the JPEG library. Most applications need only include jpeglib.h. 3163
jmemmgr.c jmemmgr.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2016, 2021-2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains the JPEG system-independent memory management routines. This code is usable across a wide variety of machines; most of the system dependencies have been isolated in a separate file. The major functions provided here are: * pool-based allocation and freeing of memory; * policy decisions about how to divide available memory among the virtual arrays; * control logic for swapping virtual arrays between main memory and backing storage. The separate system-dependent file provides the actual backing-storage access code, and it contains the policy decision about how much total main memory to use. This file is system-dependent in the sense that some of its functions are unnecessary in some systems. For example, if there is enough virtual memory so that backing storage will never be used, much of the virtual array control logic could be removed. (Of course, if you have that much memory then you shouldn't care about a little bit of unused code...) 45062
jmemnobs.c jmemnobs.c This file was part of the Independent JPEG Group's software: Copyright (C) 1992-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2017-2018, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file provides a really simple implementation of the system- dependent portion of the JPEG memory manager. This implementation assumes that no backing-store files are needed: all required space can be obtained from malloc(). This is very portable in the sense that it'll compile on almost anything, but you'd better have lots of main memory (or virtual memory) if you want to process big images. 2674
jmemsys.h jmemsys.h This file was part of the Independent JPEG Group's software: Copyright (C) 1992-1997, Thomas G. Lane. It was modified by The libjpeg-turbo Project to include only code and information relevant to libjpeg-turbo. For conditions of distribution and use, see the accompanying README.ijg file. This include file defines the interface between the system-independent and system-dependent portions of the JPEG memory manager. No other modules need include it. (The system-independent portion is jmemmgr.c; there are several different versions of the system-dependent portion.) This file works as-is for the system-dependent memory managers supplied in the IJG distribution. You may need to modify it if you write a custom memory manager. If system-dependent changes are needed in this file, the best method is to #ifdef them based on a configuration symbol supplied in jconfig.h. 7788
jmorecfg.h jmorecfg.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. Modified 1997-2009 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains additional configuration options that customize the JPEG software for special applications or support machine-dependent optimizations. Most users will not need to touch this file. 13823
jpeg_nbits_table.h 270393
jpegcomp.h jpegcomp.h Copyright (C) 2010, 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. JPEG compatibility macros These declarations are considered internal to the JPEG library; most applications using the library shouldn't need to include this file. 1130
jpegint.h jpegint.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1997, Thomas G. Lane. Modified 1997-2009 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2015-2016, 2019, 2021, D. R. Commander. Copyright (C) 2015, Google, Inc. Copyright (C) 2021, Alex Richardson. For conditions of distribution and use, see the accompanying README.ijg file. This file provides common declarations for the various JPEG modules. These declarations are considered internal to the JPEG library; most applications using the library shouldn't need to include this file. 15782
jpeglib.h jpeglib.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1998, Thomas G. Lane. Modified 2002-2009 by Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, D. R. Commander. Copyright (C) 2015, Google, Inc. For conditions of distribution and use, see the accompanying README.ijg file. This file defines the application interface for the JPEG library. Most applications using the library need only include this file, and perhaps jerror.h if they want to know the exact error codes. 50281
jquant1.c jquant1.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2009, 2015, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains 1-pass color quantization (color mapping) routines. These routines provide mapping to a fixed color map using equally spaced color values. Optional Floyd-Steinberg or ordered dithering is available. 32176
jquant2.c jquant2.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2009, 2014-2015, 2020, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains 2-pass color quantization (color mapping) routines. These routines provide selection of a custom color map for an image, followed by mapping of the image to that color map, with optional Floyd-Steinberg dithering. It is also possible to use just the second pass to map to an arbitrary externally-given color map. Note: ordered dithering is not supported, since there isn't any fast way to compute intercolor distances; it's unclear that ordered dither's fundamental assumptions even hold with an irregularly spaced color map. 48710
jsimd.h jsimd.h Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2011, 2014, 2022, D. R. Commander. Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois. Copyright (C) 2020, Arm Limited. Based on the x86 SIMD extension for IJG JPEG library, Copyright (C) 1999-2006, MIYASAKA Masaru. For conditions of distribution and use, see copyright notice in jsimdext.inc 5867
jsimd_none.c jsimd_none.c Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright (C) 2009-2011, 2014, 2022, D. R. Commander. Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois. Copyright (C) 2020, Arm Limited. Based on the x86 SIMD extension for IJG JPEG library, Copyright (C) 1999-2006, MIYASAKA Masaru. For conditions of distribution and use, see copyright notice in jsimdext.inc This file contains stubs for when there is no SIMD support available. 8050
jsimddct.h jsimddct.h Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB Based on the x86 SIMD extension for IJG JPEG library, Copyright (C) 1999-2006, MIYASAKA Masaru. For conditions of distribution and use, see copyright notice in jsimdext.inc 3085
jstdhuff.c jstdhuff.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1998, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2013, 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains routines to set the default Huffman tables, if they are not already set. 5321
jutils.c jutils.c This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. libjpeg-turbo Modifications: Copyright (C) 2022, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains tables and miscellaneous utility routines needed for both compression and decompression. Note we prefix all global names with "j" to minimize conflicts with a surrounding application. 3764
jversion.h jversion.h This file was part of the Independent JPEG Group's software: Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding. libjpeg-turbo Modifications: Copyright (C) 2010, 2012-2023, D. R. Commander. For conditions of distribution and use, see the accompanying README.ijg file. This file contains software version identification. 1754
LICENSE.md 5213
moz.build 10561
MOZCHANGES 5228
mozilla.diff 1906
README.ijg libjpeg-turbo note: This file has been modified by The libjpeg-turbo Project 12732
README.md Background 17039
simd