Files
ppsspp/Common/Data/Format/RIFF.h

42 lines
754 B
C
Raw Permalink Normal View History

2012-03-24 23:39:19 +01:00
#pragma once
// 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
class RIFFReader {
2012-03-24 23:39:19 +01:00
public:
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;
};
ChunkInfo stack[32];
uint8_t *data_;
int pos_ = 0;
int eof_ = 0; // really end of current block
2017-12-04 17:33:42 +01:00
int depth_ = 0;
int fileSize_ = 0;
2012-03-24 23:39:19 +01:00
};