3 package com.pixelmed.codec.jpeg;
5 import java.util.HashMap;
15 private static final String identString =
"@(#) $Header: /userland/cvs/codec/com/pixelmed/codec/jpeg/Markers.java,v 1.5 2018/08/30 10:23:04 dclunie Exp $";
19 public static final int APP0 = 0xffe0;
20 public static final int APP1 = 0xffe1;
21 public static final int APP2 = 0xffe2;
22 public static final int APP3 = 0xffe3;
23 public static final int APP4 = 0xffe4;
24 public static final int APP5 = 0xffe5;
25 public static final int APP6 = 0xffe6;
26 public static final int APP7 = 0xffe7;
27 public static final int APP8 = 0xffe8;
28 public static final int APP9 = 0xffe9;
29 public static final int APPA = 0xffea;
30 public static final int APPB = 0xffeb;
31 public static final int APPC = 0xffec;
32 public static final int APPD = 0xffed;
33 public static final int APPE = 0xffee;
34 public static final int APPF = 0xffef;
36 public static final int COM = 0xfffe;
37 public static final int DAC = 0xffcc;
38 public static final int DHP = 0xffde;
39 public static final int DHT = 0xffc4;
40 public static final int DNL = 0xffdc;
41 public static final int DQT = 0xffdb;
42 public static final int DRI = 0xffdd;
43 public static final int EOI = 0xffd9;
44 public static final int EXP = 0xffdf;
46 public static final int JPG = 0xffc8;
51 public static final int RST0 = 0xffd0;
52 public static final int RST1 = 0xffd1;
53 public static final int RST2 = 0xffd2;
54 public static final int RST3 = 0xffd3;
55 public static final int RST4 = 0xffd4;
56 public static final int RST5 = 0xffd5;
57 public static final int RST6 = 0xffd6;
58 public static final int RST7 = 0xffd7;
60 public static final int SOF0 = 0xffc0;
61 public static final int SOF1 = 0xffc1;
62 public static final int SOF2 = 0xffc2;
63 public static final int SOF3 = 0xffc3;
65 public static final int SOF5 = 0xffc5;
66 public static final int SOF6 = 0xffc6;
67 public static final int SOF7 = 0xffc7;
69 public static final int SOF9 = 0xffc9;
70 public static final int SOFA = 0xffca;
71 public static final int SOFB = 0xffcb;
73 public static final int SOFD = 0xffcd;
74 public static final int SOFE = 0xffce;
75 public static final int SOFF = 0xffcf;
77 public static final int SOI = 0xffd8;
78 public static final int SOS = 0xffda;
79 public static final int TEM = 0xff01;
83 public static final int SOF55 = 0xfff7;
84 public static final int LSE = 0xfff8;
93 public static final int SOC = 0xff4f;
94 public static final int SOT = 0xff90;
95 public static final int SOD = 0xff93;
97 public static final int SIZ = 0xff51;
98 public static final int COD = 0xff52;
99 public static final int COC = 0xff53;
100 public static final int RGN = 0xff5e;
101 public static final int QCD = 0xff5c;
102 public static final int QCC = 0xff5d;
103 public static final int POC = 0xff5f;
104 public static final int TLM = 0xff55;
105 public static final int PLM = 0xff57;
106 public static final int PLT = 0xff58;
107 public static final int PPM = 0xff60;
108 public static final int PPT = 0xff61;
109 public static final int SOP = 0xff91;
110 public static final int EPH = 0xff92;
111 public static final int CRG = 0xff63;
112 public static final int COM2K = 0xff64;
114 public static final int FF30 = 0xff30;
115 public static final int FF31 = 0xff31;
116 public static final int FF32 = 0xff32;
117 public static final int FF33 = 0xff33;
118 public static final int FF34 = 0xff34;
119 public static final int FF35 = 0xff35;
120 public static final int FF36 = 0xff36;
121 public static final int FF37 = 0xff37;
122 public static final int FF38 = 0xff38;
123 public static final int FF39 = 0xff39;
124 public static final int FF3A = 0xff3a;
125 public static final int FF3B = 0xff3b;
126 public static final int FF3C = 0xff3c;
127 public static final int FF3D = 0xff3d;
128 public static final int FF3E = 0xff3e;
129 public static final int FF3F = 0xff3f;
176 nolength=
true;
break;
178 nolength=
false;
break;
187 public static final boolean isSOF(
int marker) {
228 public static final boolean isDCT(
int marker) {
261 private static class MarkerDictionaryEntry {
266 MarkerDictionaryEntry(
int markercode,String abbreviation,String description) {
267 this.markercode = markercode;
268 this.abbreviation = abbreviation;
269 this.description = description;
273 private static final MarkerDictionaryEntry[] markerDictionaryTable = {
274 new MarkerDictionaryEntry(
APP0,
"APP0",
"Reserved for Application Use"),
275 new MarkerDictionaryEntry(
APP1,
"APP1",
"Reserved for Application Use"),
276 new MarkerDictionaryEntry(
APP2,
"APP2",
"Reserved for Application Use"),
277 new MarkerDictionaryEntry(
APP3,
"APP3",
"Reserved for Application Use"),
278 new MarkerDictionaryEntry(
APP4,
"APP4",
"Reserved for Application Use"),
279 new MarkerDictionaryEntry(
APP5,
"APP5",
"Reserved for Application Use"),
280 new MarkerDictionaryEntry(
APP6,
"APP6",
"Reserved for Application Use"),
281 new MarkerDictionaryEntry(
APP7,
"APP7",
"Reserved for Application Use"),
282 new MarkerDictionaryEntry(
APP8,
"APP8",
"Reserved for Application Use"),
283 new MarkerDictionaryEntry(
APP9,
"APP9",
"Reserved for Application Use"),
284 new MarkerDictionaryEntry(
APPA,
"APPA",
"Reserved for Application Use"),
285 new MarkerDictionaryEntry(
APPB,
"APPB",
"Reserved for Application Use"),
286 new MarkerDictionaryEntry(
APPC,
"APPC",
"Reserved for Application Use"),
287 new MarkerDictionaryEntry(
APPD,
"APPD",
"Reserved for Application Use"),
288 new MarkerDictionaryEntry(
APPE,
"APPE",
"Reserved for Application Use"),
289 new MarkerDictionaryEntry(
APPF,
"APPF",
"Reserved for Application Use"),
291 new MarkerDictionaryEntry(
COM,
"COM",
"Comment"),
292 new MarkerDictionaryEntry(
DAC,
"DAC",
"Define Arithmetic Conditioning Table(s)"),
293 new MarkerDictionaryEntry(
DHP,
"DHP",
"Define Hierarchical Progression"),
294 new MarkerDictionaryEntry(
DHT,
"DHT",
"Define Huffman Table(s)"),
295 new MarkerDictionaryEntry(
DNL,
"DNL",
"Define Number of Lines"),
296 new MarkerDictionaryEntry(
DQT,
"DQT",
"Define Quantization Table(s)"),
297 new MarkerDictionaryEntry(
DRI,
"DRI",
"Define Restart Interval"),
298 new MarkerDictionaryEntry(
EOI,
"EOI",
"End of Image (JPEG 2000 EOC End of codestream)"),
299 new MarkerDictionaryEntry(
EXP,
"EXP",
"Expand Reference Image(s)"),
301 new MarkerDictionaryEntry(
JPG,
"JPG",
"Reserved for JPEG extensions"),
303 new MarkerDictionaryEntry(
RST0,
"RST0",
"Restart with modulo 8 counter 0"),
304 new MarkerDictionaryEntry(
RST1,
"RST1",
"Restart with modulo 8 counter 1"),
305 new MarkerDictionaryEntry(
RST2,
"RST2",
"Restart with modulo 8 counter 2"),
306 new MarkerDictionaryEntry(
RST3,
"RST3",
"Restart with modulo 8 counter 3"),
307 new MarkerDictionaryEntry(
RST4,
"RST4",
"Restart with modulo 8 counter 4"),
308 new MarkerDictionaryEntry(
RST5,
"RST5",
"Restart with modulo 8 counter 5"),
309 new MarkerDictionaryEntry(
RST6,
"RST6",
"Restart with modulo 8 counter 6"),
310 new MarkerDictionaryEntry(
RST7,
"RST7",
"Restart with modulo 8 counter 7"),
312 new MarkerDictionaryEntry(
SOF0,
"SOF0",
"Huffman Baseline DCT"),
313 new MarkerDictionaryEntry(
SOF1,
"SOF1",
"Huffman Extended Sequential DCT"),
314 new MarkerDictionaryEntry(
SOF2,
"SOF2",
"Huffman Progressive DCT"),
315 new MarkerDictionaryEntry(
SOF3,
"SOF3",
"Huffman Lossless Sequential"),
316 new MarkerDictionaryEntry(
SOF5,
"SOF5",
"Huffman Differential Sequential DCT"),
317 new MarkerDictionaryEntry(
SOF6,
"SOF6",
"Huffman Differential Progressive DCT"),
318 new MarkerDictionaryEntry(
SOF7,
"SOF7",
"Huffman Differential Lossless"),
319 new MarkerDictionaryEntry(
SOF9,
"SOF9",
"Arithmetic Extended Sequential DCT"),
320 new MarkerDictionaryEntry(
SOFA,
"SOFA",
"Arithmetic Progressive DCT"),
321 new MarkerDictionaryEntry(
SOFB,
"SOFB",
"Arithmetic Lossless Sequential"),
322 new MarkerDictionaryEntry(
SOFD,
"SOFD",
"Arithmetic Differential Sequential DCT"),
323 new MarkerDictionaryEntry(
SOFE,
"SOFE",
"Arithmetic Differential Progressive DCT"),
324 new MarkerDictionaryEntry(
SOFF,
"SOFF",
"Arithmetic Differential Lossless"),
326 new MarkerDictionaryEntry(
SOF55,
"SOF55",
"LS"),
328 new MarkerDictionaryEntry(
SOI,
"SOI",
"Start of Image"),
329 new MarkerDictionaryEntry(
SOS,
"SOS",
"Start of Scan"),
330 new MarkerDictionaryEntry(
TEM,
"TEM",
"Temporary use with Arithmetic Encoding"),
332 new MarkerDictionaryEntry(
SOC,
"SOC",
"Start of codestream"),
333 new MarkerDictionaryEntry(
SOT,
"SOT",
"Start of tile-part"),
334 new MarkerDictionaryEntry(
SOD,
"SOD",
"Start of data"),
336 new MarkerDictionaryEntry(
SIZ,
"SIZ",
"Image and tile size"),
337 new MarkerDictionaryEntry(
COD,
"COD",
"Coding style default"),
338 new MarkerDictionaryEntry(
COC,
"COC",
"Coding style component"),
339 new MarkerDictionaryEntry(
RGN,
"RGN",
"Rgeion-of-interest"),
340 new MarkerDictionaryEntry(
QCD,
"QCD",
"Quantization default"),
341 new MarkerDictionaryEntry(
QCC,
"QCC",
"Quantization component"),
342 new MarkerDictionaryEntry(
POC,
"POC",
"Progression order change"),
343 new MarkerDictionaryEntry(
TLM,
"TLM",
"Tile-part lengths"),
344 new MarkerDictionaryEntry(
PLM,
"PLM",
"Packet length, main header"),
345 new MarkerDictionaryEntry(
PLT,
"PLT",
"Packet length, tile-part header"),
346 new MarkerDictionaryEntry(
PPM,
"PPM",
"Packet packer headers, main header"),
347 new MarkerDictionaryEntry(
PPT,
"PPT",
"Packet packer headers, tile-part header"),
348 new MarkerDictionaryEntry(
SOP,
"SOP",
"Start of packet"),
349 new MarkerDictionaryEntry(
EPH,
"EPH",
"End of packet header"),
350 new MarkerDictionaryEntry(
CRG,
"CRG",
"Component registration"),
351 new MarkerDictionaryEntry(
COM2K,
"COM",
"Comment (JPEG 2000)"),
353 new MarkerDictionaryEntry(
FF30,
"FF30",
"Reserved"),
354 new MarkerDictionaryEntry(
FF31,
"FF31",
"Reserved"),
355 new MarkerDictionaryEntry(
FF32,
"FF32",
"Reserved"),
356 new MarkerDictionaryEntry(
FF33,
"FF33",
"Reserved"),
357 new MarkerDictionaryEntry(
FF34,
"FF34",
"Reserved"),
358 new MarkerDictionaryEntry(
FF35,
"FF35",
"Reserved"),
359 new MarkerDictionaryEntry(
FF36,
"FF36",
"Reserved"),
360 new MarkerDictionaryEntry(
FF37,
"FF37",
"Reserved"),
361 new MarkerDictionaryEntry(
FF38,
"FF38",
"Reserved"),
362 new MarkerDictionaryEntry(
FF39,
"FF39",
"Reserved"),
363 new MarkerDictionaryEntry(
FF3A,
"FF3A",
"Reserved"),
364 new MarkerDictionaryEntry(
FF3B,
"FF3B",
"Reserved"),
365 new MarkerDictionaryEntry(
FF3C,
"FF3C",
"Reserved"),
366 new MarkerDictionaryEntry(
FF3D,
"FF3D",
"Reserved"),
367 new MarkerDictionaryEntry(
FF3E,
"FF3E",
"Reserved"),
368 new MarkerDictionaryEntry(
FF3F,
"FF3F",
"Reserved")
371 private static final Map<Integer,MarkerDictionaryEntry> mapOfMarkerToDictionaryEntry =
new HashMap<Integer,MarkerDictionaryEntry>();
374 for (MarkerDictionaryEntry e : markerDictionaryTable) {
375 mapOfMarkerToDictionaryEntry.put(
new Integer(e.markercode),e);
380 MarkerDictionaryEntry e = mapOfMarkerToDictionaryEntry.get(
new Integer(marker));
381 return e ==
null ?
"" : e.abbreviation;
385 MarkerDictionaryEntry e = mapOfMarkerToDictionaryEntry.get(
new Integer(marker));
386 return e ==
null ?
"" : e.description;