forked from soiaf/C-Sharp-WavPack-Decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChunkHeader.cs
47 lines (40 loc) · 835 Bytes
/
ChunkHeader.cs
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
/*
** ChunkHeader.cs
**
** Copyright (c) 2010-2016 Peter McQuillan
**
** All Rights Reserved.
**
** Distributed under the BSD Software License (see license.txt)
***/
namespace WavPack.Decoder
{
class ChunkHeader
{
internal const uint Size = 8;
internal char[] ckID = new char[4];
internal uint ckSize;
public ChunkHeader(string id, uint size)
{
ckID[0] = id[0];
ckID[1] = id[1];
ckID[2] = id[2];
ckID[3] = id[3];
ckSize = size;
}
internal virtual byte[] AsBytes()
{
byte[] bytes = new byte[Size];
bytes[0] = (byte)ckID[0];
bytes[1] = (byte)ckID[1];
bytes[2] = (byte)ckID[2];
bytes[3] = (byte)ckID[3];
// swap endians here
bytes[7] = (byte)(ckSize >> 24);
bytes[6] = (byte)(ckSize >> 16);
bytes[5] = (byte)(ckSize >> 8);
bytes[4] = (byte)ckSize;
return bytes;
}
}
}