Mercurial > hg > forks > geeqie
comparison src/jpeg_parser.c @ 1977:af653599660d lm
More use of const, fix up a warning.
author | Laurent Monin <zas@norz.org> |
---|---|
date | Mon, 14 May 2012 23:01:01 +0200 |
parents | 4417578c55f9 |
children | 8a09320fe8a7 |
comparison
equal
deleted
inserted
replaced
1976:e9ebd12f68f7 | 1977:af653599660d |
---|---|
11 */ | 11 */ |
12 | 12 |
13 #include "main.h" | 13 #include "main.h" |
14 #include "jpeg_parser.h" | 14 #include "jpeg_parser.h" |
15 | 15 |
16 gboolean jpeg_segment_find(guchar *data, guint size, | 16 gboolean jpeg_segment_find(const guchar *data, guint size, |
17 guchar app_marker, const gchar *magic, guint magic_len, | 17 guchar app_marker, const gchar *magic, guint magic_len, |
18 guint *seg_offset, guint *seg_length) | 18 guint *seg_offset, guint *seg_length) |
19 { | 19 { |
20 guchar marker = 0; | 20 guchar marker = 0; |
21 guint offset = 0; | 21 guint offset = 0; |
62 #define TIFF_TIFD_OFFSET_DATA 8 | 62 #define TIFF_TIFD_OFFSET_DATA 8 |
63 #define TIFF_TIFD_SIZE 12 | 63 #define TIFF_TIFD_SIZE 12 |
64 | 64 |
65 | 65 |
66 | 66 |
67 guint16 tiff_byte_get_int16(guchar *f, TiffByteOrder bo) | 67 guint16 tiff_byte_get_int16(const guchar *f, TiffByteOrder bo) |
68 { | 68 { |
69 guint16 align_buf; | 69 guint16 align_buf; |
70 | 70 |
71 memcpy(&align_buf, f, sizeof(guint16)); | 71 memcpy(&align_buf, f, sizeof(guint16)); |
72 | 72 |
74 return GUINT16_FROM_LE(align_buf); | 74 return GUINT16_FROM_LE(align_buf); |
75 else | 75 else |
76 return GUINT16_FROM_BE(align_buf); | 76 return GUINT16_FROM_BE(align_buf); |
77 } | 77 } |
78 | 78 |
79 guint32 tiff_byte_get_int32(guchar *f, TiffByteOrder bo) | 79 guint32 tiff_byte_get_int32(const guchar *f, TiffByteOrder bo) |
80 { | 80 { |
81 guint32 align_buf; | 81 guint32 align_buf; |
82 | 82 |
83 memcpy(&align_buf, f, sizeof(guint32)); | 83 memcpy(&align_buf, f, sizeof(guint32)); |
84 | 84 |
118 } | 118 } |
119 | 119 |
120 memcpy(f, &align_buf, sizeof(guint32)); | 120 memcpy(f, &align_buf, sizeof(guint32)); |
121 } | 121 } |
122 | 122 |
123 gint tiff_directory_offset(guchar *data, const guint len, | 123 gint tiff_directory_offset(const guchar *data, const guint len, |
124 guint *offset, TiffByteOrder *bo) | 124 guint *offset, TiffByteOrder *bo) |
125 { | 125 { |
126 if (len < 8) return FALSE; | 126 if (len < 8) return FALSE; |
127 | 127 |
128 if (memcmp(data, "II", 2) == 0) | 128 if (memcmp(data, "II", 2) == 0) |
146 *offset = tiff_byte_get_int32(data + 4, *bo); | 146 *offset = tiff_byte_get_int32(data + 4, *bo); |
147 | 147 |
148 return (*offset < len); | 148 return (*offset < len); |
149 } | 149 } |
150 | 150 |
151 typedef gint (* FuncParseIFDEntry)(guchar *tiff, guint offset, | 151 typedef gint (* FuncParseIFDEntry)(const guchar *tiff, guint offset, |
152 guint size, TiffByteOrder bo, | 152 guint size, TiffByteOrder bo, |
153 gpointer data); | 153 gpointer data); |
154 | 154 |
155 | 155 |
156 gint tiff_parse_IFD_table(guchar *tiff, guint offset, | 156 gint tiff_parse_IFD_table(const guchar *tiff, guint offset, |
157 guint size, TiffByteOrder bo, | 157 guint size, TiffByteOrder bo, |
158 guint *next_offset, | 158 guint *next_offset, |
159 FuncParseIFDEntry parse_entry, gpointer data) | 159 FuncParseIFDEntry parse_entry, gpointer data) |
160 { | 160 { |
161 guint count; | 161 guint count; |
180 if (next_offset) *next_offset = next; | 180 if (next_offset) *next_offset = next; |
181 | 181 |
182 return 0; | 182 return 0; |
183 } | 183 } |
184 | 184 |
185 static gint mpo_parse_Index_IFD_entry(guchar *tiff, guint offset, | 185 static gint mpo_parse_Index_IFD_entry(const guchar *tiff, guint offset, |
186 guint size, TiffByteOrder bo, | 186 guint size, TiffByteOrder bo, |
187 gpointer data) | 187 gpointer data) |
188 { | 188 { |
189 guint tag; | 189 guint tag; |
190 guint format; | 190 guint format; |
252 } | 252 } |
253 | 253 |
254 return 0; | 254 return 0; |
255 } | 255 } |
256 | 256 |
257 static gint mpo_parse_Attributes_IFD_entry(guchar *tiff, guint offset, | 257 static gint mpo_parse_Attributes_IFD_entry(const guchar *tiff, guint offset, |
258 guint size, TiffByteOrder bo, | 258 guint size, TiffByteOrder bo, |
259 gpointer data) | 259 gpointer data) |
260 { | 260 { |
261 guint tag; | 261 guint tag; |
262 guint format; | 262 guint format; |
308 } | 308 } |
309 | 309 |
310 return 0; | 310 return 0; |
311 } | 311 } |
312 | 312 |
313 MPOData *jpeg_get_mpo_data(guchar *data, guint size) | 313 MPOData *jpeg_get_mpo_data(const guchar *data, guint size) |
314 { | 314 { |
315 guint seg_offset; | 315 guint seg_offset; |
316 guint seg_size; | 316 guint seg_size; |
317 if (jpeg_segment_find(data, size, JPEG_MARKER_APP2, "MPF\x00", 4, &seg_offset, &seg_size) && seg_size >16) | 317 if (jpeg_segment_find(data, size, JPEG_MARKER_APP2, "MPF\x00", 4, &seg_offset, &seg_size) && seg_size >16) |
318 { | 318 { |