1 /* jpeg-marker.c
2 *
3 * Copyright � 2001 Lutz M�ller <lutz@users.sourceforge.net>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20 #include "config.h"
21 #include "jpeg-marker.h"
22
23 #include <stdlib.h>
24
25 static struct {
26 JPEGMarker marker;
27 const char *name;
28 const char *description;
29 } JPEGMarkerTable[] = {
30 {JPEG_MARKER_SOF0, "SOF0", "Encoding (baseline)"},
31 {JPEG_MARKER_SOF1, "SOF1", "Encoding (extended sequential)"},
32 {JPEG_MARKER_SOF2, "SOF2", "Encoding (progressive)"},
33 {JPEG_MARKER_SOF3, "SOF3", "Encoding (lossless)"},
34 {JPEG_MARKER_SOF5, "SOF5", "Encoding (differential sequential)"},
35 {JPEG_MARKER_SOF6, "SOF6", "Encoding (differential progressive)"},
36 {JPEG_MARKER_SOF7, "SOF7", "Encoding (differential lossless)"},
37 {JPEG_MARKER_SOF9, "SOF9",
38 "Encoding (extended sequential, arithmetic)"},
39 {JPEG_MARKER_SOF10, "SOF10", "Encoding (progressive, arithmetic)"},
40 {JPEG_MARKER_SOF11, "SOF11", "Encoding (lossless, arithmetic)"},
41 {JPEG_MARKER_SOF13, "SOF13",
42 "Encoding (differential sequential, arithmetic)"},
43 {JPEG_MARKER_SOF14, "SOF14",
44 "Encoding (differential progressive, arithmetic)"},
45 {JPEG_MARKER_SOF15, "SOF15",
46 "Encoding (differential lossless, arithmetic)"},
47 {JPEG_MARKER_SOI, "SOI", "Start of image"},
48 {JPEG_MARKER_EOI, "EOI", "End of image"},
49 {JPEG_MARKER_SOS, "SOS", "Start of scan"},
50 {JPEG_MARKER_COM, "COM", "Comment"},
51 {JPEG_MARKER_DHT, "DHT", "Define Huffman table"},
52 {JPEG_MARKER_JPG, "JPG", "Extension"},
53 {JPEG_MARKER_DAC, "DAC", "Define arithmetic coding conditioning"},
54 {JPEG_MARKER_RST1, "RST1", "Restart 1"},
55 {JPEG_MARKER_RST2, "RST2", "Restart 2"},
56 {JPEG_MARKER_RST3, "RST3", "Restart 3"},
57 {JPEG_MARKER_RST4, "RST4", "Restart 4"},
58 {JPEG_MARKER_RST5, "RST5", "Restart 5"},
59 {JPEG_MARKER_RST6, "RST6", "Restart 6"},
60 {JPEG_MARKER_RST7, "RST7", "Restart 7"},
61 {JPEG_MARKER_DQT, "DQT", "Define quantization table"},
62 {JPEG_MARKER_DNL, "DNL", "Define number of lines"},
63 {JPEG_MARKER_DRI, "DRI", "Define restart interval"},
64 {JPEG_MARKER_DHP, "DHP", "Define hierarchical progression"},
65 {JPEG_MARKER_EXP, "EXP", "Expand reference component"},
66 {JPEG_MARKER_APP0, "APP0", "Application segment 0"},
67 {JPEG_MARKER_APP1, "APP1", "Application segment 1"},
68 {JPEG_MARKER_APP2, "APP2", "Application segment 2"},
69 {JPEG_MARKER_APP3, "APP3", "Application segment 3"},
70 {JPEG_MARKER_APP4, "APP4", "Application segment 4"},
71 {JPEG_MARKER_APP5, "APP5", "Application segment 5"},
72 {JPEG_MARKER_APP6, "APP6", "Application segment 6"},
73 {JPEG_MARKER_APP7, "APP7", "Application segment 7"},
74 {JPEG_MARKER_APP8, "APP8", "Application segment 8"},
75 {JPEG_MARKER_APP9, "APP9", "Application segment 9"},
76 {JPEG_MARKER_APP10, "APP10", "Application segment 10"},
77 {JPEG_MARKER_APP11, "APP11", "Application segment 11"},
78 {JPEG_MARKER_APP12, "APP12", "Application segment 12"},
79 {JPEG_MARKER_APP13, "APP13", "Application segment 13"},
80 {JPEG_MARKER_APP14, "APP14", "Application segment 14"},
81 {JPEG_MARKER_APP15, "APP15", "Application segment 15"},
82 {JPEG_MARKER_JPG0, "JPG0", "Extension 0"},
83 {JPEG_MARKER_JPG1, "JPG1", "Extension 1"},
84 {JPEG_MARKER_JPG2, "JPG2", "Extension 2"},
85 {JPEG_MARKER_JPG3, "JPG3", "Extension 3"},
86 {JPEG_MARKER_JPG4, "JPG4", "Extension 4"},
87 {JPEG_MARKER_JPG5, "JPG5", "Extension 5"},
88 {JPEG_MARKER_JPG6, "JPG6", "Extension 6"},
89 {JPEG_MARKER_JPG7, "JPG7", "Extension 7"},
90 {JPEG_MARKER_JPG8, "JPG8", "Extension 8"},
91 {JPEG_MARKER_JPG9, "JPG9", "Extension 9"},
92 {JPEG_MARKER_JPG10, "JPG10", "Extension 10"},
93 {JPEG_MARKER_JPG11, "JPG11", "Extension 11"},
94 {JPEG_MARKER_JPG12, "JPG12", "Extension 12"},
95 {JPEG_MARKER_JPG13, "JPG13", "Extension 13"},
96 {0, NULL, NULL}
97 };
98
99 const char *
jpeg_marker_get_name(JPEGMarker marker)100 jpeg_marker_get_name (JPEGMarker marker)
101 {
102 unsigned int i;
103
104 for (i = 0; JPEGMarkerTable[i].name; i++)
105 if (JPEGMarkerTable[i].marker == marker)
106 break;
107
108 return (JPEGMarkerTable[i].name);
109 }
110
111 const char *
jpeg_marker_get_description(JPEGMarker marker)112 jpeg_marker_get_description (JPEGMarker marker)
113 {
114 unsigned int i;
115
116 for (i = 0; JPEGMarkerTable[i].description; i++)
117 if (JPEGMarkerTable[i].marker == marker)
118 break;
119
120 return (JPEGMarkerTable[i].description);
121 }
122
123