2012-03-24 23:39:19 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-10-04 00:25:21 +02:00
|
|
|
// Simple RIFF file format reader.
|
2020-09-29 10:07:07 +02:00
|
|
|
// Unrelated to the ChunkFile.h used in Dolphin and PPSSPP.
|
2012-03-31 11:16:13 +02:00
|
|
|
|
|
|
|
|
// TO REMEMBER WHEN USING:
|
|
|
|
|
|
|
|
|
|
// EITHER a chunk contains ONLY data
|
|
|
|
|
// OR it contains ONLY other chunks
|
2012-07-15 17:38:03 +02:00
|
|
|
// otherwise the scheme breaks.
|
2012-03-31 11:16:13 +02:00
|
|
|
|
2017-12-04 17:33:42 +01:00
|
|
|
#include <cstdint>
|
2012-03-24 23:39:19 +01:00
|
|
|
|
2017-12-04 17:27:47 +01:00
|
|
|
class RIFFReader {
|
2012-03-24 23:39:19 +01:00
|
|
|
public:
|
2017-12-04 17:27:47 +01:00
|
|
|
RIFFReader(const uint8_t *data, int dataSize);
|
|
|
|
|
~RIFFReader();
|
2012-03-24 23:39:19 +01:00
|
|
|
|
2017-12-04 17:33:42 +01:00
|
|
|
bool Descend(uint32_t id);
|
|
|
|
|
void Ascend();
|
2012-03-24 23:39:19 +01:00
|
|
|
|
2017-12-04 17:33:42 +01:00
|
|
|
int ReadInt();
|
|
|
|
|
void ReadData(void *data, int count);
|
2012-03-24 23:39:19 +01:00
|
|
|
|
2017-12-04 17:33:42 +01:00
|
|
|
int GetCurrentChunkSize();
|
2012-03-24 23:39:19 +01:00
|
|
|
|
|
|
|
|
private:
|
2012-10-31 13:23:16 +01:00
|
|
|
struct ChunkInfo {
|
|
|
|
|
int startLocation;
|
|
|
|
|
int parentStartLocation;
|
|
|
|
|
int parentEOF;
|
2017-12-04 17:33:42 +01:00
|
|
|
uint32_t ID;
|
2012-10-31 13:23:16 +01:00
|
|
|
int length;
|
|
|
|
|
};
|
2016-12-01 22:07:03 +01:00
|
|
|
ChunkInfo stack[32];
|
2017-12-04 17:23:29 +01:00
|
|
|
uint8_t *data_;
|
|
|
|
|
int pos_ = 0;
|
2017-12-04 18:01:51 +01:00
|
|
|
int eof_ = 0; // really end of current block
|
2017-12-04 17:33:42 +01:00
|
|
|
int depth_ = 0;
|
2017-12-04 18:01:51 +01:00
|
|
|
int fileSize_ = 0;
|
2012-03-24 23:39:19 +01:00
|
|
|
};
|