Bug fix: Run-time errors when removing a toolbar icon
[geeqie.git] / src / jpeg-parser.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: Vladimir Nadvornik
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef JPEG_PARSER_H
23 #define JPEG_PARSER_H
24
25 #define JPEG_MARKER             0xFF
26 #define JPEG_MARKER_SOI         0xD8
27 #define JPEG_MARKER_EOI         0xD9
28 #define JPEG_MARKER_APP1        0xE1
29 #define JPEG_MARKER_APP2        0xE2
30
31 /* jpeg container format:
32      all data markers start with 0XFF
33      2 byte long file start and end markers: 0xFFD8(SOI) and 0XFFD9(EOI)
34      4 byte long data segment markers in format: 0xFFTTSSSSNNN...
35        FF:   1 byte standard marker identifier
36        TT:   1 byte data type
37        SSSS: 2 bytes in Motorola byte alignment for length of the data.
38              This value includes these 2 bytes in the count, making actual
39              length of NN... == SSSS - 2.
40        NNN.: the data in this segment
41  */
42
43 gboolean jpeg_segment_find(const guchar *data, guint size,
44                             guchar app_marker, const gchar *magic, guint magic_len,
45                             guint *seg_offset, guint *seg_length);
46
47
48 struct MPOEntry {
49         guint type_code;
50         gboolean representative;
51         gboolean dependent_child;
52         gboolean dependent_parent;
53         guint offset;
54         guint length;
55         guint dep1;
56         guint dep2;
57
58         guint MPFVersion;
59         guint MPIndividualNum;
60         guint PanOrientation;
61         double PanOverlap_H;
62         double PanOverlap_V;
63         guint BaseViewpointNum;
64         double ConvergenceAngle;
65         double BaselineLength;
66         double VerticalDivergence;
67         double AxisDistance_X;
68         double AxisDistance_Y;
69         double AxisDistance_Z;
70         double YawAngle;
71         double PitchAngle;
72         double RollAngle;
73 };
74
75
76 struct MPOData {
77         guint mpo_offset;
78
79         guint version;
80         guint num_images;
81         MPOEntry *images;
82 };
83
84 MPOData* jpeg_get_mpo_data(const guchar *data, guint size);
85 void jpeg_mpo_data_free(MPOData *mpo);
86
87 #endif
88
89 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */