CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/Data/Format/RIFF.h
Views: 1401
1
#pragma once
2
3
// Simple RIFF file format reader.
4
// Unrelated to the ChunkFile.h used in Dolphin and PPSSPP.
5
6
// TO REMEMBER WHEN USING:
7
8
// EITHER a chunk contains ONLY data
9
// OR it contains ONLY other chunks
10
// otherwise the scheme breaks.
11
12
#include <cstdint>
13
14
class RIFFReader {
15
public:
16
RIFFReader(const uint8_t *data, int dataSize);
17
~RIFFReader();
18
19
bool Descend(uint32_t id);
20
void Ascend();
21
22
int ReadInt();
23
void ReadData(void *data, int count);
24
25
int GetCurrentChunkSize();
26
27
private:
28
struct ChunkInfo {
29
int startLocation;
30
int parentStartLocation;
31
int parentEOF;
32
uint32_t ID;
33
int length;
34
};
35
ChunkInfo stack[32];
36
uint8_t *data_;
37
int pos_ = 0;
38
int eof_ = 0; // really end of current block
39
int depth_ = 0;
40
int fileSize_ = 0;
41
};
42
43