Home » Archimedes archive » Acorn User » AU 1997-Xmas B.adf » PD » MakeJPEG/!MakeJPEG/Resources/JPEG/doc/wizard

MakeJPEG/!MakeJPEG/Resources/JPEG/doc/wizard

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1997-Xmas B.adf » PD
Filename: MakeJPEG/!MakeJPEG/Resources/JPEG/doc/wizard
Read OK:
File size: 261F bytes
Load address: 0000
Exec address: 0000
File contents
Advanced usage instructions for the Independent JPEG Group's JPEG software
==========================================================================

This file describes cjpeg's "switches for wizards".

The "wizard" switches are intended for experimentation with JPEG by persons
who are reasonably knowledgeable about the JPEG standard.  If you don't know
what you are doing, DON'T USE THESE SWITCHES.  You'll likely produce files
with worse image quality and/or poorer compression than you'd get from the
default settings.  Furthermore, these switches must be used with caution
when making files intended for general use, because not all JPEG decoders
will support unusual JPEG parameter settings.


Quantization Table Adjustment
-----------------------------

Ordinarily, cjpeg starts with a default set of tables (the same ones given
as examples in the JPEG standard) and scales them up or down according to
the -quality setting.  The details of the scaling algorithm can be found in
jcparam.c.  At very low quality settings, some quantization table entries
can get scaled up to values exceeding 255.  Although 2-byte quantization
values are supported by the IJG software, this feature is not in baseline
JPEG and is not supported by all implementations.  If you need to ensure
wide compatibility of low-quality files, you can constrain the scaled
quantization values to no more than 255 by giving the -baseline switch.
Note that use of -baseline will result in poorer quality for the same file
size, since more bits than necessary are expended on higher AC coefficients.

You can substitute a different set of quantization values by using the
-qtables switch:

	-qtables file	Use the quantization tables given in the named file.

The specified file should be a text file containing decimal quantization
values.  The file should contain one to four tables, each of 64 elements.
The tables are implicitly numbered 0,1,etc. in order of appearance.  Table
entries appear in normal array order (NOT in the zigzag order in which they
will be stored in the JPEG file).

Quantization table files are free format, in that arbitrary whitespace can
appear between numbers.  Also, comments can be included: a comment starts
with '#' and extends to the end of the line.  Here is an example file that
duplicates the default quantization tables:

	# Quantization tables given in JPEG spec, section K.1

	# This is table 0 (the luminance table):
	  16  11  10  16  24  40  51  61
	  12  12  14  19  26  58  60  55
	  14  13  16  24  40  57  69  56
	  14  17  22  29  51  87  80  62
	  18  22  37  56  68 109 103  77
	  24  35  55  64  81 104 113  92
	  49  64  78  87 103 121 120 101
	  72  92  95  98 112 100 103  99

	# This is table 1 (the chrominance table):
	  17  18  24  47  99  99  99  99
	  18  21  26  66  99  99  99  99
	  24  26  56  99  99  99  99  99
	  47  66  99  99  99  99  99  99
	  99  99  99  99  99  99  99  99
	  99  99  99  99  99  99  99  99
	  99  99  99  99  99  99  99  99
	  99  99  99  99  99  99  99  99

If the -qtables switch is used without -quality, then the specified tables
are used exactly as-is.  If both -qtables and -quality are used, then the
tables taken from the file are scaled in the same fashion that the default
tables would be scaled for that quality setting.  If -baseline appears, then
the quantization values are constrained to the range 1-255.

By default, cjpeg will use quantization table 0 for luminance components and
table 1 for chrominance components.  To override this choice, use the -qslots
switch:

	-qslots N[,...]		Select which quantization table to use for
				each color component.

The -qslots switch specifies a quantization table number for each color
component, in the order in which the components appear in the JPEG SOF marker.
For example, to create a separate table for each of Y,Cb,Cr, you could
provide a -qtables file that defines three quantization tables and say
"-qslots 0,1,2".  If -qslots gives fewer table numbers than there are color
components, then the last table number is repeated as necessary.


Sampling Factor Adjustment
--------------------------

By default, cjpeg uses 2:1 horizontal and vertical downsampling when
compressing YCbCr data, and no downsampling for all other color spaces.
You can override this default with the -sample switch:

	-sample HxV[,...]	Set JPEG sampling factors for each color
				component.

The -sample switch specifies the JPEG sampling factors for each color
component, in the order in which they appear in the JPEG SOF marker.
If you specify fewer HxV pairs than there are components, the remaining
components are set to 1x1 sampling.  For example, the default YCbCr setting
is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to
"-sample 2x2".

There are still some JPEG decoders in existence that support only 2x1
sampling (also called 4:2:2 sampling).  Compatibility with such decoders can
be achieved by specifying "-sample 2x1".  This is not recommended unless
really necessary, since it increases file size and encoding/decoding time
with very little quality gain.


Multiple Scan / Progression Control
-----------------------------------

By default, cjpeg emits a single-scan sequential JPEG file.  The
-progressive switch generates a progressive JPEG file using a default series
of progression parameters.  You can create multiple-scan sequential JPEG
files or progressive JPEG files with custom progression parameters by using
the -scans switch:

	-scans file	Use the scan sequence given in the named file.

The specified file should be a text file containing a "scan script".
The script specifies the contents and ordering of the scans to be emitted.
Each entry in the script defines one scan.  A scan definition specifies
the components to be included in the scan, and for progressive JPEG it also
specifies the progression parameters Ss,Se,Ah,Al for the scan.  Scan
definitions are separated by semicolons (';').  A semicolon after the last
scan definition is optional.

Each scan definition contains one to four component indexes, optionally
followed by a colon (':') and the four progressive-JPEG parameters.  The
component indexes denote which color component(s) are to be transmitted in
the scan.  Components are numbered in the order in which they appear in the
JPEG SOF marker, with the first component being numbered 0.  (Note that these
indexes are not the "component ID" codes assigned to the components, just
positional indexes.)

The progression parameters for each scan are:
	Ss	Zigzag index of first coefficient included in scan
	Se	Zigzag index of last coefficient included in scan
	Ah	Zero for first scan of a coefficient, else Al of prior scan
	Al	Successive approximation low bit position for scan
If the progression parameters are omitted, the values 0,63,0,0 are used,
producing a sequential JPEG file.  cjpeg automatically determines whether
the script represents a progressive or sequential file, by observing whether
Ss and Se values other than 0 and 63 appear.  (The -progressive switch is
not needed to specify this; in fact, it is ignored when -scans appears.)
The scan script must meet the JPEG restrictions on progression sequences.
(cjpeg checks that the spec's requirements are obeyed.)

Scan script files are free format, in that arbitrary whitespace can appear
between numbers and around punctuation.  Also, comments can be included: a
comment starts with '#' and extends to the end of the line.  For additional
legibility, commas or dashes can be placed between values.  (Actually, any
single punctuation character other than ':' or ';' can be inserted.)  For
example, the following two scan definitions are equivalent:
	0 1 2: 0 63 0 0;
	0,1,2 : 0-63, 0,0 ;

Here is an example of a scan script that generates a partially interleaved
sequential JPEG file:

	0;			# Y only in first scan
	1 2;			# Cb and Cr in second scan

Here is an example of a progressive scan script using only spectral selection
(no successive approximation):

	# Interleaved DC scan for Y,Cb,Cr:
	0,1,2: 0-0,   0, 0 ;
	# AC scans:
	0:     1-2,   0, 0 ;	# First two Y AC coefficients
	0:     3-5,   0, 0 ;	# Three more
	1:     1-63,  0, 0 ;	# All AC coefficients for Cb
	2:     1-63,  0, 0 ;	# All AC coefficients for Cr
	0:     6-9,   0, 0 ;	# More Y coefficients
	0:     10-63, 0, 0 ;	# Remaining Y coefficients

Here is an example of a successive-approximation script.  This is equivalent
to the default script used by "cjpeg -progressive" for YCbCr images:

	# Initial DC scan for Y,Cb,Cr (lowest bit not sent)
	0,1,2: 0-0,   0, 1 ;
	# First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits:
	0:     1-5,   0, 2 ;
	# Send all Cr,Cb AC coefficients, minus lowest bit:
	# (chroma data is usually too small to be worth subdividing further;
	#  but note we send Cr first since eye is least sensitive to Cb)
	2:     1-63,  0, 1 ;
	1:     1-63,  0, 1 ;
	# Send remaining Y AC coefficients, minus 2 lowest bits:
	0:     6-63,  0, 2 ;
	# Send next-to-lowest bit of all Y AC coefficients:
	0:     1-63,  2, 1 ;
	# At this point we've sent all but the lowest bit of all coefficients.
	# Send lowest bit of DC coefficients
	0,1,2: 0-0,   1, 0 ;
	# Send lowest bit of AC coefficients
	2:     1-63,  1, 0 ;
	1:     1-63,  1, 0 ;
	# Y AC lowest bit scan is last; it's usually the largest scan
	0:     1-63,  1, 0 ;

It may be worth pointing out that this script is tuned for quality settings
of around 50 to 75.  For lower quality settings, you'd probably want to use
a script with fewer stages of successive approximation (otherwise the
initial scans will be really bad).  For higher quality settings, you might
want to use more stages of successive approximation (so that the initial
scans are not too large).
00000000  41 64 76 61 6e 63 65 64  20 75 73 61 67 65 20 69  |Advanced usage i|
00000010  6e 73 74 72 75 63 74 69  6f 6e 73 20 66 6f 72 20  |nstructions for |
00000020  74 68 65 20 49 6e 64 65  70 65 6e 64 65 6e 74 20  |the Independent |
00000030  4a 50 45 47 20 47 72 6f  75 70 27 73 20 4a 50 45  |JPEG Group's JPE|
00000040  47 20 73 6f 66 74 77 61  72 65 0a 3d 3d 3d 3d 3d  |G software.=====|
00000050  3d 3d 3d 3d 3d 3d 3d 3d  3d 3d 3d 3d 3d 3d 3d 3d  |================|
*
00000090  3d 3d 3d 3d 3d 0a 0a 54  68 69 73 20 66 69 6c 65  |=====..This file|
000000a0  20 64 65 73 63 72 69 62  65 73 20 63 6a 70 65 67  | describes cjpeg|
000000b0  27 73 20 22 73 77 69 74  63 68 65 73 20 66 6f 72  |'s "switches for|
000000c0  20 77 69 7a 61 72 64 73  22 2e 0a 0a 54 68 65 20  | wizards"...The |
000000d0  22 77 69 7a 61 72 64 22  20 73 77 69 74 63 68 65  |"wizard" switche|
000000e0  73 20 61 72 65 20 69 6e  74 65 6e 64 65 64 20 66  |s are intended f|
000000f0  6f 72 20 65 78 70 65 72  69 6d 65 6e 74 61 74 69  |or experimentati|
00000100  6f 6e 20 77 69 74 68 20  4a 50 45 47 20 62 79 20  |on with JPEG by |
00000110  70 65 72 73 6f 6e 73 0a  77 68 6f 20 61 72 65 20  |persons.who are |
00000120  72 65 61 73 6f 6e 61 62  6c 79 20 6b 6e 6f 77 6c  |reasonably knowl|
00000130  65 64 67 65 61 62 6c 65  20 61 62 6f 75 74 20 74  |edgeable about t|
00000140  68 65 20 4a 50 45 47 20  73 74 61 6e 64 61 72 64  |he JPEG standard|
00000150  2e 20 20 49 66 20 79 6f  75 20 64 6f 6e 27 74 20  |.  If you don't |
00000160  6b 6e 6f 77 0a 77 68 61  74 20 79 6f 75 20 61 72  |know.what you ar|
00000170  65 20 64 6f 69 6e 67 2c  20 44 4f 4e 27 54 20 55  |e doing, DON'T U|
00000180  53 45 20 54 48 45 53 45  20 53 57 49 54 43 48 45  |SE THESE SWITCHE|
00000190  53 2e 20 20 59 6f 75 27  6c 6c 20 6c 69 6b 65 6c  |S.  You'll likel|
000001a0  79 20 70 72 6f 64 75 63  65 20 66 69 6c 65 73 0a  |y produce files.|
000001b0  77 69 74 68 20 77 6f 72  73 65 20 69 6d 61 67 65  |with worse image|
000001c0  20 71 75 61 6c 69 74 79  20 61 6e 64 2f 6f 72 20  | quality and/or |
000001d0  70 6f 6f 72 65 72 20 63  6f 6d 70 72 65 73 73 69  |poorer compressi|
000001e0  6f 6e 20 74 68 61 6e 20  79 6f 75 27 64 20 67 65  |on than you'd ge|
000001f0  74 20 66 72 6f 6d 20 74  68 65 0a 64 65 66 61 75  |t from the.defau|
00000200  6c 74 20 73 65 74 74 69  6e 67 73 2e 20 20 46 75  |lt settings.  Fu|
00000210  72 74 68 65 72 6d 6f 72  65 2c 20 74 68 65 73 65  |rthermore, these|
00000220  20 73 77 69 74 63 68 65  73 20 6d 75 73 74 20 62  | switches must b|
00000230  65 20 75 73 65 64 20 77  69 74 68 20 63 61 75 74  |e used with caut|
00000240  69 6f 6e 0a 77 68 65 6e  20 6d 61 6b 69 6e 67 20  |ion.when making |
00000250  66 69 6c 65 73 20 69 6e  74 65 6e 64 65 64 20 66  |files intended f|
00000260  6f 72 20 67 65 6e 65 72  61 6c 20 75 73 65 2c 20  |or general use, |
00000270  62 65 63 61 75 73 65 20  6e 6f 74 20 61 6c 6c 20  |because not all |
00000280  4a 50 45 47 20 64 65 63  6f 64 65 72 73 0a 77 69  |JPEG decoders.wi|
00000290  6c 6c 20 73 75 70 70 6f  72 74 20 75 6e 75 73 75  |ll support unusu|
000002a0  61 6c 20 4a 50 45 47 20  70 61 72 61 6d 65 74 65  |al JPEG paramete|
000002b0  72 20 73 65 74 74 69 6e  67 73 2e 0a 0a 0a 51 75  |r settings....Qu|
000002c0  61 6e 74 69 7a 61 74 69  6f 6e 20 54 61 62 6c 65  |antization Table|
000002d0  20 41 64 6a 75 73 74 6d  65 6e 74 0a 2d 2d 2d 2d  | Adjustment.----|
000002e0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000002f0  2d 2d 2d 2d 2d 2d 2d 2d  2d 0a 0a 4f 72 64 69 6e  |---------..Ordin|
00000300  61 72 69 6c 79 2c 20 63  6a 70 65 67 20 73 74 61  |arily, cjpeg sta|
00000310  72 74 73 20 77 69 74 68  20 61 20 64 65 66 61 75  |rts with a defau|
00000320  6c 74 20 73 65 74 20 6f  66 20 74 61 62 6c 65 73  |lt set of tables|
00000330  20 28 74 68 65 20 73 61  6d 65 20 6f 6e 65 73 20  | (the same ones |
00000340  67 69 76 65 6e 0a 61 73  20 65 78 61 6d 70 6c 65  |given.as example|
00000350  73 20 69 6e 20 74 68 65  20 4a 50 45 47 20 73 74  |s in the JPEG st|
00000360  61 6e 64 61 72 64 29 20  61 6e 64 20 73 63 61 6c  |andard) and scal|
00000370  65 73 20 74 68 65 6d 20  75 70 20 6f 72 20 64 6f  |es them up or do|
00000380  77 6e 20 61 63 63 6f 72  64 69 6e 67 20 74 6f 0a  |wn according to.|
00000390  74 68 65 20 2d 71 75 61  6c 69 74 79 20 73 65 74  |the -quality set|
000003a0  74 69 6e 67 2e 20 20 54  68 65 20 64 65 74 61 69  |ting.  The detai|
000003b0  6c 73 20 6f 66 20 74 68  65 20 73 63 61 6c 69 6e  |ls of the scalin|
000003c0  67 20 61 6c 67 6f 72 69  74 68 6d 20 63 61 6e 20  |g algorithm can |
000003d0  62 65 20 66 6f 75 6e 64  20 69 6e 0a 6a 63 70 61  |be found in.jcpa|
000003e0  72 61 6d 2e 63 2e 20 20  41 74 20 76 65 72 79 20  |ram.c.  At very |
000003f0  6c 6f 77 20 71 75 61 6c  69 74 79 20 73 65 74 74  |low quality sett|
00000400  69 6e 67 73 2c 20 73 6f  6d 65 20 71 75 61 6e 74  |ings, some quant|
00000410  69 7a 61 74 69 6f 6e 20  74 61 62 6c 65 20 65 6e  |ization table en|
00000420  74 72 69 65 73 0a 63 61  6e 20 67 65 74 20 73 63  |tries.can get sc|
00000430  61 6c 65 64 20 75 70 20  74 6f 20 76 61 6c 75 65  |aled up to value|
00000440  73 20 65 78 63 65 65 64  69 6e 67 20 32 35 35 2e  |s exceeding 255.|
00000450  20 20 41 6c 74 68 6f 75  67 68 20 32 2d 62 79 74  |  Although 2-byt|
00000460  65 20 71 75 61 6e 74 69  7a 61 74 69 6f 6e 0a 76  |e quantization.v|
00000470  61 6c 75 65 73 20 61 72  65 20 73 75 70 70 6f 72  |alues are suppor|
00000480  74 65 64 20 62 79 20 74  68 65 20 49 4a 47 20 73  |ted by the IJG s|
00000490  6f 66 74 77 61 72 65 2c  20 74 68 69 73 20 66 65  |oftware, this fe|
000004a0  61 74 75 72 65 20 69 73  20 6e 6f 74 20 69 6e 20  |ature is not in |
000004b0  62 61 73 65 6c 69 6e 65  0a 4a 50 45 47 20 61 6e  |baseline.JPEG an|
000004c0  64 20 69 73 20 6e 6f 74  20 73 75 70 70 6f 72 74  |d is not support|
000004d0  65 64 20 62 79 20 61 6c  6c 20 69 6d 70 6c 65 6d  |ed by all implem|
000004e0  65 6e 74 61 74 69 6f 6e  73 2e 20 20 49 66 20 79  |entations.  If y|
000004f0  6f 75 20 6e 65 65 64 20  74 6f 20 65 6e 73 75 72  |ou need to ensur|
00000500  65 0a 77 69 64 65 20 63  6f 6d 70 61 74 69 62 69  |e.wide compatibi|
00000510  6c 69 74 79 20 6f 66 20  6c 6f 77 2d 71 75 61 6c  |lity of low-qual|
00000520  69 74 79 20 66 69 6c 65  73 2c 20 79 6f 75 20 63  |ity files, you c|
00000530  61 6e 20 63 6f 6e 73 74  72 61 69 6e 20 74 68 65  |an constrain the|
00000540  20 73 63 61 6c 65 64 0a  71 75 61 6e 74 69 7a 61  | scaled.quantiza|
00000550  74 69 6f 6e 20 76 61 6c  75 65 73 20 74 6f 20 6e  |tion values to n|
00000560  6f 20 6d 6f 72 65 20 74  68 61 6e 20 32 35 35 20  |o more than 255 |
00000570  62 79 20 67 69 76 69 6e  67 20 74 68 65 20 2d 62  |by giving the -b|
00000580  61 73 65 6c 69 6e 65 20  73 77 69 74 63 68 2e 0a  |aseline switch..|
00000590  4e 6f 74 65 20 74 68 61  74 20 75 73 65 20 6f 66  |Note that use of|
000005a0  20 2d 62 61 73 65 6c 69  6e 65 20 77 69 6c 6c 20  | -baseline will |
000005b0  72 65 73 75 6c 74 20 69  6e 20 70 6f 6f 72 65 72  |result in poorer|
000005c0  20 71 75 61 6c 69 74 79  20 66 6f 72 20 74 68 65  | quality for the|
000005d0  20 73 61 6d 65 20 66 69  6c 65 0a 73 69 7a 65 2c  | same file.size,|
000005e0  20 73 69 6e 63 65 20 6d  6f 72 65 20 62 69 74 73  | since more bits|
000005f0  20 74 68 61 6e 20 6e 65  63 65 73 73 61 72 79 20  | than necessary |
00000600  61 72 65 20 65 78 70 65  6e 64 65 64 20 6f 6e 20  |are expended on |
00000610  68 69 67 68 65 72 20 41  43 20 63 6f 65 66 66 69  |higher AC coeffi|
00000620  63 69 65 6e 74 73 2e 0a  0a 59 6f 75 20 63 61 6e  |cients...You can|
00000630  20 73 75 62 73 74 69 74  75 74 65 20 61 20 64 69  | substitute a di|
00000640  66 66 65 72 65 6e 74 20  73 65 74 20 6f 66 20 71  |fferent set of q|
00000650  75 61 6e 74 69 7a 61 74  69 6f 6e 20 76 61 6c 75  |uantization valu|
00000660  65 73 20 62 79 20 75 73  69 6e 67 20 74 68 65 0a  |es by using the.|
00000670  2d 71 74 61 62 6c 65 73  20 73 77 69 74 63 68 3a  |-qtables switch:|
00000680  0a 0a 09 2d 71 74 61 62  6c 65 73 20 66 69 6c 65  |...-qtables file|
00000690  09 55 73 65 20 74 68 65  20 71 75 61 6e 74 69 7a  |.Use the quantiz|
000006a0  61 74 69 6f 6e 20 74 61  62 6c 65 73 20 67 69 76  |ation tables giv|
000006b0  65 6e 20 69 6e 20 74 68  65 20 6e 61 6d 65 64 20  |en in the named |
000006c0  66 69 6c 65 2e 0a 0a 54  68 65 20 73 70 65 63 69  |file...The speci|
000006d0  66 69 65 64 20 66 69 6c  65 20 73 68 6f 75 6c 64  |fied file should|
000006e0  20 62 65 20 61 20 74 65  78 74 20 66 69 6c 65 20  | be a text file |
000006f0  63 6f 6e 74 61 69 6e 69  6e 67 20 64 65 63 69 6d  |containing decim|
00000700  61 6c 20 71 75 61 6e 74  69 7a 61 74 69 6f 6e 0a  |al quantization.|
00000710  76 61 6c 75 65 73 2e 20  20 54 68 65 20 66 69 6c  |values.  The fil|
00000720  65 20 73 68 6f 75 6c 64  20 63 6f 6e 74 61 69 6e  |e should contain|
00000730  20 6f 6e 65 20 74 6f 20  66 6f 75 72 20 74 61 62  | one to four tab|
00000740  6c 65 73 2c 20 65 61 63  68 20 6f 66 20 36 34 20  |les, each of 64 |
00000750  65 6c 65 6d 65 6e 74 73  2e 0a 54 68 65 20 74 61  |elements..The ta|
00000760  62 6c 65 73 20 61 72 65  20 69 6d 70 6c 69 63 69  |bles are implici|
00000770  74 6c 79 20 6e 75 6d 62  65 72 65 64 20 30 2c 31  |tly numbered 0,1|
00000780  2c 65 74 63 2e 20 69 6e  20 6f 72 64 65 72 20 6f  |,etc. in order o|
00000790  66 20 61 70 70 65 61 72  61 6e 63 65 2e 20 20 54  |f appearance.  T|
000007a0  61 62 6c 65 0a 65 6e 74  72 69 65 73 20 61 70 70  |able.entries app|
000007b0  65 61 72 20 69 6e 20 6e  6f 72 6d 61 6c 20 61 72  |ear in normal ar|
000007c0  72 61 79 20 6f 72 64 65  72 20 28 4e 4f 54 20 69  |ray order (NOT i|
000007d0  6e 20 74 68 65 20 7a 69  67 7a 61 67 20 6f 72 64  |n the zigzag ord|
000007e0  65 72 20 69 6e 20 77 68  69 63 68 20 74 68 65 79  |er in which they|
000007f0  0a 77 69 6c 6c 20 62 65  20 73 74 6f 72 65 64 20  |.will be stored |
00000800  69 6e 20 74 68 65 20 4a  50 45 47 20 66 69 6c 65  |in the JPEG file|
00000810  29 2e 0a 0a 51 75 61 6e  74 69 7a 61 74 69 6f 6e  |)...Quantization|
00000820  20 74 61 62 6c 65 20 66  69 6c 65 73 20 61 72 65  | table files are|
00000830  20 66 72 65 65 20 66 6f  72 6d 61 74 2c 20 69 6e  | free format, in|
00000840  20 74 68 61 74 20 61 72  62 69 74 72 61 72 79 20  | that arbitrary |
00000850  77 68 69 74 65 73 70 61  63 65 20 63 61 6e 0a 61  |whitespace can.a|
00000860  70 70 65 61 72 20 62 65  74 77 65 65 6e 20 6e 75  |ppear between nu|
00000870  6d 62 65 72 73 2e 20 20  41 6c 73 6f 2c 20 63 6f  |mbers.  Also, co|
00000880  6d 6d 65 6e 74 73 20 63  61 6e 20 62 65 20 69 6e  |mments can be in|
00000890  63 6c 75 64 65 64 3a 20  61 20 63 6f 6d 6d 65 6e  |cluded: a commen|
000008a0  74 20 73 74 61 72 74 73  0a 77 69 74 68 20 27 23  |t starts.with '#|
000008b0  27 20 61 6e 64 20 65 78  74 65 6e 64 73 20 74 6f  |' and extends to|
000008c0  20 74 68 65 20 65 6e 64  20 6f 66 20 74 68 65 20  | the end of the |
000008d0  6c 69 6e 65 2e 20 20 48  65 72 65 20 69 73 20 61  |line.  Here is a|
000008e0  6e 20 65 78 61 6d 70 6c  65 20 66 69 6c 65 20 74  |n example file t|
000008f0  68 61 74 0a 64 75 70 6c  69 63 61 74 65 73 20 74  |hat.duplicates t|
00000900  68 65 20 64 65 66 61 75  6c 74 20 71 75 61 6e 74  |he default quant|
00000910  69 7a 61 74 69 6f 6e 20  74 61 62 6c 65 73 3a 0a  |ization tables:.|
00000920  0a 09 23 20 51 75 61 6e  74 69 7a 61 74 69 6f 6e  |..# Quantization|
00000930  20 74 61 62 6c 65 73 20  67 69 76 65 6e 20 69 6e  | tables given in|
00000940  20 4a 50 45 47 20 73 70  65 63 2c 20 73 65 63 74  | JPEG spec, sect|
00000950  69 6f 6e 20 4b 2e 31 0a  0a 09 23 20 54 68 69 73  |ion K.1...# This|
00000960  20 69 73 20 74 61 62 6c  65 20 30 20 28 74 68 65  | is table 0 (the|
00000970  20 6c 75 6d 69 6e 61 6e  63 65 20 74 61 62 6c 65  | luminance table|
00000980  29 3a 0a 09 20 20 31 36  20 20 31 31 20 20 31 30  |):..  16  11  10|
00000990  20 20 31 36 20 20 32 34  20 20 34 30 20 20 35 31  |  16  24  40  51|
000009a0  20 20 36 31 0a 09 20 20  31 32 20 20 31 32 20 20  |  61..  12  12  |
000009b0  31 34 20 20 31 39 20 20  32 36 20 20 35 38 20 20  |14  19  26  58  |
000009c0  36 30 20 20 35 35 0a 09  20 20 31 34 20 20 31 33  |60  55..  14  13|
000009d0  20 20 31 36 20 20 32 34  20 20 34 30 20 20 35 37  |  16  24  40  57|
000009e0  20 20 36 39 20 20 35 36  0a 09 20 20 31 34 20 20  |  69  56..  14  |
000009f0  31 37 20 20 32 32 20 20  32 39 20 20 35 31 20 20  |17  22  29  51  |
00000a00  38 37 20 20 38 30 20 20  36 32 0a 09 20 20 31 38  |87  80  62..  18|
00000a10  20 20 32 32 20 20 33 37  20 20 35 36 20 20 36 38  |  22  37  56  68|
00000a20  20 31 30 39 20 31 30 33  20 20 37 37 0a 09 20 20  | 109 103  77..  |
00000a30  32 34 20 20 33 35 20 20  35 35 20 20 36 34 20 20  |24  35  55  64  |
00000a40  38 31 20 31 30 34 20 31  31 33 20 20 39 32 0a 09  |81 104 113  92..|
00000a50  20 20 34 39 20 20 36 34  20 20 37 38 20 20 38 37  |  49  64  78  87|
00000a60  20 31 30 33 20 31 32 31  20 31 32 30 20 31 30 31  | 103 121 120 101|
00000a70  0a 09 20 20 37 32 20 20  39 32 20 20 39 35 20 20  |..  72  92  95  |
00000a80  39 38 20 31 31 32 20 31  30 30 20 31 30 33 20 20  |98 112 100 103  |
00000a90  39 39 0a 0a 09 23 20 54  68 69 73 20 69 73 20 74  |99...# This is t|
00000aa0  61 62 6c 65 20 31 20 28  74 68 65 20 63 68 72 6f  |able 1 (the chro|
00000ab0  6d 69 6e 61 6e 63 65 20  74 61 62 6c 65 29 3a 0a  |minance table):.|
00000ac0  09 20 20 31 37 20 20 31  38 20 20 32 34 20 20 34  |.  17  18  24  4|
00000ad0  37 20 20 39 39 20 20 39  39 20 20 39 39 20 20 39  |7  99  99  99  9|
00000ae0  39 0a 09 20 20 31 38 20  20 32 31 20 20 32 36 20  |9..  18  21  26 |
00000af0  20 36 36 20 20 39 39 20  20 39 39 20 20 39 39 20  | 66  99  99  99 |
00000b00  20 39 39 0a 09 20 20 32  34 20 20 32 36 20 20 35  | 99..  24  26  5|
00000b10  36 20 20 39 39 20 20 39  39 20 20 39 39 20 20 39  |6  99  99  99  9|
00000b20  39 20 20 39 39 0a 09 20  20 34 37 20 20 36 36 20  |9  99..  47  66 |
00000b30  20 39 39 20 20 39 39 20  20 39 39 20 20 39 39 20  | 99  99  99  99 |
00000b40  20 39 39 20 20 39 39 0a  09 20 20 39 39 20 20 39  | 99  99..  99  9|
00000b50  39 20 20 39 39 20 20 39  39 20 20 39 39 20 20 39  |9  99  99  99  9|
00000b60  39 20 20 39 39 20 20 39  39 0a 09 20 20 39 39 20  |9  99  99..  99 |
00000b70  20 39 39 20 20 39 39 20  20 39 39 20 20 39 39 20  | 99  99  99  99 |
00000b80  20 39 39 20 20 39 39 20  20 39 39 0a 09 20 20 39  | 99  99  99..  9|
00000b90  39 20 20 39 39 20 20 39  39 20 20 39 39 20 20 39  |9  99  99  99  9|
00000ba0  39 20 20 39 39 20 20 39  39 20 20 39 39 0a 09 20  |9  99  99  99.. |
00000bb0  20 39 39 20 20 39 39 20  20 39 39 20 20 39 39 20  | 99  99  99  99 |
00000bc0  20 39 39 20 20 39 39 20  20 39 39 20 20 39 39 0a  | 99  99  99  99.|
00000bd0  0a 49 66 20 74 68 65 20  2d 71 74 61 62 6c 65 73  |.If the -qtables|
00000be0  20 73 77 69 74 63 68 20  69 73 20 75 73 65 64 20  | switch is used |
00000bf0  77 69 74 68 6f 75 74 20  2d 71 75 61 6c 69 74 79  |without -quality|
00000c00  2c 20 74 68 65 6e 20 74  68 65 20 73 70 65 63 69  |, then the speci|
00000c10  66 69 65 64 20 74 61 62  6c 65 73 0a 61 72 65 20  |fied tables.are |
00000c20  75 73 65 64 20 65 78 61  63 74 6c 79 20 61 73 2d  |used exactly as-|
00000c30  69 73 2e 20 20 49 66 20  62 6f 74 68 20 2d 71 74  |is.  If both -qt|
00000c40  61 62 6c 65 73 20 61 6e  64 20 2d 71 75 61 6c 69  |ables and -quali|
00000c50  74 79 20 61 72 65 20 75  73 65 64 2c 20 74 68 65  |ty are used, the|
00000c60  6e 20 74 68 65 0a 74 61  62 6c 65 73 20 74 61 6b  |n the.tables tak|
00000c70  65 6e 20 66 72 6f 6d 20  74 68 65 20 66 69 6c 65  |en from the file|
00000c80  20 61 72 65 20 73 63 61  6c 65 64 20 69 6e 20 74  | are scaled in t|
00000c90  68 65 20 73 61 6d 65 20  66 61 73 68 69 6f 6e 20  |he same fashion |
00000ca0  74 68 61 74 20 74 68 65  20 64 65 66 61 75 6c 74  |that the default|
00000cb0  0a 74 61 62 6c 65 73 20  77 6f 75 6c 64 20 62 65  |.tables would be|
00000cc0  20 73 63 61 6c 65 64 20  66 6f 72 20 74 68 61 74  | scaled for that|
00000cd0  20 71 75 61 6c 69 74 79  20 73 65 74 74 69 6e 67  | quality setting|
00000ce0  2e 20 20 49 66 20 2d 62  61 73 65 6c 69 6e 65 20  |.  If -baseline |
00000cf0  61 70 70 65 61 72 73 2c  20 74 68 65 6e 0a 74 68  |appears, then.th|
00000d00  65 20 71 75 61 6e 74 69  7a 61 74 69 6f 6e 20 76  |e quantization v|
00000d10  61 6c 75 65 73 20 61 72  65 20 63 6f 6e 73 74 72  |alues are constr|
00000d20  61 69 6e 65 64 20 74 6f  20 74 68 65 20 72 61 6e  |ained to the ran|
00000d30  67 65 20 31 2d 32 35 35  2e 0a 0a 42 79 20 64 65  |ge 1-255...By de|
00000d40  66 61 75 6c 74 2c 20 63  6a 70 65 67 20 77 69 6c  |fault, cjpeg wil|
00000d50  6c 20 75 73 65 20 71 75  61 6e 74 69 7a 61 74 69  |l use quantizati|
00000d60  6f 6e 20 74 61 62 6c 65  20 30 20 66 6f 72 20 6c  |on table 0 for l|
00000d70  75 6d 69 6e 61 6e 63 65  20 63 6f 6d 70 6f 6e 65  |uminance compone|
00000d80  6e 74 73 20 61 6e 64 0a  74 61 62 6c 65 20 31 20  |nts and.table 1 |
00000d90  66 6f 72 20 63 68 72 6f  6d 69 6e 61 6e 63 65 20  |for chrominance |
00000da0  63 6f 6d 70 6f 6e 65 6e  74 73 2e 20 20 54 6f 20  |components.  To |
00000db0  6f 76 65 72 72 69 64 65  20 74 68 69 73 20 63 68  |override this ch|
00000dc0  6f 69 63 65 2c 20 75 73  65 20 74 68 65 20 2d 71  |oice, use the -q|
00000dd0  73 6c 6f 74 73 0a 73 77  69 74 63 68 3a 0a 0a 09  |slots.switch:...|
00000de0  2d 71 73 6c 6f 74 73 20  4e 5b 2c 2e 2e 2e 5d 09  |-qslots N[,...].|
00000df0  09 53 65 6c 65 63 74 20  77 68 69 63 68 20 71 75  |.Select which qu|
00000e00  61 6e 74 69 7a 61 74 69  6f 6e 20 74 61 62 6c 65  |antization table|
00000e10  20 74 6f 20 75 73 65 20  66 6f 72 0a 09 09 09 09  | to use for.....|
00000e20  65 61 63 68 20 63 6f 6c  6f 72 20 63 6f 6d 70 6f  |each color compo|
00000e30  6e 65 6e 74 2e 0a 0a 54  68 65 20 2d 71 73 6c 6f  |nent...The -qslo|
00000e40  74 73 20 73 77 69 74 63  68 20 73 70 65 63 69 66  |ts switch specif|
00000e50  69 65 73 20 61 20 71 75  61 6e 74 69 7a 61 74 69  |ies a quantizati|
00000e60  6f 6e 20 74 61 62 6c 65  20 6e 75 6d 62 65 72 20  |on table number |
00000e70  66 6f 72 20 65 61 63 68  20 63 6f 6c 6f 72 0a 63  |for each color.c|
00000e80  6f 6d 70 6f 6e 65 6e 74  2c 20 69 6e 20 74 68 65  |omponent, in the|
00000e90  20 6f 72 64 65 72 20 69  6e 20 77 68 69 63 68 20  | order in which |
00000ea0  74 68 65 20 63 6f 6d 70  6f 6e 65 6e 74 73 20 61  |the components a|
00000eb0  70 70 65 61 72 20 69 6e  20 74 68 65 20 4a 50 45  |ppear in the JPE|
00000ec0  47 20 53 4f 46 20 6d 61  72 6b 65 72 2e 0a 46 6f  |G SOF marker..Fo|
00000ed0  72 20 65 78 61 6d 70 6c  65 2c 20 74 6f 20 63 72  |r example, to cr|
00000ee0  65 61 74 65 20 61 20 73  65 70 61 72 61 74 65 20  |eate a separate |
00000ef0  74 61 62 6c 65 20 66 6f  72 20 65 61 63 68 20 6f  |table for each o|
00000f00  66 20 59 2c 43 62 2c 43  72 2c 20 79 6f 75 20 63  |f Y,Cb,Cr, you c|
00000f10  6f 75 6c 64 0a 70 72 6f  76 69 64 65 20 61 20 2d  |ould.provide a -|
00000f20  71 74 61 62 6c 65 73 20  66 69 6c 65 20 74 68 61  |qtables file tha|
00000f30  74 20 64 65 66 69 6e 65  73 20 74 68 72 65 65 20  |t defines three |
00000f40  71 75 61 6e 74 69 7a 61  74 69 6f 6e 20 74 61 62  |quantization tab|
00000f50  6c 65 73 20 61 6e 64 20  73 61 79 0a 22 2d 71 73  |les and say."-qs|
00000f60  6c 6f 74 73 20 30 2c 31  2c 32 22 2e 20 20 49 66  |lots 0,1,2".  If|
00000f70  20 2d 71 73 6c 6f 74 73  20 67 69 76 65 73 20 66  | -qslots gives f|
00000f80  65 77 65 72 20 74 61 62  6c 65 20 6e 75 6d 62 65  |ewer table numbe|
00000f90  72 73 20 74 68 61 6e 20  74 68 65 72 65 20 61 72  |rs than there ar|
00000fa0  65 20 63 6f 6c 6f 72 0a  63 6f 6d 70 6f 6e 65 6e  |e color.componen|
00000fb0  74 73 2c 20 74 68 65 6e  20 74 68 65 20 6c 61 73  |ts, then the las|
00000fc0  74 20 74 61 62 6c 65 20  6e 75 6d 62 65 72 20 69  |t table number i|
00000fd0  73 20 72 65 70 65 61 74  65 64 20 61 73 20 6e 65  |s repeated as ne|
00000fe0  63 65 73 73 61 72 79 2e  0a 0a 0a 53 61 6d 70 6c  |cessary....Sampl|
00000ff0  69 6e 67 20 46 61 63 74  6f 72 20 41 64 6a 75 73  |ing Factor Adjus|
00001000  74 6d 65 6e 74 0a 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |tment.----------|
00001010  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00001020  0a 0a 42 79 20 64 65 66  61 75 6c 74 2c 20 63 6a  |..By default, cj|
00001030  70 65 67 20 75 73 65 73  20 32 3a 31 20 68 6f 72  |peg uses 2:1 hor|
00001040  69 7a 6f 6e 74 61 6c 20  61 6e 64 20 76 65 72 74  |izontal and vert|
00001050  69 63 61 6c 20 64 6f 77  6e 73 61 6d 70 6c 69 6e  |ical downsamplin|
00001060  67 20 77 68 65 6e 0a 63  6f 6d 70 72 65 73 73 69  |g when.compressi|
00001070  6e 67 20 59 43 62 43 72  20 64 61 74 61 2c 20 61  |ng YCbCr data, a|
00001080  6e 64 20 6e 6f 20 64 6f  77 6e 73 61 6d 70 6c 69  |nd no downsampli|
00001090  6e 67 20 66 6f 72 20 61  6c 6c 20 6f 74 68 65 72  |ng for all other|
000010a0  20 63 6f 6c 6f 72 20 73  70 61 63 65 73 2e 0a 59  | color spaces..Y|
000010b0  6f 75 20 63 61 6e 20 6f  76 65 72 72 69 64 65 20  |ou can override |
000010c0  74 68 69 73 20 64 65 66  61 75 6c 74 20 77 69 74  |this default wit|
000010d0  68 20 74 68 65 20 2d 73  61 6d 70 6c 65 20 73 77  |h the -sample sw|
000010e0  69 74 63 68 3a 0a 0a 09  2d 73 61 6d 70 6c 65 20  |itch:...-sample |
000010f0  48 78 56 5b 2c 2e 2e 2e  5d 09 53 65 74 20 4a 50  |HxV[,...].Set JP|
00001100  45 47 20 73 61 6d 70 6c  69 6e 67 20 66 61 63 74  |EG sampling fact|
00001110  6f 72 73 20 66 6f 72 20  65 61 63 68 20 63 6f 6c  |ors for each col|
00001120  6f 72 0a 09 09 09 09 63  6f 6d 70 6f 6e 65 6e 74  |or.....component|
00001130  2e 0a 0a 54 68 65 20 2d  73 61 6d 70 6c 65 20 73  |...The -sample s|
00001140  77 69 74 63 68 20 73 70  65 63 69 66 69 65 73 20  |witch specifies |
00001150  74 68 65 20 4a 50 45 47  20 73 61 6d 70 6c 69 6e  |the JPEG samplin|
00001160  67 20 66 61 63 74 6f 72  73 20 66 6f 72 20 65 61  |g factors for ea|
00001170  63 68 20 63 6f 6c 6f 72  0a 63 6f 6d 70 6f 6e 65  |ch color.compone|
00001180  6e 74 2c 20 69 6e 20 74  68 65 20 6f 72 64 65 72  |nt, in the order|
00001190  20 69 6e 20 77 68 69 63  68 20 74 68 65 79 20 61  | in which they a|
000011a0  70 70 65 61 72 20 69 6e  20 74 68 65 20 4a 50 45  |ppear in the JPE|
000011b0  47 20 53 4f 46 20 6d 61  72 6b 65 72 2e 0a 49 66  |G SOF marker..If|
000011c0  20 79 6f 75 20 73 70 65  63 69 66 79 20 66 65 77  | you specify few|
000011d0  65 72 20 48 78 56 20 70  61 69 72 73 20 74 68 61  |er HxV pairs tha|
000011e0  6e 20 74 68 65 72 65 20  61 72 65 20 63 6f 6d 70  |n there are comp|
000011f0  6f 6e 65 6e 74 73 2c 20  74 68 65 20 72 65 6d 61  |onents, the rema|
00001200  69 6e 69 6e 67 0a 63 6f  6d 70 6f 6e 65 6e 74 73  |ining.components|
00001210  20 61 72 65 20 73 65 74  20 74 6f 20 31 78 31 20  | are set to 1x1 |
00001220  73 61 6d 70 6c 69 6e 67  2e 20 20 46 6f 72 20 65  |sampling.  For e|
00001230  78 61 6d 70 6c 65 2c 20  74 68 65 20 64 65 66 61  |xample, the defa|
00001240  75 6c 74 20 59 43 62 43  72 20 73 65 74 74 69 6e  |ult YCbCr settin|
00001250  67 0a 69 73 20 65 71 75  69 76 61 6c 65 6e 74 20  |g.is equivalent |
00001260  74 6f 20 22 2d 73 61 6d  70 6c 65 20 32 78 32 2c  |to "-sample 2x2,|
00001270  31 78 31 2c 31 78 31 22  2c 20 77 68 69 63 68 20  |1x1,1x1", which |
00001280  63 61 6e 20 62 65 20 61  62 62 72 65 76 69 61 74  |can be abbreviat|
00001290  65 64 20 74 6f 0a 22 2d  73 61 6d 70 6c 65 20 32  |ed to."-sample 2|
000012a0  78 32 22 2e 0a 0a 54 68  65 72 65 20 61 72 65 20  |x2"...There are |
000012b0  73 74 69 6c 6c 20 73 6f  6d 65 20 4a 50 45 47 20  |still some JPEG |
000012c0  64 65 63 6f 64 65 72 73  20 69 6e 20 65 78 69 73  |decoders in exis|
000012d0  74 65 6e 63 65 20 74 68  61 74 20 73 75 70 70 6f  |tence that suppo|
000012e0  72 74 20 6f 6e 6c 79 20  32 78 31 0a 73 61 6d 70  |rt only 2x1.samp|
000012f0  6c 69 6e 67 20 28 61 6c  73 6f 20 63 61 6c 6c 65  |ling (also calle|
00001300  64 20 34 3a 32 3a 32 20  73 61 6d 70 6c 69 6e 67  |d 4:2:2 sampling|
00001310  29 2e 20 20 43 6f 6d 70  61 74 69 62 69 6c 69 74  |).  Compatibilit|
00001320  79 20 77 69 74 68 20 73  75 63 68 20 64 65 63 6f  |y with such deco|
00001330  64 65 72 73 20 63 61 6e  0a 62 65 20 61 63 68 69  |ders can.be achi|
00001340  65 76 65 64 20 62 79 20  73 70 65 63 69 66 79 69  |eved by specifyi|
00001350  6e 67 20 22 2d 73 61 6d  70 6c 65 20 32 78 31 22  |ng "-sample 2x1"|
00001360  2e 20 20 54 68 69 73 20  69 73 20 6e 6f 74 20 72  |.  This is not r|
00001370  65 63 6f 6d 6d 65 6e 64  65 64 20 75 6e 6c 65 73  |ecommended unles|
00001380  73 0a 72 65 61 6c 6c 79  20 6e 65 63 65 73 73 61  |s.really necessa|
00001390  72 79 2c 20 73 69 6e 63  65 20 69 74 20 69 6e 63  |ry, since it inc|
000013a0  72 65 61 73 65 73 20 66  69 6c 65 20 73 69 7a 65  |reases file size|
000013b0  20 61 6e 64 20 65 6e 63  6f 64 69 6e 67 2f 64 65  | and encoding/de|
000013c0  63 6f 64 69 6e 67 20 74  69 6d 65 0a 77 69 74 68  |coding time.with|
000013d0  20 76 65 72 79 20 6c 69  74 74 6c 65 20 71 75 61  | very little qua|
000013e0  6c 69 74 79 20 67 61 69  6e 2e 0a 0a 0a 4d 75 6c  |lity gain....Mul|
000013f0  74 69 70 6c 65 20 53 63  61 6e 20 2f 20 50 72 6f  |tiple Scan / Pro|
00001400  67 72 65 73 73 69 6f 6e  20 43 6f 6e 74 72 6f 6c  |gression Control|
00001410  0a 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |.---------------|
00001420  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00001430  2d 2d 2d 2d 0a 0a 42 79  20 64 65 66 61 75 6c 74  |----..By default|
00001440  2c 20 63 6a 70 65 67 20  65 6d 69 74 73 20 61 20  |, cjpeg emits a |
00001450  73 69 6e 67 6c 65 2d 73  63 61 6e 20 73 65 71 75  |single-scan sequ|
00001460  65 6e 74 69 61 6c 20 4a  50 45 47 20 66 69 6c 65  |ential JPEG file|
00001470  2e 20 20 54 68 65 0a 2d  70 72 6f 67 72 65 73 73  |.  The.-progress|
00001480  69 76 65 20 73 77 69 74  63 68 20 67 65 6e 65 72  |ive switch gener|
00001490  61 74 65 73 20 61 20 70  72 6f 67 72 65 73 73 69  |ates a progressi|
000014a0  76 65 20 4a 50 45 47 20  66 69 6c 65 20 75 73 69  |ve JPEG file usi|
000014b0  6e 67 20 61 20 64 65 66  61 75 6c 74 20 73 65 72  |ng a default ser|
000014c0  69 65 73 0a 6f 66 20 70  72 6f 67 72 65 73 73 69  |ies.of progressi|
000014d0  6f 6e 20 70 61 72 61 6d  65 74 65 72 73 2e 20 20  |on parameters.  |
000014e0  59 6f 75 20 63 61 6e 20  63 72 65 61 74 65 20 6d  |You can create m|
000014f0  75 6c 74 69 70 6c 65 2d  73 63 61 6e 20 73 65 71  |ultiple-scan seq|
00001500  75 65 6e 74 69 61 6c 20  4a 50 45 47 0a 66 69 6c  |uential JPEG.fil|
00001510  65 73 20 6f 72 20 70 72  6f 67 72 65 73 73 69 76  |es or progressiv|
00001520  65 20 4a 50 45 47 20 66  69 6c 65 73 20 77 69 74  |e JPEG files wit|
00001530  68 20 63 75 73 74 6f 6d  20 70 72 6f 67 72 65 73  |h custom progres|
00001540  73 69 6f 6e 20 70 61 72  61 6d 65 74 65 72 73 20  |sion parameters |
00001550  62 79 20 75 73 69 6e 67  0a 74 68 65 20 2d 73 63  |by using.the -sc|
00001560  61 6e 73 20 73 77 69 74  63 68 3a 0a 0a 09 2d 73  |ans switch:...-s|
00001570  63 61 6e 73 20 66 69 6c  65 09 55 73 65 20 74 68  |cans file.Use th|
00001580  65 20 73 63 61 6e 20 73  65 71 75 65 6e 63 65 20  |e scan sequence |
00001590  67 69 76 65 6e 20 69 6e  20 74 68 65 20 6e 61 6d  |given in the nam|
000015a0  65 64 20 66 69 6c 65 2e  0a 0a 54 68 65 20 73 70  |ed file...The sp|
000015b0  65 63 69 66 69 65 64 20  66 69 6c 65 20 73 68 6f  |ecified file sho|
000015c0  75 6c 64 20 62 65 20 61  20 74 65 78 74 20 66 69  |uld be a text fi|
000015d0  6c 65 20 63 6f 6e 74 61  69 6e 69 6e 67 20 61 20  |le containing a |
000015e0  22 73 63 61 6e 20 73 63  72 69 70 74 22 2e 0a 54  |"scan script"..T|
000015f0  68 65 20 73 63 72 69 70  74 20 73 70 65 63 69 66  |he script specif|
00001600  69 65 73 20 74 68 65 20  63 6f 6e 74 65 6e 74 73  |ies the contents|
00001610  20 61 6e 64 20 6f 72 64  65 72 69 6e 67 20 6f 66  | and ordering of|
00001620  20 74 68 65 20 73 63 61  6e 73 20 74 6f 20 62 65  | the scans to be|
00001630  20 65 6d 69 74 74 65 64  2e 0a 45 61 63 68 20 65  | emitted..Each e|
00001640  6e 74 72 79 20 69 6e 20  74 68 65 20 73 63 72 69  |ntry in the scri|
00001650  70 74 20 64 65 66 69 6e  65 73 20 6f 6e 65 20 73  |pt defines one s|
00001660  63 61 6e 2e 20 20 41 20  73 63 61 6e 20 64 65 66  |can.  A scan def|
00001670  69 6e 69 74 69 6f 6e 20  73 70 65 63 69 66 69 65  |inition specifie|
00001680  73 0a 74 68 65 20 63 6f  6d 70 6f 6e 65 6e 74 73  |s.the components|
00001690  20 74 6f 20 62 65 20 69  6e 63 6c 75 64 65 64 20  | to be included |
000016a0  69 6e 20 74 68 65 20 73  63 61 6e 2c 20 61 6e 64  |in the scan, and|
000016b0  20 66 6f 72 20 70 72 6f  67 72 65 73 73 69 76 65  | for progressive|
000016c0  20 4a 50 45 47 20 69 74  20 61 6c 73 6f 0a 73 70  | JPEG it also.sp|
000016d0  65 63 69 66 69 65 73 20  74 68 65 20 70 72 6f 67  |ecifies the prog|
000016e0  72 65 73 73 69 6f 6e 20  70 61 72 61 6d 65 74 65  |ression paramete|
000016f0  72 73 20 53 73 2c 53 65  2c 41 68 2c 41 6c 20 66  |rs Ss,Se,Ah,Al f|
00001700  6f 72 20 74 68 65 20 73  63 61 6e 2e 20 20 53 63  |or the scan.  Sc|
00001710  61 6e 0a 64 65 66 69 6e  69 74 69 6f 6e 73 20 61  |an.definitions a|
00001720  72 65 20 73 65 70 61 72  61 74 65 64 20 62 79 20  |re separated by |
00001730  73 65 6d 69 63 6f 6c 6f  6e 73 20 28 27 3b 27 29  |semicolons (';')|
00001740  2e 20 20 41 20 73 65 6d  69 63 6f 6c 6f 6e 20 61  |.  A semicolon a|
00001750  66 74 65 72 20 74 68 65  20 6c 61 73 74 0a 73 63  |fter the last.sc|
00001760  61 6e 20 64 65 66 69 6e  69 74 69 6f 6e 20 69 73  |an definition is|
00001770  20 6f 70 74 69 6f 6e 61  6c 2e 0a 0a 45 61 63 68  | optional...Each|
00001780  20 73 63 61 6e 20 64 65  66 69 6e 69 74 69 6f 6e  | scan definition|
00001790  20 63 6f 6e 74 61 69 6e  73 20 6f 6e 65 20 74 6f  | contains one to|
000017a0  20 66 6f 75 72 20 63 6f  6d 70 6f 6e 65 6e 74 20  | four component |
000017b0  69 6e 64 65 78 65 73 2c  20 6f 70 74 69 6f 6e 61  |indexes, optiona|
000017c0  6c 6c 79 0a 66 6f 6c 6c  6f 77 65 64 20 62 79 20  |lly.followed by |
000017d0  61 20 63 6f 6c 6f 6e 20  28 27 3a 27 29 20 61 6e  |a colon (':') an|
000017e0  64 20 74 68 65 20 66 6f  75 72 20 70 72 6f 67 72  |d the four progr|
000017f0  65 73 73 69 76 65 2d 4a  50 45 47 20 70 61 72 61  |essive-JPEG para|
00001800  6d 65 74 65 72 73 2e 20  20 54 68 65 0a 63 6f 6d  |meters.  The.com|
00001810  70 6f 6e 65 6e 74 20 69  6e 64 65 78 65 73 20 64  |ponent indexes d|
00001820  65 6e 6f 74 65 20 77 68  69 63 68 20 63 6f 6c 6f  |enote which colo|
00001830  72 20 63 6f 6d 70 6f 6e  65 6e 74 28 73 29 20 61  |r component(s) a|
00001840  72 65 20 74 6f 20 62 65  20 74 72 61 6e 73 6d 69  |re to be transmi|
00001850  74 74 65 64 20 69 6e 0a  74 68 65 20 73 63 61 6e  |tted in.the scan|
00001860  2e 20 20 43 6f 6d 70 6f  6e 65 6e 74 73 20 61 72  |.  Components ar|
00001870  65 20 6e 75 6d 62 65 72  65 64 20 69 6e 20 74 68  |e numbered in th|
00001880  65 20 6f 72 64 65 72 20  69 6e 20 77 68 69 63 68  |e order in which|
00001890  20 74 68 65 79 20 61 70  70 65 61 72 20 69 6e 20  | they appear in |
000018a0  74 68 65 0a 4a 50 45 47  20 53 4f 46 20 6d 61 72  |the.JPEG SOF mar|
000018b0  6b 65 72 2c 20 77 69 74  68 20 74 68 65 20 66 69  |ker, with the fi|
000018c0  72 73 74 20 63 6f 6d 70  6f 6e 65 6e 74 20 62 65  |rst component be|
000018d0  69 6e 67 20 6e 75 6d 62  65 72 65 64 20 30 2e 20  |ing numbered 0. |
000018e0  20 28 4e 6f 74 65 20 74  68 61 74 20 74 68 65 73  | (Note that thes|
000018f0  65 0a 69 6e 64 65 78 65  73 20 61 72 65 20 6e 6f  |e.indexes are no|
00001900  74 20 74 68 65 20 22 63  6f 6d 70 6f 6e 65 6e 74  |t the "component|
00001910  20 49 44 22 20 63 6f 64  65 73 20 61 73 73 69 67  | ID" codes assig|
00001920  6e 65 64 20 74 6f 20 74  68 65 20 63 6f 6d 70 6f  |ned to the compo|
00001930  6e 65 6e 74 73 2c 20 6a  75 73 74 0a 70 6f 73 69  |nents, just.posi|
00001940  74 69 6f 6e 61 6c 20 69  6e 64 65 78 65 73 2e 29  |tional indexes.)|
00001950  0a 0a 54 68 65 20 70 72  6f 67 72 65 73 73 69 6f  |..The progressio|
00001960  6e 20 70 61 72 61 6d 65  74 65 72 73 20 66 6f 72  |n parameters for|
00001970  20 65 61 63 68 20 73 63  61 6e 20 61 72 65 3a 0a  | each scan are:.|
00001980  09 53 73 09 5a 69 67 7a  61 67 20 69 6e 64 65 78  |.Ss.Zigzag index|
00001990  20 6f 66 20 66 69 72 73  74 20 63 6f 65 66 66 69  | of first coeffi|
000019a0  63 69 65 6e 74 20 69 6e  63 6c 75 64 65 64 20 69  |cient included i|
000019b0  6e 20 73 63 61 6e 0a 09  53 65 09 5a 69 67 7a 61  |n scan..Se.Zigza|
000019c0  67 20 69 6e 64 65 78 20  6f 66 20 6c 61 73 74 20  |g index of last |
000019d0  63 6f 65 66 66 69 63 69  65 6e 74 20 69 6e 63 6c  |coefficient incl|
000019e0  75 64 65 64 20 69 6e 20  73 63 61 6e 0a 09 41 68  |uded in scan..Ah|
000019f0  09 5a 65 72 6f 20 66 6f  72 20 66 69 72 73 74 20  |.Zero for first |
00001a00  73 63 61 6e 20 6f 66 20  61 20 63 6f 65 66 66 69  |scan of a coeffi|
00001a10  63 69 65 6e 74 2c 20 65  6c 73 65 20 41 6c 20 6f  |cient, else Al o|
00001a20  66 20 70 72 69 6f 72 20  73 63 61 6e 0a 09 41 6c  |f prior scan..Al|
00001a30  09 53 75 63 63 65 73 73  69 76 65 20 61 70 70 72  |.Successive appr|
00001a40  6f 78 69 6d 61 74 69 6f  6e 20 6c 6f 77 20 62 69  |oximation low bi|
00001a50  74 20 70 6f 73 69 74 69  6f 6e 20 66 6f 72 20 73  |t position for s|
00001a60  63 61 6e 0a 49 66 20 74  68 65 20 70 72 6f 67 72  |can.If the progr|
00001a70  65 73 73 69 6f 6e 20 70  61 72 61 6d 65 74 65 72  |ession parameter|
00001a80  73 20 61 72 65 20 6f 6d  69 74 74 65 64 2c 20 74  |s are omitted, t|
00001a90  68 65 20 76 61 6c 75 65  73 20 30 2c 36 33 2c 30  |he values 0,63,0|
00001aa0  2c 30 20 61 72 65 20 75  73 65 64 2c 0a 70 72 6f  |,0 are used,.pro|
00001ab0  64 75 63 69 6e 67 20 61  20 73 65 71 75 65 6e 74  |ducing a sequent|
00001ac0  69 61 6c 20 4a 50 45 47  20 66 69 6c 65 2e 20 20  |ial JPEG file.  |
00001ad0  63 6a 70 65 67 20 61 75  74 6f 6d 61 74 69 63 61  |cjpeg automatica|
00001ae0  6c 6c 79 20 64 65 74 65  72 6d 69 6e 65 73 20 77  |lly determines w|
00001af0  68 65 74 68 65 72 0a 74  68 65 20 73 63 72 69 70  |hether.the scrip|
00001b00  74 20 72 65 70 72 65 73  65 6e 74 73 20 61 20 70  |t represents a p|
00001b10  72 6f 67 72 65 73 73 69  76 65 20 6f 72 20 73 65  |rogressive or se|
00001b20  71 75 65 6e 74 69 61 6c  20 66 69 6c 65 2c 20 62  |quential file, b|
00001b30  79 20 6f 62 73 65 72 76  69 6e 67 20 77 68 65 74  |y observing whet|
00001b40  68 65 72 0a 53 73 20 61  6e 64 20 53 65 20 76 61  |her.Ss and Se va|
00001b50  6c 75 65 73 20 6f 74 68  65 72 20 74 68 61 6e 20  |lues other than |
00001b60  30 20 61 6e 64 20 36 33  20 61 70 70 65 61 72 2e  |0 and 63 appear.|
00001b70  20 20 28 54 68 65 20 2d  70 72 6f 67 72 65 73 73  |  (The -progress|
00001b80  69 76 65 20 73 77 69 74  63 68 20 69 73 0a 6e 6f  |ive switch is.no|
00001b90  74 20 6e 65 65 64 65 64  20 74 6f 20 73 70 65 63  |t needed to spec|
00001ba0  69 66 79 20 74 68 69 73  3b 20 69 6e 20 66 61 63  |ify this; in fac|
00001bb0  74 2c 20 69 74 20 69 73  20 69 67 6e 6f 72 65 64  |t, it is ignored|
00001bc0  20 77 68 65 6e 20 2d 73  63 61 6e 73 20 61 70 70  | when -scans app|
00001bd0  65 61 72 73 2e 29 0a 54  68 65 20 73 63 61 6e 20  |ears.).The scan |
00001be0  73 63 72 69 70 74 20 6d  75 73 74 20 6d 65 65 74  |script must meet|
00001bf0  20 74 68 65 20 4a 50 45  47 20 72 65 73 74 72 69  | the JPEG restri|
00001c00  63 74 69 6f 6e 73 20 6f  6e 20 70 72 6f 67 72 65  |ctions on progre|
00001c10  73 73 69 6f 6e 20 73 65  71 75 65 6e 63 65 73 2e  |ssion sequences.|
00001c20  0a 28 63 6a 70 65 67 20  63 68 65 63 6b 73 20 74  |.(cjpeg checks t|
00001c30  68 61 74 20 74 68 65 20  73 70 65 63 27 73 20 72  |hat the spec's r|
00001c40  65 71 75 69 72 65 6d 65  6e 74 73 20 61 72 65 20  |equirements are |
00001c50  6f 62 65 79 65 64 2e 29  0a 0a 53 63 61 6e 20 73  |obeyed.)..Scan s|
00001c60  63 72 69 70 74 20 66 69  6c 65 73 20 61 72 65 20  |cript files are |
00001c70  66 72 65 65 20 66 6f 72  6d 61 74 2c 20 69 6e 20  |free format, in |
00001c80  74 68 61 74 20 61 72 62  69 74 72 61 72 79 20 77  |that arbitrary w|
00001c90  68 69 74 65 73 70 61 63  65 20 63 61 6e 20 61 70  |hitespace can ap|
00001ca0  70 65 61 72 0a 62 65 74  77 65 65 6e 20 6e 75 6d  |pear.between num|
00001cb0  62 65 72 73 20 61 6e 64  20 61 72 6f 75 6e 64 20  |bers and around |
00001cc0  70 75 6e 63 74 75 61 74  69 6f 6e 2e 20 20 41 6c  |punctuation.  Al|
00001cd0  73 6f 2c 20 63 6f 6d 6d  65 6e 74 73 20 63 61 6e  |so, comments can|
00001ce0  20 62 65 20 69 6e 63 6c  75 64 65 64 3a 20 61 0a  | be included: a.|
00001cf0  63 6f 6d 6d 65 6e 74 20  73 74 61 72 74 73 20 77  |comment starts w|
00001d00  69 74 68 20 27 23 27 20  61 6e 64 20 65 78 74 65  |ith '#' and exte|
00001d10  6e 64 73 20 74 6f 20 74  68 65 20 65 6e 64 20 6f  |nds to the end o|
00001d20  66 20 74 68 65 20 6c 69  6e 65 2e 20 20 46 6f 72  |f the line.  For|
00001d30  20 61 64 64 69 74 69 6f  6e 61 6c 0a 6c 65 67 69  | additional.legi|
00001d40  62 69 6c 69 74 79 2c 20  63 6f 6d 6d 61 73 20 6f  |bility, commas o|
00001d50  72 20 64 61 73 68 65 73  20 63 61 6e 20 62 65 20  |r dashes can be |
00001d60  70 6c 61 63 65 64 20 62  65 74 77 65 65 6e 20 76  |placed between v|
00001d70  61 6c 75 65 73 2e 20 20  28 41 63 74 75 61 6c 6c  |alues.  (Actuall|
00001d80  79 2c 20 61 6e 79 0a 73  69 6e 67 6c 65 20 70 75  |y, any.single pu|
00001d90  6e 63 74 75 61 74 69 6f  6e 20 63 68 61 72 61 63  |nctuation charac|
00001da0  74 65 72 20 6f 74 68 65  72 20 74 68 61 6e 20 27  |ter other than '|
00001db0  3a 27 20 6f 72 20 27 3b  27 20 63 61 6e 20 62 65  |:' or ';' can be|
00001dc0  20 69 6e 73 65 72 74 65  64 2e 29 20 20 46 6f 72  | inserted.)  For|
00001dd0  0a 65 78 61 6d 70 6c 65  2c 20 74 68 65 20 66 6f  |.example, the fo|
00001de0  6c 6c 6f 77 69 6e 67 20  74 77 6f 20 73 63 61 6e  |llowing two scan|
00001df0  20 64 65 66 69 6e 69 74  69 6f 6e 73 20 61 72 65  | definitions are|
00001e00  20 65 71 75 69 76 61 6c  65 6e 74 3a 0a 09 30 20  | equivalent:..0 |
00001e10  31 20 32 3a 20 30 20 36  33 20 30 20 30 3b 0a 09  |1 2: 0 63 0 0;..|
00001e20  30 2c 31 2c 32 20 3a 20  30 2d 36 33 2c 20 30 2c  |0,1,2 : 0-63, 0,|
00001e30  30 20 3b 0a 0a 48 65 72  65 20 69 73 20 61 6e 20  |0 ;..Here is an |
00001e40  65 78 61 6d 70 6c 65 20  6f 66 20 61 20 73 63 61  |example of a sca|
00001e50  6e 20 73 63 72 69 70 74  20 74 68 61 74 20 67 65  |n script that ge|
00001e60  6e 65 72 61 74 65 73 20  61 20 70 61 72 74 69 61  |nerates a partia|
00001e70  6c 6c 79 20 69 6e 74 65  72 6c 65 61 76 65 64 0a  |lly interleaved.|
00001e80  73 65 71 75 65 6e 74 69  61 6c 20 4a 50 45 47 20  |sequential JPEG |
00001e90  66 69 6c 65 3a 0a 0a 09  30 3b 09 09 09 23 20 59  |file:...0;...# Y|
00001ea0  20 6f 6e 6c 79 20 69 6e  20 66 69 72 73 74 20 73  | only in first s|
00001eb0  63 61 6e 0a 09 31 20 32  3b 09 09 09 23 20 43 62  |can..1 2;...# Cb|
00001ec0  20 61 6e 64 20 43 72 20  69 6e 20 73 65 63 6f 6e  | and Cr in secon|
00001ed0  64 20 73 63 61 6e 0a 0a  48 65 72 65 20 69 73 20  |d scan..Here is |
00001ee0  61 6e 20 65 78 61 6d 70  6c 65 20 6f 66 20 61 20  |an example of a |
00001ef0  70 72 6f 67 72 65 73 73  69 76 65 20 73 63 61 6e  |progressive scan|
00001f00  20 73 63 72 69 70 74 20  75 73 69 6e 67 20 6f 6e  | script using on|
00001f10  6c 79 20 73 70 65 63 74  72 61 6c 20 73 65 6c 65  |ly spectral sele|
00001f20  63 74 69 6f 6e 0a 28 6e  6f 20 73 75 63 63 65 73  |ction.(no succes|
00001f30  73 69 76 65 20 61 70 70  72 6f 78 69 6d 61 74 69  |sive approximati|
00001f40  6f 6e 29 3a 0a 0a 09 23  20 49 6e 74 65 72 6c 65  |on):...# Interle|
00001f50  61 76 65 64 20 44 43 20  73 63 61 6e 20 66 6f 72  |aved DC scan for|
00001f60  20 59 2c 43 62 2c 43 72  3a 0a 09 30 2c 31 2c 32  | Y,Cb,Cr:..0,1,2|
00001f70  3a 20 30 2d 30 2c 20 20  20 30 2c 20 30 20 3b 0a  |: 0-0,   0, 0 ;.|
00001f80  09 23 20 41 43 20 73 63  61 6e 73 3a 0a 09 30 3a  |.# AC scans:..0:|
00001f90  20 20 20 20 20 31 2d 32  2c 20 20 20 30 2c 20 30  |     1-2,   0, 0|
00001fa0  20 3b 09 23 20 46 69 72  73 74 20 74 77 6f 20 59  | ;.# First two Y|
00001fb0  20 41 43 20 63 6f 65 66  66 69 63 69 65 6e 74 73  | AC coefficients|
00001fc0  0a 09 30 3a 20 20 20 20  20 33 2d 35 2c 20 20 20  |..0:     3-5,   |
00001fd0  30 2c 20 30 20 3b 09 23  20 54 68 72 65 65 20 6d  |0, 0 ;.# Three m|
00001fe0  6f 72 65 0a 09 31 3a 20  20 20 20 20 31 2d 36 33  |ore..1:     1-63|
00001ff0  2c 20 20 30 2c 20 30 20  3b 09 23 20 41 6c 6c 20  |,  0, 0 ;.# All |
00002000  41 43 20 63 6f 65 66 66  69 63 69 65 6e 74 73 20  |AC coefficients |
00002010  66 6f 72 20 43 62 0a 09  32 3a 20 20 20 20 20 31  |for Cb..2:     1|
00002020  2d 36 33 2c 20 20 30 2c  20 30 20 3b 09 23 20 41  |-63,  0, 0 ;.# A|
00002030  6c 6c 20 41 43 20 63 6f  65 66 66 69 63 69 65 6e  |ll AC coefficien|
00002040  74 73 20 66 6f 72 20 43  72 0a 09 30 3a 20 20 20  |ts for Cr..0:   |
00002050  20 20 36 2d 39 2c 20 20  20 30 2c 20 30 20 3b 09  |  6-9,   0, 0 ;.|
00002060  23 20 4d 6f 72 65 20 59  20 63 6f 65 66 66 69 63  |# More Y coeffic|
00002070  69 65 6e 74 73 0a 09 30  3a 20 20 20 20 20 31 30  |ients..0:     10|
00002080  2d 36 33 2c 20 30 2c 20  30 20 3b 09 23 20 52 65  |-63, 0, 0 ;.# Re|
00002090  6d 61 69 6e 69 6e 67 20  59 20 63 6f 65 66 66 69  |maining Y coeffi|
000020a0  63 69 65 6e 74 73 0a 0a  48 65 72 65 20 69 73 20  |cients..Here is |
000020b0  61 6e 20 65 78 61 6d 70  6c 65 20 6f 66 20 61 20  |an example of a |
000020c0  73 75 63 63 65 73 73 69  76 65 2d 61 70 70 72 6f  |successive-appro|
000020d0  78 69 6d 61 74 69 6f 6e  20 73 63 72 69 70 74 2e  |ximation script.|
000020e0  20 20 54 68 69 73 20 69  73 20 65 71 75 69 76 61  |  This is equiva|
000020f0  6c 65 6e 74 0a 74 6f 20  74 68 65 20 64 65 66 61  |lent.to the defa|
00002100  75 6c 74 20 73 63 72 69  70 74 20 75 73 65 64 20  |ult script used |
00002110  62 79 20 22 63 6a 70 65  67 20 2d 70 72 6f 67 72  |by "cjpeg -progr|
00002120  65 73 73 69 76 65 22 20  66 6f 72 20 59 43 62 43  |essive" for YCbC|
00002130  72 20 69 6d 61 67 65 73  3a 0a 0a 09 23 20 49 6e  |r images:...# In|
00002140  69 74 69 61 6c 20 44 43  20 73 63 61 6e 20 66 6f  |itial DC scan fo|
00002150  72 20 59 2c 43 62 2c 43  72 20 28 6c 6f 77 65 73  |r Y,Cb,Cr (lowes|
00002160  74 20 62 69 74 20 6e 6f  74 20 73 65 6e 74 29 0a  |t bit not sent).|
00002170  09 30 2c 31 2c 32 3a 20  30 2d 30 2c 20 20 20 30  |.0,1,2: 0-0,   0|
00002180  2c 20 31 20 3b 0a 09 23  20 46 69 72 73 74 20 41  |, 1 ;..# First A|
00002190  43 20 73 63 61 6e 3a 20  73 65 6e 64 20 66 69 72  |C scan: send fir|
000021a0  73 74 20 35 20 59 20 41  43 20 63 6f 65 66 66 69  |st 5 Y AC coeffi|
000021b0  63 69 65 6e 74 73 2c 20  6d 69 6e 75 73 20 32 20  |cients, minus 2 |
000021c0  6c 6f 77 65 73 74 20 62  69 74 73 3a 0a 09 30 3a  |lowest bits:..0:|
000021d0  20 20 20 20 20 31 2d 35  2c 20 20 20 30 2c 20 32  |     1-5,   0, 2|
000021e0  20 3b 0a 09 23 20 53 65  6e 64 20 61 6c 6c 20 43  | ;..# Send all C|
000021f0  72 2c 43 62 20 41 43 20  63 6f 65 66 66 69 63 69  |r,Cb AC coeffici|
00002200  65 6e 74 73 2c 20 6d 69  6e 75 73 20 6c 6f 77 65  |ents, minus lowe|
00002210  73 74 20 62 69 74 3a 0a  09 23 20 28 63 68 72 6f  |st bit:..# (chro|
00002220  6d 61 20 64 61 74 61 20  69 73 20 75 73 75 61 6c  |ma data is usual|
00002230  6c 79 20 74 6f 6f 20 73  6d 61 6c 6c 20 74 6f 20  |ly too small to |
00002240  62 65 20 77 6f 72 74 68  20 73 75 62 64 69 76 69  |be worth subdivi|
00002250  64 69 6e 67 20 66 75 72  74 68 65 72 3b 0a 09 23  |ding further;..#|
00002260  20 20 62 75 74 20 6e 6f  74 65 20 77 65 20 73 65  |  but note we se|
00002270  6e 64 20 43 72 20 66 69  72 73 74 20 73 69 6e 63  |nd Cr first sinc|
00002280  65 20 65 79 65 20 69 73  20 6c 65 61 73 74 20 73  |e eye is least s|
00002290  65 6e 73 69 74 69 76 65  20 74 6f 20 43 62 29 0a  |ensitive to Cb).|
000022a0  09 32 3a 20 20 20 20 20  31 2d 36 33 2c 20 20 30  |.2:     1-63,  0|
000022b0  2c 20 31 20 3b 0a 09 31  3a 20 20 20 20 20 31 2d  |, 1 ;..1:     1-|
000022c0  36 33 2c 20 20 30 2c 20  31 20 3b 0a 09 23 20 53  |63,  0, 1 ;..# S|
000022d0  65 6e 64 20 72 65 6d 61  69 6e 69 6e 67 20 59 20  |end remaining Y |
000022e0  41 43 20 63 6f 65 66 66  69 63 69 65 6e 74 73 2c  |AC coefficients,|
000022f0  20 6d 69 6e 75 73 20 32  20 6c 6f 77 65 73 74 20  | minus 2 lowest |
00002300  62 69 74 73 3a 0a 09 30  3a 20 20 20 20 20 36 2d  |bits:..0:     6-|
00002310  36 33 2c 20 20 30 2c 20  32 20 3b 0a 09 23 20 53  |63,  0, 2 ;..# S|
00002320  65 6e 64 20 6e 65 78 74  2d 74 6f 2d 6c 6f 77 65  |end next-to-lowe|
00002330  73 74 20 62 69 74 20 6f  66 20 61 6c 6c 20 59 20  |st bit of all Y |
00002340  41 43 20 63 6f 65 66 66  69 63 69 65 6e 74 73 3a  |AC coefficients:|
00002350  0a 09 30 3a 20 20 20 20  20 31 2d 36 33 2c 20 20  |..0:     1-63,  |
00002360  32 2c 20 31 20 3b 0a 09  23 20 41 74 20 74 68 69  |2, 1 ;..# At thi|
00002370  73 20 70 6f 69 6e 74 20  77 65 27 76 65 20 73 65  |s point we've se|
00002380  6e 74 20 61 6c 6c 20 62  75 74 20 74 68 65 20 6c  |nt all but the l|
00002390  6f 77 65 73 74 20 62 69  74 20 6f 66 20 61 6c 6c  |owest bit of all|
000023a0  20 63 6f 65 66 66 69 63  69 65 6e 74 73 2e 0a 09  | coefficients...|
000023b0  23 20 53 65 6e 64 20 6c  6f 77 65 73 74 20 62 69  |# Send lowest bi|
000023c0  74 20 6f 66 20 44 43 20  63 6f 65 66 66 69 63 69  |t of DC coeffici|
000023d0  65 6e 74 73 0a 09 30 2c  31 2c 32 3a 20 30 2d 30  |ents..0,1,2: 0-0|
000023e0  2c 20 20 20 31 2c 20 30  20 3b 0a 09 23 20 53 65  |,   1, 0 ;..# Se|
000023f0  6e 64 20 6c 6f 77 65 73  74 20 62 69 74 20 6f 66  |nd lowest bit of|
00002400  20 41 43 20 63 6f 65 66  66 69 63 69 65 6e 74 73  | AC coefficients|
00002410  0a 09 32 3a 20 20 20 20  20 31 2d 36 33 2c 20 20  |..2:     1-63,  |
00002420  31 2c 20 30 20 3b 0a 09  31 3a 20 20 20 20 20 31  |1, 0 ;..1:     1|
00002430  2d 36 33 2c 20 20 31 2c  20 30 20 3b 0a 09 23 20  |-63,  1, 0 ;..# |
00002440  59 20 41 43 20 6c 6f 77  65 73 74 20 62 69 74 20  |Y AC lowest bit |
00002450  73 63 61 6e 20 69 73 20  6c 61 73 74 3b 20 69 74  |scan is last; it|
00002460  27 73 20 75 73 75 61 6c  6c 79 20 74 68 65 20 6c  |'s usually the l|
00002470  61 72 67 65 73 74 20 73  63 61 6e 0a 09 30 3a 20  |argest scan..0: |
00002480  20 20 20 20 31 2d 36 33  2c 20 20 31 2c 20 30 20  |    1-63,  1, 0 |
00002490  3b 0a 0a 49 74 20 6d 61  79 20 62 65 20 77 6f 72  |;..It may be wor|
000024a0  74 68 20 70 6f 69 6e 74  69 6e 67 20 6f 75 74 20  |th pointing out |
000024b0  74 68 61 74 20 74 68 69  73 20 73 63 72 69 70 74  |that this script|
000024c0  20 69 73 20 74 75 6e 65  64 20 66 6f 72 20 71 75  | is tuned for qu|
000024d0  61 6c 69 74 79 20 73 65  74 74 69 6e 67 73 0a 6f  |ality settings.o|
000024e0  66 20 61 72 6f 75 6e 64  20 35 30 20 74 6f 20 37  |f around 50 to 7|
000024f0  35 2e 20 20 46 6f 72 20  6c 6f 77 65 72 20 71 75  |5.  For lower qu|
00002500  61 6c 69 74 79 20 73 65  74 74 69 6e 67 73 2c 20  |ality settings, |
00002510  79 6f 75 27 64 20 70 72  6f 62 61 62 6c 79 20 77  |you'd probably w|
00002520  61 6e 74 20 74 6f 20 75  73 65 0a 61 20 73 63 72  |ant to use.a scr|
00002530  69 70 74 20 77 69 74 68  20 66 65 77 65 72 20 73  |ipt with fewer s|
00002540  74 61 67 65 73 20 6f 66  20 73 75 63 63 65 73 73  |tages of success|
00002550  69 76 65 20 61 70 70 72  6f 78 69 6d 61 74 69 6f  |ive approximatio|
00002560  6e 20 28 6f 74 68 65 72  77 69 73 65 20 74 68 65  |n (otherwise the|
00002570  0a 69 6e 69 74 69 61 6c  20 73 63 61 6e 73 20 77  |.initial scans w|
00002580  69 6c 6c 20 62 65 20 72  65 61 6c 6c 79 20 62 61  |ill be really ba|
00002590  64 29 2e 20 20 46 6f 72  20 68 69 67 68 65 72 20  |d).  For higher |
000025a0  71 75 61 6c 69 74 79 20  73 65 74 74 69 6e 67 73  |quality settings|
000025b0  2c 20 79 6f 75 20 6d 69  67 68 74 0a 77 61 6e 74  |, you might.want|
000025c0  20 74 6f 20 75 73 65 20  6d 6f 72 65 20 73 74 61  | to use more sta|
000025d0  67 65 73 20 6f 66 20 73  75 63 63 65 73 73 69 76  |ges of successiv|
000025e0  65 20 61 70 70 72 6f 78  69 6d 61 74 69 6f 6e 20  |e approximation |
000025f0  28 73 6f 20 74 68 61 74  20 74 68 65 20 69 6e 69  |(so that the ini|
00002600  74 69 61 6c 0a 73 63 61  6e 73 20 61 72 65 20 6e  |tial.scans are n|
00002610  6f 74 20 74 6f 6f 20 6c  61 72 67 65 29 2e 0a     |ot too large)..|
0000261f