OSDN Git Service

・#26997 DTXViewer023 のソースコード一式を追加。変更点は以下の通り。
[dtxmania/dtxmania.git] / @jpeglibソリューション / jpeg-8c / wizard.txt
1 Advanced usage instructions for the Independent JPEG Group's JPEG software\r
2 ==========================================================================\r
3 \r
4 This file describes cjpeg's "switches for wizards".\r
5 \r
6 The "wizard" switches are intended for experimentation with JPEG by persons\r
7 who are reasonably knowledgeable about the JPEG standard.  If you don't know\r
8 what you are doing, DON'T USE THESE SWITCHES.  You'll likely produce files\r
9 with worse image quality and/or poorer compression than you'd get from the\r
10 default settings.  Furthermore, these switches must be used with caution\r
11 when making files intended for general use, because not all JPEG decoders\r
12 will support unusual JPEG parameter settings.\r
13 \r
14 \r
15 Quantization Table Adjustment\r
16 -----------------------------\r
17 \r
18 Ordinarily, cjpeg starts with a default set of tables (the same ones given\r
19 as examples in the JPEG standard) and scales them up or down according to\r
20 the -quality setting.  The details of the scaling algorithm can be found in\r
21 jcparam.c.  At very low quality settings, some quantization table entries\r
22 can get scaled up to values exceeding 255.  Although 2-byte quantization\r
23 values are supported by the IJG software, this feature is not in baseline\r
24 JPEG and is not supported by all implementations.  If you need to ensure\r
25 wide compatibility of low-quality files, you can constrain the scaled\r
26 quantization values to no more than 255 by giving the -baseline switch.\r
27 Note that use of -baseline will result in poorer quality for the same file\r
28 size, since more bits than necessary are expended on higher AC coefficients.\r
29 \r
30 You can substitute a different set of quantization values by using the\r
31 -qtables switch:\r
32 \r
33         -qtables file   Use the quantization tables given in the named file.\r
34 \r
35 The specified file should be a text file containing decimal quantization\r
36 values.  The file should contain one to four tables, each of 64 elements.\r
37 The tables are implicitly numbered 0,1,etc. in order of appearance.  Table\r
38 entries appear in normal array order (NOT in the zigzag order in which they\r
39 will be stored in the JPEG file).\r
40 \r
41 Quantization table files are free format, in that arbitrary whitespace can\r
42 appear between numbers.  Also, comments can be included: a comment starts\r
43 with '#' and extends to the end of the line.  Here is an example file that\r
44 duplicates the default quantization tables:\r
45 \r
46         # Quantization tables given in JPEG spec, section K.1\r
47 \r
48         # This is table 0 (the luminance table):\r
49           16  11  10  16  24  40  51  61\r
50           12  12  14  19  26  58  60  55\r
51           14  13  16  24  40  57  69  56\r
52           14  17  22  29  51  87  80  62\r
53           18  22  37  56  68 109 103  77\r
54           24  35  55  64  81 104 113  92\r
55           49  64  78  87 103 121 120 101\r
56           72  92  95  98 112 100 103  99\r
57 \r
58         # This is table 1 (the chrominance table):\r
59           17  18  24  47  99  99  99  99\r
60           18  21  26  66  99  99  99  99\r
61           24  26  56  99  99  99  99  99\r
62           47  66  99  99  99  99  99  99\r
63           99  99  99  99  99  99  99  99\r
64           99  99  99  99  99  99  99  99\r
65           99  99  99  99  99  99  99  99\r
66           99  99  99  99  99  99  99  99\r
67 \r
68 If the -qtables switch is used without -quality, then the specified tables\r
69 are used exactly as-is.  If both -qtables and -quality are used, then the\r
70 tables taken from the file are scaled in the same fashion that the default\r
71 tables would be scaled for that quality setting.  If -baseline appears, then\r
72 the quantization values are constrained to the range 1-255.\r
73 \r
74 By default, cjpeg will use quantization table 0 for luminance components and\r
75 table 1 for chrominance components.  To override this choice, use the -qslots\r
76 switch:\r
77 \r
78         -qslots N[,...]         Select which quantization table to use for\r
79                                 each color component.\r
80 \r
81 The -qslots switch specifies a quantization table number for each color\r
82 component, in the order in which the components appear in the JPEG SOF marker.\r
83 For example, to create a separate table for each of Y,Cb,Cr, you could\r
84 provide a -qtables file that defines three quantization tables and say\r
85 "-qslots 0,1,2".  If -qslots gives fewer table numbers than there are color\r
86 components, then the last table number is repeated as necessary.\r
87 \r
88 \r
89 Sampling Factor Adjustment\r
90 --------------------------\r
91 \r
92 By default, cjpeg uses 2:1 horizontal and vertical downsampling when\r
93 compressing YCbCr data, and no downsampling for all other color spaces.\r
94 You can override this default with the -sample switch:\r
95 \r
96         -sample HxV[,...]       Set JPEG sampling factors for each color\r
97                                 component.\r
98 \r
99 The -sample switch specifies the JPEG sampling factors for each color\r
100 component, in the order in which they appear in the JPEG SOF marker.\r
101 If you specify fewer HxV pairs than there are components, the remaining\r
102 components are set to 1x1 sampling.  For example, the default YCbCr setting\r
103 is equivalent to "-sample 2x2,1x1,1x1", which can be abbreviated to\r
104 "-sample 2x2".\r
105 \r
106 There are still some JPEG decoders in existence that support only 2x1\r
107 sampling (also called 4:2:2 sampling).  Compatibility with such decoders can\r
108 be achieved by specifying "-sample 2x1".  This is not recommended unless\r
109 really necessary, since it increases file size and encoding/decoding time\r
110 with very little quality gain.\r
111 \r
112 \r
113 Multiple Scan / Progression Control\r
114 -----------------------------------\r
115 \r
116 By default, cjpeg emits a single-scan sequential JPEG file.  The\r
117 -progressive switch generates a progressive JPEG file using a default series\r
118 of progression parameters.  You can create multiple-scan sequential JPEG\r
119 files or progressive JPEG files with custom progression parameters by using\r
120 the -scans switch:\r
121 \r
122         -scans file     Use the scan sequence given in the named file.\r
123 \r
124 The specified file should be a text file containing a "scan script".\r
125 The script specifies the contents and ordering of the scans to be emitted.\r
126 Each entry in the script defines one scan.  A scan definition specifies\r
127 the components to be included in the scan, and for progressive JPEG it also\r
128 specifies the progression parameters Ss,Se,Ah,Al for the scan.  Scan\r
129 definitions are separated by semicolons (';').  A semicolon after the last\r
130 scan definition is optional.\r
131 \r
132 Each scan definition contains one to four component indexes, optionally\r
133 followed by a colon (':') and the four progressive-JPEG parameters.  The\r
134 component indexes denote which color component(s) are to be transmitted in\r
135 the scan.  Components are numbered in the order in which they appear in the\r
136 JPEG SOF marker, with the first component being numbered 0.  (Note that these\r
137 indexes are not the "component ID" codes assigned to the components, just\r
138 positional indexes.)\r
139 \r
140 The progression parameters for each scan are:\r
141         Ss      Zigzag index of first coefficient included in scan\r
142         Se      Zigzag index of last coefficient included in scan\r
143         Ah      Zero for first scan of a coefficient, else Al of prior scan\r
144         Al      Successive approximation low bit position for scan\r
145 If the progression parameters are omitted, the values 0,63,0,0 are used,\r
146 producing a sequential JPEG file.  cjpeg automatically determines whether\r
147 the script represents a progressive or sequential file, by observing whether\r
148 Ss and Se values other than 0 and 63 appear.  (The -progressive switch is\r
149 not needed to specify this; in fact, it is ignored when -scans appears.)\r
150 The scan script must meet the JPEG restrictions on progression sequences.\r
151 (cjpeg checks that the spec's requirements are obeyed.)\r
152 \r
153 Scan script files are free format, in that arbitrary whitespace can appear\r
154 between numbers and around punctuation.  Also, comments can be included: a\r
155 comment starts with '#' and extends to the end of the line.  For additional\r
156 legibility, commas or dashes can be placed between values.  (Actually, any\r
157 single punctuation character other than ':' or ';' can be inserted.)  For\r
158 example, the following two scan definitions are equivalent:\r
159         0 1 2: 0 63 0 0;\r
160         0,1,2 : 0-63, 0,0 ;\r
161 \r
162 Here is an example of a scan script that generates a partially interleaved\r
163 sequential JPEG file:\r
164 \r
165         0;                      # Y only in first scan\r
166         1 2;                    # Cb and Cr in second scan\r
167 \r
168 Here is an example of a progressive scan script using only spectral selection\r
169 (no successive approximation):\r
170 \r
171         # Interleaved DC scan for Y,Cb,Cr:\r
172         0,1,2: 0-0,   0, 0 ;\r
173         # AC scans:\r
174         0:     1-2,   0, 0 ;    # First two Y AC coefficients\r
175         0:     3-5,   0, 0 ;    # Three more\r
176         1:     1-63,  0, 0 ;    # All AC coefficients for Cb\r
177         2:     1-63,  0, 0 ;    # All AC coefficients for Cr\r
178         0:     6-9,   0, 0 ;    # More Y coefficients\r
179         0:     10-63, 0, 0 ;    # Remaining Y coefficients\r
180 \r
181 Here is an example of a successive-approximation script.  This is equivalent\r
182 to the default script used by "cjpeg -progressive" for YCbCr images:\r
183 \r
184         # Initial DC scan for Y,Cb,Cr (lowest bit not sent)\r
185         0,1,2: 0-0,   0, 1 ;\r
186         # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits:\r
187         0:     1-5,   0, 2 ;\r
188         # Send all Cr,Cb AC coefficients, minus lowest bit:\r
189         # (chroma data is usually too small to be worth subdividing further;\r
190         #  but note we send Cr first since eye is least sensitive to Cb)\r
191         2:     1-63,  0, 1 ;\r
192         1:     1-63,  0, 1 ;\r
193         # Send remaining Y AC coefficients, minus 2 lowest bits:\r
194         0:     6-63,  0, 2 ;\r
195         # Send next-to-lowest bit of all Y AC coefficients:\r
196         0:     1-63,  2, 1 ;\r
197         # At this point we've sent all but the lowest bit of all coefficients.\r
198         # Send lowest bit of DC coefficients\r
199         0,1,2: 0-0,   1, 0 ;\r
200         # Send lowest bit of AC coefficients\r
201         2:     1-63,  1, 0 ;\r
202         1:     1-63,  1, 0 ;\r
203         # Y AC lowest bit scan is last; it's usually the largest scan\r
204         0:     1-63,  1, 0 ;\r
205 \r
206 It may be worth pointing out that this script is tuned for quality settings\r
207 of around 50 to 75.  For lower quality settings, you'd probably want to use\r
208 a script with fewer stages of successive approximation (otherwise the\r
209 initial scans will be really bad).  For higher quality settings, you might\r
210 want to use more stages of successive approximation (so that the initial\r
211 scans are not too large).\r