-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDSSubcode.h
153 lines (131 loc) · 3.93 KB
/
DDSSubcode.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//
// Copyright 2018, Jeremy Cooper
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef RDAT_DDS_SUBCODE_H
#define RDAT_DDS_SUBCODE_H
#include <stdint.h>
//
// Helper classes for decoding various sub-codes used by the DDS
// standard.
//
class DDSSubcodePack {
protected:
DDSSubcodePack() : mValid(false) {};
~DDSSubcodePack() {};
public:
bool IsValid() const { return mValid; };
protected:
bool mValid;
};
//
// 9.4.1 Pack Item No. 1
//
// Describes the current running file number (separator 1) and
// the current running basic group (~128k of data) in that file.
//
class DDSSubcodePack1 : public DDSSubcodePack {
public:
DDSSubcodePack1() {};
static const unsigned int kID = 1;
void Decode(const uint8_t *bytes);
uint8_t mPosition;
uint16_t mGroup;
uint32_t mSeparator1Count;
};
//
// 9.4.2 Pack Item No. 2
//
// Describes the current running separator 2 count (not used in UNIX)
// and record count.
//
class DDSSubcodePack2 : public DDSSubcodePack {
public:
DDSSubcodePack2() {};
static const unsigned int kID = 2;
void Decode(const uint8_t *bytes);
uint8_t mRepetitions;
uint16_t mSeparator2Count;
uint32_t mRecordCount;
};
//
// 9.4.3 Pack Item No. 3
//
// Describes the absolute frame number of this frame (unique for the
// whole tape) and the logical frame number (relative to current basic
// group). It also contains two of the four super-redundant data column
// checksum values for this frame.
//
class DDSSubcodePack3 : public DDSSubcodePack {
public:
DDSSubcodePack3() {};
static const unsigned int kID = 3;
void Decode(const uint8_t *bytes);
uint8_t mPartitionID;
uint8_t mAreaID;
uint32_t mAbsoluteFrameID;
uint8_t mChecksum1;
uint8_t mChecksum2;
uint8_t mLogicalFrameID;
bool mIsLastLogicalFrame;
bool mIsECC3Frame;
};
//
// 9.4.4 Pack Item No. 4
//
// Mostly redundant with pack 3 but it contains the two remaining
// column checksum values.
//
class DDSSubcodePack4 : public DDSSubcodePack {
public:
DDSSubcodePack4() {};
static const unsigned int kID = 4;
void Decode(const uint8_t *bytes);
uint8_t mPartitionID;
uint8_t mAreaID;
uint32_t mAbsoluteFrameID;
uint8_t mChecksum3;
uint8_t mChecksum4;
uint8_t mLogicalFrameID;
bool mIsLastLogicalFrame;
bool mIsECC3Frame;
};
//
// 9.4.5 Pack Item No. 5
//
// This is a statistics frame that should only appear in the system
// area of the tape (I think). It gives a summary of what was written.
//
class DDSSubcodePack5 : public DDSSubcodePack {
public:
DDSSubcodePack5() {};
static const unsigned int kID = 5;
void Decode(const uint8_t *bytes);
uint32_t mLastRecordedDataGroups;
uint32_t mTotalRecordedDataGroups;
};
#endif