Home | History | Annotate | Download | only in jpeg

Lines Matching full:jpeg

1 USING THE IJG JPEG LIBRARY
4 This file is part of the Independent JPEG Group's software.
8 This file describes how to use the IJG JPEG library within an application
12 JPEG library. Also see jpeglib.h (the include file to be used by application
42 Progressive JPEG support
66 The IJG JPEG library provides C code to read and write JPEG-compressed image
73 JPEG standard but is necessary for typical applications of JPEG. These
74 functions preprocess the image before JPEG compression or postprocess it after
81 A wide range of quality vs. speed tradeoffs are possible in JPEG processing,
87 low-quality modes may not meet the JPEG standard's accuracy requirements;
91 the ISO JPEG standard; most baseline, extended-sequential, and progressive
92 JPEG processes are supported. (Our subset includes all features now in common
95 * Lossless JPEG
103 By itself, the library handles only interchange JPEG datastreams --- in
105 surrounding code to process interchange or abbreviated JPEG datastreams that
107 used by the free LIBTIFF library to support JPEG compression in TIFF.)
113 The rough outline of a JPEG compression operation is:
115 Allocate and initialize a JPEG compression object
122 Release the JPEG compression object
124 A JPEG compression object holds parameters and working state for the JPEG
128 same parameter settings for a sequence of images. Re-use of a JPEG object
129 also has important implications for processing abbreviated JPEG datastreams,
139 Similarly, the rough outline of a JPEG decompression operation is:
141 Allocate and initialize a JPEG decompression object
149 Release the JPEG decompression object
163 by calling jpeg_abort(); or, if you do not need to retain the JPEG object,
166 JPEG compression and decompression objects are two separate struct types.
170 The JPEG library has no static variables: all state is in the compression
172 compression and decompression operations concurrently, using multiple JPEG
187 image data format that the JPEG library expects or returns.
196 programs don't work with grayscale JPEG files.
198 There is no provision for colormapped input. JPEG files are always full-color
201 JPEG often doesn't work very well with source data that has been colormapped,
202 because of dithering noise. This is discussed in more detail in the JPEG FAQ
234 except that colormapped output is supported. (Again, a JPEG file is never
243 (ie, at most 256 colors for an 8-bit JPEG library).
249 Here we revisit the JPEG compression outline given in the overview.
251 1. Allocate and initialize a JPEG compression object.
253 A JPEG compression object is a "struct jpeg_compress_struct". (It also has
257 whole JPEG compression sequence. Otherwise it can be static or allocated
260 You will also need a structure representing a JPEG error handler. The part
265 handler. The default error handler will print JPEG error/warning messages
269 the JPEG object's "err" field, and then call jpeg_create_compress() to
270 initialize the rest of the JPEG object.
287 As previously mentioned, the JPEG library delivers compressed data to a
320 fields in the JPEG object (cinfo structure):
327 The image dimensions are, hopefully, obvious. JPEG supports image dimensions
334 JPEG has a large number of compression parameters that determine how the
363 storage, and emit the first few bytes of the JPEG datastream header.
369 The "TRUE" parameter ensures that a complete JPEG interchange datastream
374 Once you have called jpeg_start_compress(), you may not alter any JPEG
375 parameters or other fields of the JPEG object until you have completed
388 Image data should be written in top-to-bottom scanline order. The JPEG spec
393 the JPEG library's virtual array mechanism to invert the data efficiently.
397 in the next_scanline field of the JPEG object. Usually you can just use
433 jpeg_finish_compress() also releases working memory associated with the JPEG
453 After completing a compression cycle, you may dispose of the JPEG object
457 If you do not change any JPEG parameters, the new datastream will be written
464 7. Release the JPEG compression object.
466 When you are done with a JPEG compression object, destroy it by calling
489 * If you don't need the JPEG object any more, just call
494 * If you want to re-use the JPEG object, call jpeg_abort_compress(), or call
503 jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG
512 Here we revisit the JPEG decompression outline given in the overview.
514 1. Allocate and initialize a JPEG decompression object.
534 As previously mentioned, the JPEG library reads compressed data from a "data
560 jpeg_finish_decompress(). If you wish to read a series of JPEG images from
562 jpeg_finish_decompress() sequence without reinitializing either the JPEG
575 info have been stored in the JPEG object. The application may wish to
582 * Abbreviated JPEG files are to be processed --- see the section on
584 interchange JPEG files need not be concerned with this case either.
587 image dimensions and other header info for a JPEG file. In that case,
588 call jpeg_destroy() when you are done with the JPEG object, or call
624 to complete. With a single-scan (non progressive) JPEG file and default
629 scaling, are available in the JPEG object; so is the selected colormap, if
647 Note: if you are using the JPEG library's internal memory manager to allocate
667 out the image in bottom-to-top order, you can use the JPEG library's virtual
672 in the output_scanline field of the JPEG object. Usually you can just use
694 with the JPEG object to be released.
707 After completing a decompression cycle, you may dispose of the JPEG object as
713 8. Release the JPEG decompression object.
715 When you are done with a JPEG decompression object, destroy it by calling
727 jpeg_destroy() if you don't need the JPEG object any more, or
735 Applications using the JPEG library should include the header file jpeglib.h
741 If the application needs to refer to individual JPEG library error codes, also
745 installing the JPEG header files in a system directory, you will want to
748 The most convenient way to include the JPEG code into your executable program
755 While you can build the JPEG library as a shared library if the whim strikes
772 It may be worth pointing out that the core JPEG library does not actually
786 This section describes all the optional parameters you can set for JPEG
789 of the JPEG standard; if you don't know what a parameter is for, it's best
791 more info about JPEG.
794 all the parameters; that way your code is more likely to work with future JPEG
802 This routine sets all JPEG parameters to reasonable defaults, using
808 Sets the JPEG file's colorspace (field jpeg_color_space) as specified,
816 Selects an appropriate JPEG colorspace based on cinfo->in_color_space,
819 just the colorspace-dependent JPEG parameters.
822 Constructs JPEG quantization tables appropriate for the indicated
828 entries are constrained to the range 1..255 for full JPEG baseline
862 the basic table to be given in JPEG zigzag order. If you need to
868 Generates a default scan script for writing a progressive-JPEG file.
871 the JPEG color space is set correctly before calling this routine.
894 The JPEG color space and corresponding number of components; see
910 To emit restart markers in the JPEG file, set one of these nonzero.
916 NOTE: the overhead of restart markers is higher in grayscale JPEG
924 single-scan sequential JPEG file. If not NULL, scan_info points to
926 compressor will then write a JPEG file having one scan for each scan
928 progressive JPEG files. The library checks that the scan array
929 defines a valid JPEG scan sequence. (jpeg_simple_progression creates
930 a suitable scan definition array for progressive JPEG.) This is
931 discussed further under "Progressive JPEG support".
940 jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space
960 jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK,
964 default behavior ensures that the JPEG file's color space can be
979 JPEG sample tables by jpeg_set_defaults(). If you need to allocate
992 JPEG color space, *not* the source image color space. A suitably large
997 The one-byte identifier code to be recorded in the JPEG file for
1004 be 1..4 according to the JPEG standard. Note that larger sampling
1029 parameter selection, since all of the JPEG internal parameters are
1039 The following fields in the JPEG object are set by jpeg_read_header() and
1055 The JPEG color space, unfortunately, is something of a guess since the JPEG
1121 CAUTION: if the JPEG library creates its own colormap, the storage
1141 progressive JPEG files; if FALSE, not. Default is TRUE. Early
1160 JPEG library's memory manager to allocate output buffer space, because you
1187 The JPEG standard itself is "color blind" and doesn't specify any particular
1190 existing de-facto JPEG file format standards specify YCbCr or grayscale data
1195 The JPEG library can handle the most common colorspace conversions (namely
1202 in_color_space. This is transformed to the JPEG file's color space given
1203 by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color
1215 indicate the color space of the JPEG file. It is important to ensure that
1216 these are written correctly, or omitted if the JPEG file's color space is not
1219 properly, so long as it is told the truth about the JPEG color space.
1231 For decompression, the JPEG file's color space is given in jpeg_color_space,
1235 guess. If you know the JPEG file's color space for certain, you can override
1254 CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG
1260 Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK
1261 data in the same inverted-YCCK representation used in bare JPEG files, but
1264 EPS/JPEG files, and will omit the PS-level inversion. (But the data
1265 polarity used in bare JPEG files will not change in 3.0.) In either case,
1266 the JPEG library must not invert the data itself, or else Ghostscript would
1273 When the default error handler is used, any error detected inside the JPEG
1280 The JPEG library never writes any message directly; it always goes through
1289 You may, if you wish, simply replace the entire JPEG error handling module
1296 All of the error handling routines will receive a pointer to the JPEG object
1301 additional data which is not known to the JPEG library or the standard error
1302 handler. The most convenient way to do this is to embed either the JPEG
1307 JPEG object, which the application can also use to find related data.
1319 clean up the JPEG object with jpeg_abort() or jpeg_destroy().
1322 Actual output of any JPEG message. Override this to send messages
1339 Only error_exit() and emit_message() are called from the rest of the JPEG
1345 JPEG library code. You could replace the message texts (for instance, with
1375 The JPEG compression library sends its compressed data to a "destination
1388 decompress a JPEG datastream that was all in memory, you could just make the
1441 the JPEG compression object. This can be done in-line in your setup code if
1516 pointers, and insert a pointer to the struct into the "src" field of the JPEG
1528 Some applications need to use the JPEG library as an incremental memory-to-
1546 that it has done nothing. Upon seeing this, the JPEG library suspends
1549 JPEG library again.
1578 The compressor does not allow suspension while it is trying to write JPEG
1647 The decompressor does not attempt to suspend within standard JPEG markers;
1650 longest standard marker in the file. Standard JPEG markers should normally
1683 If the JPEG library has not moved the pointer/count forward in the current
1700 Progressive JPEG support
1703 Progressive JPEG rearranges the stored data into a series of scans of
1704 increasing quality. In situations where a JPEG file is transmitted across a
1708 identical to that of a regular (sequential) JPEG file of the same quality
1709 setting. Progressive JPEG files are often slightly smaller than equivalent
1710 sequential JPEG files, but the possibility of incremental display is the main
1711 reason for using progressive JPEG.
1713 The IJG encoder library generates progressive JPEG files when given a
1715 Creation of progressive JPEG files is otherwise transparent to the encoder.
1716 Progressive JPEG files can also be read transparently by the decoder library.
1724 Each displayed scan requires about as much work to decode as a full JPEG
1739 To create a progressive JPEG file (or a multiple-scan sequential JPEG file),
1754 mode when creating a progressive JPEG file, because the default Huffman
1776 This mode is typically used for incremental display of progressive JPEG files,
1777 but it can be used with any JPEG file. Each scan of a progressive JPEG file
1851 routine can be called at any time after initializing the JPEG object. It
1869 This is discussed further under "I/O suspension", above. (Note: the JPEG
1872 same JPEG object in another thread.)
2023 This setting is relevant only when decoding a progressive JPEG image.
2099 for all JPEG images, even single-scan ones. This will work, but it is
2104 maximum performance on baseline JPEG files, you should use buffered-image
2114 possible. If the JPEG memory manager has to use a temporary file, you will
2138 A JPEG compression or decompression object can be reused to process multiple
2141 feature. Rather, reuse of an object provides support for abbreviated JPEG
2145 A JPEG file normally contains several hundred bytes worth of quantization
2148 The JPEG standard therefore permits tables to be omitted. The standard
2149 defines three classes of JPEG datastreams:
2151 the image. These are the usual kind of JPEG file.
2170 The JPEG library provides support for reading and writing any combination of
2208 create JPEG compression object
2209 set JPEG parameters
2217 Since the JPEG
2230 a JPEG decompression object to read the specification file, then copying the
2275 create JPEG decompression object
2297 without releasing/recreating the JPEG object or the data source module.
2315 Some applications may need to insert or extract special data in the JPEG
2316 datastream. The JPEG standard provides marker types "COM" (comment) and
2342 selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if
2345 Adobe markers and will set the JPEG colorspace properly when one is found.
2420 within the JPEG file includes it. (Hence the maximum data length is really
2475 Some applications need to supply already-downsampled image data to the JPEG
2489 in the JPEG file (please read the earlier section on Special color spaces)
2490 and downsampled to the sampling factors specified in the JPEG parameters.
2491 You must supply the data in the format used internally by the JPEG library,
2598 It is possible to read or write the contents of a JPEG file as raw DCT
2600 transcoding between different JPEG file formats. Other possible applications
2601 include lossless cropping of a JPEG image, lossless reassembly of a
2602 multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc.
2604 To read the contents of a JPEG file as DCT coefficients, open the file and do
2609 descriptors. Each virtual array can be accessed directly using the JPEG
2612 for simple transcoding to a different JPEG file format, the array list can
2616 normal array order (not JPEG zigzag order). The block arrays contain only
2642 To write the contents of a JPEG file as DCT coefficients, you must provide
2644 block arrays read from an input JPEG file by jpeg_read_coefficients(), or
2645 allocate virtual arrays from the JPEG compression object and fill them
2666 When writing raw DCT coefficients, it is crucial that the JPEG quantization
2668 resulting file will be invalid. For transcoding from an existing JPEG file,
2673 JPEG input file --- that is, it should be awaiting jpeg_finish_decompress().
2678 emitting abbreviated JPEG files by accident. If you really want to emit an
2679 abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables'
2687 Some applications may need to regain control from the JPEG library every so
2714 make sure it will live as long as the JPEG object does. Allocating from the
2715 JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You
2734 depends on the number of scans in the JPEG file, which isn't always known in
2754 This section covers some key facts about the JPEG library's built-in memory
2763 Some data is allocated "permanently" and will not be freed until the JPEG
2769 Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object.
2791 after creating the JPEG object. (Of course, there is still a minimum size for
2801 important to clean up the JPEG object properly to ensure that the temporary
2807 or jpeg_destroy() for any active JPEG objects. A handler is not needed with
2818 JPEG process), and operating mode (application-selected options).
2828 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG
2838 The above figures are valid for 8-bit JPEG data precision and a machine with
2839 32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and
2864 The JPEG standard provides for both the baseline 8-bit DCT process and
2865 a 12-bit DCT process. The IJG code supports 12-bit lossy JPEG if you define
2887 by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we
2915 The JPEG library has been written to be extremely portable; the sample
2946 The JPEG library proper does not assume ASCII representation of characters.
2951 The JPEG library does not rely heavily on the C library. In particular, C
2978 The JPEG library typically needs 2Kb-3Kb of stack space. It will also
2993 released until you destroy the JPEG object. This is only an issue if you
2994 save a JPEG object between compression or decompression operations.
3006 can use it; the JPEG library is significantly faster in flat model.