Files
wc3re/MveDecoder.hh

83 lines
1.7 KiB
C++

#ifndef WC3RE_MVEDECODER_HH__
#define WC3RE_MVEDECODER_HH__
#include <vector>
#include <array>
#include "IffFile.hh"
class MveDecoder {
public:
MveDecoder(std::string const& path);
MveDecoder(IffFile::Handle iff);
size_t numBranches() const {
return branches_.size();
}
using Frame = std::vector<uint8_t>;
using Audio = std::vector<int16_t>;
using Palette = std::array<uint8_t, 768>;
private:
using AUDIVec = std::vector<IffFile::Object const*>;
using VGAVec = std::vector<IffFile::Object const*>;
struct Shot {
Palette const& palt;
AUDIVec AUDIs;
VGAVec VGAs;
};
public:
class Movie {
public:
bool hasNext() const;
std::tuple<Frame const&, Palette const&> decodeNext();
~Movie();
bool hasAudio() const;
Audio getNextAudio();
unsigned getWidth() const;
unsigned getHeight() const;
private:
Movie(std::vector<Shot>::const_iterator shotIt,
std::vector<Shot>::const_iterator shotEnd,
MveDecoder const& mve);
void parseVGA(IffFile::Object const& vga);
std::vector<Shot>::const_iterator shotIt_, shotEnd_;
VGAVec::const_iterator frameIt_;
AUDIVec::const_iterator audioIt_;
Frame frame_;
MveDecoder const& mve_;
// Buffers for frame decoding
std::vector<uint8_t> pixelBuf_;
Frame frameBuf_;
std::vector<char> commandBuf_;
// Buffer usage stats
size_t maxPixel_, maxCommand_;
friend class MveDecoder;
};
Movie open(size_t branch) const;
private:
IffFile::Handle iff_;
unsigned width_, height_;
std::vector<Palette> palts_;
std::vector<std::vector<Shot> > branches_;
friend struct AudioCBData;
};
#endif