Collaboration diagram for MP3Frame:
Public Types | |
enum | { nowrite, fastwrite, normal } |
Public Member Functions | |
MP3Frame (MP3Stream *stream, MP3Frame *prev=0) | |
~MP3Frame () | |
MP3Frame * | Destroy () |
MP3Frame * | Next () |
void | Write (Bitstream &bs) |
void | SetDataBegin (int startpos) |
void | Enlarge (int num) |
void | WriteData (Bitstream &bs, MP3Frame *frame, int cutstart, int cutend) |
void | SetFirst () |
bool | isLocked () const |
bool | CorruptionFound () const |
int | Bitrate () const |
int | DataSize () const |
void | ChangeGain (int n) |
bool | isSilent () const |
void | ShowInfo (std::ostream &str) const |
Implements operations with MP3 Frames, creates a linked list of frames, works in cooperation with MP3Stream.
Most complexity is hidden here: MP3 files have so-called "bit reservoir". Frame data can be stored in few previous frames, so when a frame is written you have to work with 3 frames: the one you are writing, another one from which you write data and a third one where the data really are.
This class handles that, see function Write().
Definition at line 35 of file mp3frame.h.
|
Write mode
Definition at line 40 of file mp3frame.h. |
|
Constructor. Reads data from MP3Stream, skips corrupted frames, so it always constructs an correct frame. EOF condition is handled in Bitstream via exceptions.
Definition at line 17 of file mp3frame.cpp. Referenced by Next(). |
|
Destructor Definition at line 35 of file mp3frame.cpp. |
|
Get frame's bitrate
Definition at line 356 of file mp3frame.cpp. References FrameHeader::Bitrate(). |
|
Change volume of frame
Definition at line 366 of file mp3frame.cpp. References ChannelHeader::ChangeGain(), and FrameHeader::NumChannels(). |
|
Whether there was some corruption before frame Constructor always construct a valid frame, but records if there was some problem (with synchronization, invalid header, etc.).
Definition at line 351 of file mp3frame.cpp. |
|
Number of bytes of data beloning to frame These are not bytes in the frame, but data belonging to frame, which can be in a few preceding frames.
Definition at line 361 of file mp3frame.cpp. Referenced by MP3Stream::WriteData(), and WriteData(). |
|
Deletes itself and returns next frame.
Definition at line 181 of file mp3frame.cpp. Referenced by MP3Stream::SeekTo(), and MP3Stream::~MP3Stream(). |
|
Changes bitrate of frame in order to resize it. When data in stream are moved forward (eg. when small frames on beginning are removed), sometimes they would overflow to next frame, which is forbidden. So the frame has to be resized by changing its bitrate.
Definition at line 263 of file mp3frame.cpp. References FrameHeader::Bitrate(), FrameHeader::Enlarge(), and FrameHeader::FrameSize(). Referenced by Write(). |
|
Whether frame is locked (can't be deleted) It's was possible that Write() on some frame dealocated that frame, so i had to implement locking mechanism (only used in Write() in normal mode). MP3Stream::SeekTo() checks whether frame is locked, but not Destroy().
Definition at line 346 of file mp3frame.cpp. Referenced by MP3Stream::SeekTo(). |
|
Whether frame is completely silent It detects just digital silence acording to data size. Anything else would require decompression of audio.
Definition at line 374 of file mp3frame.cpp. References ChannelHeader::DataSize(), and FrameHeader::NumChannels(). |
|
Returns next frame (and reads it if it does not exist).
Definition at line 192 of file mp3frame.cpp. References MP3Frame(). Referenced by MP3Iterator::operator++(), and MP3Stream::WriteData(). |
|
Calculates offset of frame data. The offset is difference between position of frame in stream and the position of its first byte (which can be up to mp3::max_databegin lower). When the offset should be higher than mp3::max_databegin, padding bytes are added.
Definition at line 248 of file mp3frame.cpp. References DataHeader::MaxDataBegin(). Referenced by MP3Stream::WriteData(). |
|
Makes this frame first in stream. Needed when frames at the beginning are removed, because Write() on some next frame would cause data from removed frames being written. It don't delete any frames, because they can keep data of the new first frame. Definition at line 341 of file mp3frame.cpp. References MP3Stream::SetFirst(). |
|
Write frame information Writes version, layer, bitrate, etc.
Definition at line 386 of file mp3frame.cpp. References FrameHeader::Bitrate(), FrameHeader::Frequency(), FrameHeader::isIntensStereo(), FrameHeader::isMSstereo(), FrameHeader::isValid(), FrameHeader::Layer(), FrameHeader::Mode(), and FrameHeader::Version(). |
|
Write the frame with data. Action depends on write mode of MP3Stream. In fastwrite mode it simply writes data in this frame. In normal mode it calls MP3Stream::WriteData() with number of bytes it needs. It locks the frame so it won't be deallocated.
Definition at line 216 of file mp3frame.cpp. References Enlarge(), fastwrite, nowrite, DataHeader::SetDataBegin(), AudioData::Write(), MP3Stream::WriteData(), and MP3Stream::WriteMode(). |
|
Gets data belonging to frame from stream (ie. not data in the stream) and writes them. Parameters cutstart and cutend are used to write only a part of frame so it fits to data part of other frame.
Definition at line 280 of file mp3frame.cpp. References DataSize(), m_data, m_next, m_spacesize, m_totalbytes, MP3Stream::SeekTo(), AudioData::Write(), and Bitstream::WriteNullBytes(). Referenced by MP3Stream::WriteData(). |