#ifndef WC3RE_MVEDECODER_HH__ #define WC3RE_MVEDECODER_HH__ #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; 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(); ~Movie(); 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); void parseVGA(IffFile::Object const& vga); std::vector::const_iterator shotIt_, shotEnd_; VGAVec::const_iterator frameIt_; AUDIVec::const_iterator audioIt_; Frame frame_; MveDecoder const& mve_; // Buffers for frame decoding std::vector pixelBuf_; Frame frameBuf_; std::vector 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 palts_; std::vector > branches_; friend struct AudioCBData; }; #endif