#ifndef WC3RE_MVEDECODER_HH__ #define WC3RE_MVEDECODER_HH__ #include #include #include "IffFile.hh" class MveDecoder { public: MveDecoder(uint8_t const* base, size_t length); size_t numBranches() const { return branches_.size(); } using Frame = std::vector; using Audio = std::vector; using Palette = std::array; private: using AUDIVec = std::vector; using VGAVec = std::vector; struct Shot { Palette const& palt; AUDIVec AUDIs; VGAVec VGAs; }; public: class Movie { public: bool hasNext() const; std::tuple decodeNext(); bool hasAudio() const; Audio getNextAudio(); unsigned getWidth() const; unsigned getHeight() const; private: Movie(std::vector::const_iterator shotIt, std::vector::const_iterator shotEnd, MveDecoder const& mve); std::vector::const_iterator shotIt_, shotEnd_; VGAVec::const_iterator frameIt_; AUDIVec::const_iterator audioIt_; Frame frame_; MveDecoder const& mve_; friend class MveDecoder; }; Movie open(size_t branch) const; private: IffFile iff_; unsigned width_, height_; std::vector palts_; std::vector > branches_; Frame parseVGA(IffFile::Object const& vga, Frame const* prev) const; friend struct AudioCBData; }; #endif