-
Notifications
You must be signed in to change notification settings - Fork 1
/
cameratypes.h
111 lines (89 loc) · 2.17 KB
/
cameratypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef CAMERATYPES_H
#define CAMERATYPES_H
#include <QObject>
namespace CutePocket
{
Q_NAMESPACE
typedef union
{
quint16 u16;
quint8 u8[2];
} U16_U8;
typedef union
{
qint16 s16;
qint8 u8[2];
} S16_S8;
typedef union
{
quint32 u32;
quint16 u16[2];
quint8 u8[4];
} U32_U8;
typedef union
{
qint32 s32;
quint8 u8[4];
} S32_U8;
typedef union
{
qint32 s32;
qint8 s8[4];
} S32_S8;
typedef union
{
qint64 s64;
qint8 s8[8];
} S64_S8;
inline quint16 uint16at(const QByteArray &ba, int p) {
CutePocket::U16_U8 val;
val.u8[0] = static_cast<quint8>(ba.at(p));
val.u8[1] = static_cast<quint8>(ba.at(p+1));
return val.u16;
};
inline qint16 int16at(const QByteArray &ba, int p) {
CutePocket::S16_S8 val;
val.u8[0] = static_cast<qint8>(ba.at(p));
val.u8[1] = static_cast<qint8>(ba.at(p+1));
return val.s16;
};
inline quint32 uint32at(const QByteArray &ba, int p) {
CutePocket::U32_U8 val;
val.u8[3] = static_cast<quint8>(ba.at(p));
val.u8[2] = static_cast<quint8>(ba.at(p+1));
val.u8[1] = static_cast<quint8>(ba.at(p+2));
val.u8[0] = static_cast<quint8>(ba.at(p+3));
return val.u32;
};
inline qint32 int32at(const QByteArray &ba, int p) {
CutePocket::S32_U8 val;
val.u8[0] = static_cast<quint8>(ba.at(p));
val.u8[1] = static_cast<quint8>(ba.at(p+1));
val.u8[2] = static_cast<quint8>(ba.at(p+2));
val.u8[3] = static_cast<quint8>(ba.at(p+3));
return val.s32;
};
inline qint64 int64at(const QByteArray &ba, int p) {
CutePocket::S64_S8 val;
val.s8[7] = static_cast<qint8>(ba.at(p));
val.s8[6] = static_cast<qint8>(ba.at(p+1));
val.s8[5] = static_cast<qint8>(ba.at(p+2));
val.s8[4] = static_cast<qint8>(ba.at(p+3));
val.s8[3] = static_cast<qint8>(ba.at(p+4));
val.s8[2] = static_cast<qint8>(ba.at(p+5));
val.s8[1] = static_cast<qint8>(ba.at(p+6));
val.s8[0] = static_cast<qint8>(ba.at(p+7));
return val.s64;
};
inline bool boolat(const QByteArray &ba, int p) {
return static_cast<bool>(ba.at(p));
};
enum MediaType
{
StillMedia = 1,
ClipMedia = 2,
SoundMedia = 3
};
Q_ENUM_NS(MediaType)
}
#endif // CAMERATYPES_H