//----------------------------------------------------------------------------- // // Musepack Demuxer // // Author : Igor Janos // //----------------------------------------------------------------------------- #pragma once class CMPCReader; //----------------------------------------------------------------------------- // // CMPCPacket // //----------------------------------------------------------------------------- class CMPCPacket { public: int64 file_position; // absolute file position (in bits) uint8 *packet; // we own this one uint8 *payload; // just a pointer int32 packet_size; // whole packet size int32 payload_size; // only the payload uint16 key; // parsed key value REFERENCE_TIME tStart, tStop; // to be used later public: CMPCPacket(); virtual ~CMPCPacket(); // loading packets int Load_SV7(CMPCReader *reader, int &bits_to_skip, bool only_parse=false); int Load(CMPCReader *reader); void Release(); }; //----------------------------------------------------------------------------- // // CMPCChapter // //----------------------------------------------------------------------------- class CMPCChapter { public: int64 sample_offset; float chapter_gain_db; float chapter_peak_db; CString caption; public: CMPCChapter(); virtual ~CMPCChapter(); int Load(CMPCPacket *packet); }; //----------------------------------------------------------------------------- // // CMPCFile class // //----------------------------------------------------------------------------- class CMPCFile { public: // stream header __int64 duration_10mhz; // total file duration int stream_version; // 7, 8 are supported int sample_rate; int channels; int audio_block_frames; int block_pwr; int seek_pwr; uint8 true_gapless; uint8 fast_seeking; // replay gain float gain_title_db; float gain_title_peak_db; float gain_album_db; float gain_album_peak_db; // seeking table int64 seek_table_position; // position of seeking table in file (in bits) int64 header_position; // (in bits) uint64 *seek_table; int64 seek_table_size; // current position int64 total_samples; int64 current_sample; // internals CMPCReader *reader; // file reader interface int bits_to_skip; // after seeking // buffer for decoder specific info uint8 *extradata; int extradata_max_size; // total size int extradata_size; // current size of extradata // APE Tags APE_Tag tag; // chapters vector chapters; int Open_SV8(); int Open_SV7(); public: CMPCFile(); virtual ~CMPCFile(); // I/O for MPC file int Open(CMPCReader *reader); void ClearChapters(); // parsing packets int ReadStreamHeader(CMPCPacket *packet); int ReadReplaygain(CMPCPacket *packet); int ReadSeekOffset(CMPCPacket *packet); int ReadSeekTable(CMPCPacket *packet); void StoreExtraDataPacket(CMPCPacket *packet); // parsing out packets int ReadAudioPacket(CMPCPacket *packet, int64 *cur_sample); int Seek(int64 seek_sample); };