Lines Matching refs:JPEG
1 USING THE IJG JPEG LIBRARY
3 This file was part of the Independent JPEG Group's software:
11 This file describes how to use the IJG JPEG library within an application
15 JPEG library. Also see jpeglib.h (the include file to be used by application
46 Progressive JPEG support
70 The IJG JPEG library provides C code to read and write JPEG-compressed image
77 JPEG standard but is necessary for typical applications of JPEG. These
78 functions preprocess the image before JPEG compression or postprocess it after
85 A wide range of quality vs. speed tradeoffs are possible in JPEG processing,
91 low-quality modes may not meet the JPEG standard's accuracy requirements;
95 the ISO JPEG standard; most baseline, extended-sequential, and progressive
96 JPEG processes are supported. (Our subset includes all features now in common
99 * Lossless JPEG
106 By itself, the library handles only interchange JPEG datastreams --- in
108 surrounding code to process interchange or abbreviated JPEG datastreams that
110 used by the free LIBTIFF library to support JPEG compression in TIFF.)
116 The rough outline of a JPEG compression operation is:
118 Allocate and initialize a JPEG compression object
125 Release the JPEG compression object
127 A JPEG compression object holds parameters and working state for the JPEG
131 same parameter settings for a sequence of images. Re-use of a JPEG object
132 also has important implications for processing abbreviated JPEG datastreams,
142 Similarly, the rough outline of a JPEG decompression operation is:
144 Allocate and initialize a JPEG decompression object
152 Release the JPEG decompression object
166 by calling jpeg_abort(); or, if you do not need to retain the JPEG object,
169 JPEG compression and decompression objects are two separate struct types.
173 The JPEG library has no static variables: all state is in the compression
175 compression and decompression operations concurrently, using multiple JPEG
190 image data format that the JPEG library expects or returns.
199 programs don't work with grayscale JPEG files.
201 There is no provision for colormapped input. JPEG files are always full-color
204 JPEG often doesn't work very well with source data that has been colormapped,
205 because of dithering noise. This is discussed in more detail in the JPEG FAQ
237 except that colormapped output is supported. (Again, a JPEG file is never
246 (ie, at most 256 colors for an 8-bit JPEG library).
252 Here we revisit the JPEG compression outline given in the overview.
254 1. Allocate and initialize a JPEG compression object.
256 A JPEG compression object is a "struct jpeg_compress_struct". (It also has
260 whole JPEG compression sequence. Otherwise it can be static or allocated
263 You will also need a structure representing a JPEG error handler. The part
268 handler. The default error handler will print JPEG error/warning messages
272 the JPEG object's "err" field, and then call jpeg_create_compress() to
273 initialize the rest of the JPEG object.
290 As previously mentioned, the JPEG library delivers compressed data to a
323 fields in the JPEG object (cinfo structure):
330 The image dimensions are, hopefully, obvious. JPEG supports image dimensions
337 JPEG has a large number of compression parameters that determine how the
366 storage, and emit the first few bytes of the JPEG datastream header.
372 The "TRUE" parameter ensures that a complete JPEG interchange datastream
377 Once you have called jpeg_start_compress(), you may not alter any JPEG
378 parameters or other fields of the JPEG object until you have completed
396 can use the JPEG library's virtual array mechanism to invert the data
400 in the next_scanline field of the JPEG object. Usually you can just use
436 jpeg_finish_compress() also releases working memory associated with the JPEG
456 After completing a compression cycle, you may dispose of the JPEG object
460 If you do not change any JPEG parameters, the new datastream will be written
467 7. Release the JPEG compression object.
469 When you are done with a JPEG compression object, destroy it by calling
492 * If you don't need the JPEG object any more, just call
497 * If you want to re-use the JPEG object, call jpeg_abort_compress(), or call
506 jpeg_destroy() and jpeg_abort() are the only safe calls to make on a JPEG
515 Here we revisit the JPEG decompression outline given in the overview.
517 1. Allocate and initialize a JPEG decompression object.
537 As previously mentioned, the JPEG library reads compressed data from a "data
563 jpeg_finish_decompress(). If you wish to read a series of JPEG images from
565 jpeg_finish_decompress() sequence without reinitializing either the JPEG
578 info have been stored in the JPEG object. The application may wish to
585 * Abbreviated JPEG files are to be processed --- see the section on
587 interchange JPEG files need not be concerned with this case either.
590 image dimensions and other header info for a JPEG file. In that case,
591 call jpeg_destroy() when you are done with the JPEG object, or call
627 to complete. With a single-scan (non progressive) JPEG file and default
632 scaling, are available in the JPEG object; so is the selected colormap, if
650 Note: if you are using the JPEG library's internal memory manager to allocate
670 out the image in bottom-to-top order, you can use the JPEG library's virtual
675 in the output_scanline field of the JPEG object. Usually you can just use
697 with the JPEG object to be released.
710 After completing a decompression cycle, you may dispose of the JPEG object as
716 8. Release the JPEG decompression object.
718 When you are done with a JPEG decompression object, destroy it by calling
730 jpeg_destroy() if you don't need the JPEG object any more, or
739 that wish to view only a portion of a large JPEG image without decompressing
749 multiple rows in the JPEG image.
765 particular vertical offset in the JPEG image in order to decode a subset of the
771 1) JPEG decompression occurs in blocks, so if jpeg_skip_scanlines() is
788 only a portion of each row in the JPEG image. It must be called after
823 Applications using the JPEG library should include the header file jpeglib.h
829 If the application needs to refer to individual JPEG library error codes, also
833 installing the JPEG header files in a system directory, you will want to
836 The most convenient way to include the JPEG code into your executable program
843 While you can build the JPEG library as a shared library if the whim strikes
854 It may be worth pointing out that the core JPEG library does not actually
868 This section describes all the optional parameters you can set for JPEG
871 of the JPEG standard; if you don't know what a parameter is for, it's best
873 more info about JPEG.
876 all the parameters; that way your code is more likely to work with future JPEG
884 This routine sets all JPEG parameters to reasonable defaults, using
890 Sets the JPEG file's colorspace (field jpeg_color_space) as specified,
898 Selects an appropriate JPEG colorspace based on cinfo->in_color_space,
901 just the colorspace-dependent JPEG parameters.
904 Constructs JPEG quantization tables appropriate for the indicated
910 entries are constrained to the range 1..255 for full JPEG baseline
950 the basic table to be given in JPEG zigzag order. If you need to
956 Generates a default scan script for writing a progressive-JPEG file.
959 the JPEG color space is set correctly before calling this routine.
997 The JPEG color space and corresponding number of components; see
1013 To emit restart markers in the JPEG file, set one of these nonzero.
1019 NOTE: the overhead of restart markers is higher in grayscale JPEG
1027 single-scan sequential JPEG file. If not NULL, scan_info points to
1029 compressor will then write a JPEG file having one scan for each scan
1031 progressive JPEG files. The library checks that the scan array
1032 defines a valid JPEG scan sequence. (jpeg_simple_progression creates
1033 a suitable scan definition array for progressive JPEG.) This is
1034 discussed further under "Progressive JPEG support".
1043 jpeg_set_colorspace() set this TRUE if a JFIF-legal JPEG color space
1063 jpeg_set_colorspace() set this TRUE if JPEG color space RGB, CMYK,
1067 default behavior ensures that the JPEG file's color space can be
1083 Note that the q_scale_factor[] values use "linear" scales, so JPEG
1109 JPEG sample tables by jpeg_set_defaults(). If you need to allocate
1117 The actual dimensions of the JPEG image that will be written to the file are
1130 JPEG color space, *not* the source image color space. A suitably large
1135 The one-byte identifier code to be recorded in the JPEG file for
1142 be 1..4 according to the JPEG standard. Note that larger sampling
1167 parameter selection, since all of the JPEG internal parameters are
1177 The following fields in the JPEG object are set by jpeg_read_header() and
1193 The JPEG color space, unfortunately, is something of a guess since the JPEG
1260 CAUTION: if the JPEG library creates its own colormap, the storage
1279 SIMD extensions.) If the JPEG image was compressed using a quality
1289 actually produce a more lossy output image than if the JPEG image had
1304 progressive JPEG files; if FALSE, not. Default is TRUE. Early
1323 JPEG library's memory manager to allocate output buffer space, because you
1350 The JPEG standard itself is "color blind" and doesn't specify any particular
1353 existing de-facto JPEG file format standards specify YCbCr or grayscale data
1358 The JPEG library can handle the most common colorspace conversions (namely
1365 in_color_space. This is transformed to the JPEG file's color space given
1366 by jpeg_color_space. jpeg_set_defaults() chooses a reasonable JPEG color
1378 indicate the color space of the JPEG file. It is important to ensure that
1379 these are written correctly, or omitted if the JPEG file's color space is not
1382 properly, so long as it is told the truth about the JPEG color space.
1394 For decompression, the JPEG file's color space is given in jpeg_color_space,
1398 guess. If you know the JPEG file's color space for certain, you can override
1418 CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG
1424 Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK
1425 data in the same inverted-YCCK representation used in bare JPEG files, but
1428 EPS/JPEG files, and will omit the PS-level inversion. (But the data
1429 polarity used in bare JPEG files will not change in 3.0.) In either case,
1430 the JPEG library must not invert the data itself, or else Ghostscript would
1437 When the default error handler is used, any error detected inside the JPEG
1444 The JPEG library never writes any message directly; it always goes through
1453 You may, if you wish, simply replace the entire JPEG error handling module
1460 All of the error handling routines will receive a pointer to the JPEG object
1465 additional data which is not known to the JPEG library or the standard error
1466 handler. The most convenient way to do this is to embed either the JPEG
1471 JPEG object, which the application can also use to find related data.
1483 clean up the JPEG object with jpeg_abort() or jpeg_destroy().
1486 Actual output of any JPEG message. Override this to send messages
1503 Only error_exit() and emit_message() are called from the rest of the JPEG
1509 JPEG library code. You could replace the message texts (for instance, with
1539 The JPEG compression library sends its compressed data to a "destination
1606 the JPEG compression object. This can be done in-line in your setup code if
1682 pointers, and insert a pointer to the struct into the "src" field of the JPEG
1694 Some applications need to use the JPEG library as an incremental memory-to-
1712 that it has done nothing. Upon seeing this, the JPEG library suspends
1715 JPEG library again.
1744 The compressor does not allow suspension while it is trying to write JPEG
1813 The decompressor does not attempt to suspend within standard JPEG markers;
1816 longest standard marker in the file. Standard JPEG markers should normally
1849 If the JPEG library has not moved the pointer/count forward in the current
1866 Progressive JPEG support
1869 Progressive JPEG rearranges the stored data into a series of scans of
1870 increasing quality. In situations where a JPEG file is transmitted across a
1874 identical to that of a regular (sequential) JPEG file of the same quality
1875 setting. Progressive JPEG files are often slightly smaller than equivalent
1876 sequential JPEG files, but the possibility of incremental display is the main
1877 reason for using progressive JPEG.
1879 The IJG encoder library generates progressive JPEG files when given a
1881 Creation of progressive JPEG files is otherwise transparent to the encoder.
1882 Progressive JPEG files can also be read transparently by the decoder library.
1890 Each displayed scan requires about as much work to decode as a full JPEG
1905 To create a progressive JPEG file (or a multiple-scan sequential JPEG file),
1920 mode when creating a progressive JPEG file, because the default Huffman
1942 This mode is typically used for incremental display of progressive JPEG files,
1943 but it can be used with any JPEG file. Each scan of a progressive JPEG file
2017 routine can be called at any time after initializing the JPEG object. It
2035 This is discussed further under "I/O suspension", above. (Note: the JPEG
2038 same JPEG object in another thread.)
2189 This setting is relevant only when decoding a progressive JPEG image.
2265 for all JPEG images, even single-scan ones. This will work, but it is
2270 maximum performance on baseline JPEG files, you should use buffered-image
2280 possible. If the JPEG memory manager has to use a temporary file, you will
2304 A JPEG compression or decompression object can be reused to process multiple
2307 feature. Rather, reuse of an object provides support for abbreviated JPEG
2311 A JPEG file normally contains several hundred bytes worth of quantization
2314 The JPEG standard therefore permits tables to be omitted. The standard
2315 defines three classes of JPEG datastreams:
2317 the image. These are the usual kind of JPEG file.
2336 The JPEG library provides support for reading and writing any combination of
2374 create JPEG compression object
2375 set JPEG parameters
2383 Since the JPEG parameters are not altered between writing the table file and
2396 a JPEG decompression object to read the specification file, then copying the
2441 create JPEG decompression object
2463 without releasing/recreating the JPEG object or the data source module.
2481 Some applications may need to insert or extract special data in the JPEG
2482 datastream. The JPEG standard provides marker types "COM" (comment) and
2508 selected JPEG colorspace is grayscale or YCbCr, or an Adobe APP14 marker if
2511 Adobe markers and will set the JPEG colorspace properly when one is found.
2586 within the JPEG file includes it. (Hence the maximum data length is really
2642 Consortium (ICC) device profiles embedded in JFIF JPEG image files:
2651 The ICC has defined a standard for including such data in JPEG "APP2" markers.
2654 JPEG file while writing it, or to extract the profile data from a JPEG file
2679 Some applications need to supply already-downsampled image data to the JPEG
2693 in the JPEG file (please read the earlier section on Special color spaces)
2694 and downsampled to the sampling factors specified in the JPEG parameters.
2695 You must supply the data in the format used internally by the JPEG library,
2802 It is possible to read or write the contents of a JPEG file as raw DCT
2804 transcoding between different JPEG file formats. Other possible applications
2805 include lossless cropping of a JPEG image, lossless reassembly of a
2806 multi-strip or multi-tile TIFF/JPEG file into a single JPEG datastream, etc.
2808 To read the contents of a JPEG file as DCT coefficients, open the file and do
2813 descriptors. Each virtual array can be accessed directly using the JPEG
2816 for simple transcoding to a different JPEG file format, the array list can
2820 normal array order (not JPEG zigzag order). The block arrays contain only
2846 To write the contents of a JPEG file as DCT coefficients, you must provide
2848 block arrays read from an input JPEG file by jpeg_read_coefficients(), or
2849 allocate virtual arrays from the JPEG compression object and fill them
2870 When writing raw DCT coefficients, it is crucial that the JPEG quantization
2872 resulting file will be invalid. For transcoding from an existing JPEG file,
2877 JPEG input file --- that is, it should be awaiting jpeg_finish_decompress().
2882 emitting abbreviated JPEG files by accident. If you really want to emit an
2883 abbreviated JPEG file, call jpeg_suppress_tables(), or set the tables'
2891 Some applications may need to regain control from the JPEG library every so
2918 make sure it will live as long as the JPEG object does. Allocating from the
2919 JPEG memory manager with lifetime JPOOL_PERMANENT will work nicely.) You
2938 depends on the number of scans in the JPEG file, which isn't always known in
2958 This section covers some key facts about the JPEG library's built-in memory
2967 Some data is allocated "permanently" and will not be freed until the JPEG
2973 Use JPOOL_PERMANENT to get storage that lasts as long as the JPEG object.
2988 after creating the JPEG object. (Of course, there is still a minimum size for
3008 JPEG process), and operating mode (application-selected options).
3018 3. A full-image DCT coefficient buffer is needed to decode a multi-scan JPEG
3028 The above figures are valid for 8-bit JPEG data precision and a machine with
3029 32-bit ints. For 12-bit JPEG data, double the size of the strip buffers and
3054 The JPEG standard provides for both the baseline 8-bit DCT process and
3055 a 12-bit DCT process. The IJG code supports 12-bit lossy JPEG if you define
3073 by MAX_COMPONENTS. The JPEG standard allows up to 255 components, but we
3101 The JPEG library has been written to be extremely portable; the sample
3131 The JPEG library proper does not assume ASCII representation of characters.
3136 The JPEG library does not rely heavily on the C library. In particular, C