source: josm/trunk/src/com/drew/imaging/jpeg/JpegSegmentType.java@ 15217

Last change on this file since 15217 was 15217, checked in by Don-vip, 5 years ago

see #17848 - update to metadata-extractor 2.12.0

File size: 6.0 KB
Line 
1/*
2 * Copyright 2002-2019 Drew Noakes and contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * https://drewnoakes.com/code/exif/
19 * https://github.com/drewnoakes/metadata-extractor
20 */
21package com.drew.imaging.jpeg;
22
23import com.drew.lang.annotations.Nullable;
24
25import java.util.ArrayList;
26import java.util.Collection;
27import java.util.List;
28
29/**
30 * An enumeration of the known segment types found in JPEG files.
31 *
32 * <ul>
33 * <li>http://www.ozhiker.com/electronics/pjmt/jpeg_info/app_segments.html</li>
34 * <li>http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html</li>
35 * </ul>
36 *
37 * @author Drew Noakes https://drewnoakes.com
38 */
39public enum JpegSegmentType
40{
41 /** APP0 JPEG segment identifier. Commonly contains JFIF, JFXX. */
42 APP0((byte)0xE0, true),
43
44 /** APP1 JPEG segment identifier. Commonly contains Exif. XMP data is also kept in here, though usually in a second instance. */
45 APP1((byte)0xE1, true),
46
47 /** APP2 JPEG segment identifier. Commonly contains ICC. */
48 APP2((byte)0xE2, true),
49
50 /** APP3 JPEG segment identifier. */
51 APP3((byte)0xE3, true),
52
53 /** APP4 JPEG segment identifier. */
54 APP4((byte)0xE4, true),
55
56 /** APP5 JPEG segment identifier. */
57 APP5((byte)0xE5, true),
58
59 /** APP6 JPEG segment identifier. */
60 APP6((byte)0xE6, true),
61
62 /** APP7 JPEG segment identifier. */
63 APP7((byte)0xE7, true),
64
65 /** APP8 JPEG segment identifier. */
66 APP8((byte)0xE8, true),
67
68 /** APP9 JPEG segment identifier. */
69 APP9((byte)0xE9, true),
70
71 /** APPA (App10) JPEG segment identifier. Can contain Unicode comments, though {@link JpegSegmentType#COM} is more commonly used for comments. */
72 APPA((byte)0xEA, true),
73
74 /** APPB (App11) JPEG segment identifier. */
75 APPB((byte)0xEB, true),
76
77 /** APPC (App12) JPEG segment identifier. */
78 APPC((byte)0xEC, true),
79
80 /** APPD (App13) JPEG segment identifier. Commonly contains IPTC, Photoshop data. */
81 APPD((byte)0xED, true),
82
83 /** APPE (App14) JPEG segment identifier. Commonly contains Adobe data. */
84 APPE((byte)0xEE, true),
85
86 /** APPF (App15) JPEG segment identifier. */
87 APPF((byte)0xEF, true),
88
89 /** Start Of Image segment identifier. */
90 SOI((byte)0xD8, false),
91
92 /** Define Quantization Table segment identifier. */
93 DQT((byte)0xDB, false),
94
95 /** Define Number of Lines segment identifier. */
96 DNL((byte)0xDC, false),
97
98 /** Define Restart Interval segment identifier. */
99 DRI((byte)0xDD, false),
100
101 /** Define Hierarchical Progression segment identifier. */
102 DHP((byte)0xDE, false),
103
104 /** EXPand reference component(s) segment identifier. */
105 EXP((byte)0xDF, false),
106
107 /** Define Huffman Table segment identifier. */
108 DHT((byte)0xC4, false),
109
110 /** Define Arithmetic Coding conditioning segment identifier. */
111 DAC((byte)0xCC, false),
112
113 /** Start-of-Frame (0) segment identifier for Baseline DCT. */
114 SOF0((byte)0xC0, true),
115
116 /** Start-of-Frame (1) segment identifier for Extended sequential DCT. */
117 SOF1((byte)0xC1, true),
118
119 /** Start-of-Frame (2) segment identifier for Progressive DCT. */
120 SOF2((byte)0xC2, true),
121
122 /** Start-of-Frame (3) segment identifier for Lossless (sequential). */
123 SOF3((byte)0xC3, true),
124
125// /** Start-of-Frame (4) segment identifier. */
126// SOF4((byte)0xC4, true),
127
128 /** Start-of-Frame (5) segment identifier for Differential sequential DCT. */
129 SOF5((byte)0xC5, true),
130
131 /** Start-of-Frame (6) segment identifier for Differential progressive DCT. */
132 SOF6((byte)0xC6, true),
133
134 /** Start-of-Frame (7) segment identifier for Differential lossless (sequential). */
135 SOF7((byte)0xC7, true),
136
137 /** Reserved for JPEG extensions. */
138 JPG((byte)0xC8, true),
139
140 /** Start-of-Frame (9) segment identifier for Extended sequential DCT. */
141 SOF9((byte)0xC9, true),
142
143 /** Start-of-Frame (10) segment identifier for Progressive DCT. */
144 SOF10((byte)0xCA, true),
145
146 /** Start-of-Frame (11) segment identifier for Lossless (sequential). */
147 SOF11((byte)0xCB, true),
148
149// /** Start-of-Frame (12) segment identifier. */
150// SOF12((byte)0xCC, true),
151
152 /** Start-of-Frame (13) segment identifier for Differential sequential DCT. */
153 SOF13((byte)0xCD, true),
154
155 /** Start-of-Frame (14) segment identifier for Differential progressive DCT. */
156 SOF14((byte)0xCE, true),
157
158 /** Start-of-Frame (15) segment identifier for Differential lossless (sequential). */
159 SOF15((byte)0xCF, true),
160
161 /** JPEG comment segment identifier for comments. */
162 COM((byte)0xFE, true);
163
164 public static final Collection<JpegSegmentType> canContainMetadataTypes;
165
166 static {
167 List<JpegSegmentType> segmentTypes = new ArrayList<JpegSegmentType>();
168 for (JpegSegmentType segmentType : JpegSegmentType.class.getEnumConstants()) {
169 if (segmentType.canContainMetadata) {
170 segmentTypes.add(segmentType);
171 }
172 }
173 canContainMetadataTypes = segmentTypes;
174 }
175
176 public final byte byteValue;
177 public final boolean canContainMetadata;
178
179 JpegSegmentType(byte byteValue, boolean canContainMetadata)
180 {
181 this.byteValue = byteValue;
182 this.canContainMetadata = canContainMetadata;
183 }
184
185 @Nullable
186 public static JpegSegmentType fromByte(byte segmentTypeByte)
187 {
188 for (JpegSegmentType segmentType : JpegSegmentType.class.getEnumConstants()) {
189 if (segmentType.byteValue == segmentTypeByte)
190 return segmentType;
191 }
192 return null;
193 }
194}
Note: See TracBrowser for help on using the repository browser.