kwave
18.07.70
|
#include <RIFFChunk.h>
Public Types | |
enum | ChunkType { Root, Main, Sub, Garbage, Empty } |
Public Member Functions | |
RIFFChunk (Kwave::RIFFChunk *parent, const QByteArray &name, const QByteArray &format, quint32 length, quint32 phys_offset, quint32 phys_length) | |
virtual | ~RIFFChunk () |
bool | isSane () const |
ChunkType | type () const |
void | setType (ChunkType type) |
const QByteArray & | name () const |
const QByteArray & | format () const |
void | setFormat (const QByteArray &format) |
Kwave::RIFFChunk * | parent () const |
const QByteArray | path () const |
quint32 | dataStart () const |
quint32 | dataLength () const |
quint32 | length () const |
void | setLength (quint32 length) |
quint32 | physStart () const |
quint32 | physEnd () const |
quint32 | physLength () const |
Kwave::RIFFChunkList & | subChunks () |
const Kwave::RIFFChunkList & | subChunks () const |
bool | isChildOf (Kwave::RIFFChunk *chunk) |
void | fixSize () |
void | dumpStructure () |
Private Attributes | |
ChunkType | m_type |
QByteArray | m_name |
QByteArray | m_format |
Kwave::RIFFChunk * | m_parent |
quint32 | m_chunk_length |
quint32 | m_phys_offset |
quint32 | m_phys_length |
Kwave::RIFFChunkList | m_sub_chunks |
Stores information about a RIFF chunk, containing name, type, position in the source and length.
Definition at line 39 of file RIFFChunk.h.
State of a chunk. Most are a sub-chunks. If one is known to contain further sub-chunks, it is marked as a main chunk. main and sub chunks always have a valid name and some length information, but might be truncated. If the name is not valid, the chunk is considered to contain only garbage. If the name is valid but there is no length information the chunk is marked as "empty".
Enumerator | |
---|---|
Root | virtual root node of the RIFF structure |
Main | contains sub-chunks |
Sub | valid/sane sub-chunk |
Garbage | no or invalid name |
Empty | valid name, but no size |
Definition at line 50 of file RIFFChunk.h.
Kwave::RIFFChunk::RIFFChunk | ( | Kwave::RIFFChunk * | parent, |
const QByteArray & | name, | ||
const QByteArray & | format, | ||
quint32 | length, | ||
quint32 | phys_offset, | ||
quint32 | phys_length | ||
) |
Constructor.
parent | pointer to the parent node (or null if root node) |
name | the 4-byte name of the chunk |
format | the 4-byte format specifier, only valid for main chunks, contains invalid data in sub-chunks |
length | size of the chunk's data |
phys_offset | start of the chunk name in the source |
phys_length | length allocated in the source (file) |
Definition at line 28 of file RIFFChunk.cpp.
|
virtual |
Destructor
Definition at line 38 of file RIFFChunk.cpp.
References m_sub_chunks.
quint32 Kwave::RIFFChunk::dataLength | ( | ) | const |
Returns the physical length of the chunk's data
Definition at line 136 of file RIFFChunk.cpp.
References m_chunk_length, m_type, and Main.
Referenced by isSane(), Kwave::RIFFParser::joinGarbageToEmpty(), Kwave::WavDecoder::open(), parent(), Kwave::RIFFParser::parse(), and Kwave::WavDecoder::repairChunk().
quint32 Kwave::RIFFChunk::dataStart | ( | ) | const |
Returns the offset where the chunk's data starts.
Definition at line 130 of file RIFFChunk.cpp.
References m_phys_offset, m_type, and Main.
Referenced by Kwave::RIFFParser::joinGarbageToEmpty(), Kwave::WavDecoder::open(), parent(), Kwave::RIFFParser::parse(), and Kwave::WavDecoder::repairChunk().
void Kwave::RIFFChunk::dumpStructure | ( | ) |
Dumps the structure of this chunks and all sub-chunks, useful for debugging.
Definition at line 203 of file RIFFChunk.cpp.
References dumpStructure(), Empty, Garbage, length(), m_phys_offset, m_sub_chunks, m_type, Main, path(), physEnd(), physLength(), Root, and Sub.
Referenced by Kwave::RIFFParser::dumpStructure(), dumpStructure(), and subChunks().
void Kwave::RIFFChunk::fixSize | ( | ) |
Fixes descrepancies in the size of the chunk. The new size will be computed as the size of all sub-chunks (that will be recursively fixed too) plus the own header.
Definition at line 158 of file RIFFChunk.cpp.
References fixSize(), m_chunk_length, m_phys_length, m_type, Main, path(), physEnd(), physStart(), Root, and subChunks().
Referenced by fixSize(), Kwave::WavDecoder::repair(), and subChunks().
|
inline |
Returns the chunk's format string.
Definition at line 97 of file RIFFChunk.h.
References m_format.
Referenced by path(), Kwave::WavDecoder::repairChunk(), and setFormat().
bool Kwave::RIFFChunk::isChildOf | ( | Kwave::RIFFChunk * | chunk | ) |
Returns true if the given chunk is a parent of us.
Definition at line 149 of file RIFFChunk.cpp.
References isChildOf(), m_parent, m_type, and Root.
Referenced by Kwave::RIFFParser::fixGarbageEnds(), isChildOf(), and subChunks().
bool Kwave::RIFFChunk::isSane | ( | ) | const |
Returns true if the file chunk no structural errors and no garbage or empty chunks.
Definition at line 49 of file RIFFChunk.cpp.
References CHECK, dataLength(), Empty, Garbage, isSane(), m_phys_length, m_sub_chunks, m_type, Main, path(), Root, and subChunks().
Referenced by Kwave::RIFFParser::isSane(), and isSane().
|
inline |
Returns the length of the chunk in bytes, like stated in the head of the chunk. Includes the format when it's a main chunk.
Definition at line 123 of file RIFFChunk.h.
References m_chunk_length, and setLength().
Referenced by dumpStructure(), Kwave::WavDecoder::open(), and setLength().
|
inline |
Returns the 4-character name of the chunk
Definition at line 91 of file RIFFChunk.h.
References m_name.
Referenced by Kwave::RIFFParser::chunkCount(), Kwave::RIFFParser::findChunk(), Kwave::RIFFParser::fixGarbageEnds(), Kwave::RIFFParser::joinGarbageToEmpty(), Kwave::WavDecoder::open(), Kwave::RIFFParser::parse(), path(), Kwave::WavDecoder::repair(), and Kwave::WavDecoder::repairChunk().
|
inline |
Returns the pointer to the parent node
Definition at line 103 of file RIFFChunk.h.
References dataLength(), dataStart(), m_parent, and path().
Referenced by Kwave::RIFFParser::addChunk(), and Kwave::RIFFParser::joinGarbageToEmpty().
const QByteArray Kwave::RIFFChunk::path | ( | ) | const |
Returns the full path of this node. If the node is a "Main" chunk and has a format parameter, the format is appended, separated with a ":". If the chunk name is not unique within it's parents the zero based index is appended within round brackets.
Definition at line 88 of file RIFFChunk.cpp.
References format(), m_format, m_name, m_parent, m_type, Main, name(), path(), subChunks(), and type().
Referenced by Kwave::RIFFParser::chunkCount(), dumpStructure(), Kwave::RIFFParser::findChunk(), fixSize(), isSane(), parent(), Kwave::RIFFParser::parse(), and path().
quint32 Kwave::RIFFChunk::physEnd | ( | ) | const |
Returns the offset in the source (file) where the chunk ends.
Definition at line 79 of file RIFFChunk.cpp.
References Garbage, m_phys_length, m_phys_offset, m_type, and Root.
Referenced by Kwave::RIFFParser::collectGarbage(), dumpStructure(), Kwave::RIFFParser::findMissingChunk(), Kwave::RIFFParser::fixGarbageEnds(), fixSize(), Kwave::RIFFParser::parse(), and physStart().
|
inline |
Returns the length of the chunk in the file. For some dubious reason this seems always to be rounded up for even numbers!
Definition at line 146 of file RIFFChunk.h.
References m_phys_length.
Referenced by Kwave::RIFFParser::detectEndianness(), dumpStructure(), Kwave::RIFFParser::findMissingChunk(), Kwave::RIFFParser::joinGarbageToEmpty(), Kwave::WavDecoder::open(), Kwave::RIFFParser::parse(), Kwave::WavDecoder::repair(), and Kwave::WavDecoder::repairChunk().
|
inline |
Returns the offset in the source (file) where the chunk (name) starts.
Definition at line 135 of file RIFFChunk.h.
References m_phys_offset, and physEnd().
Referenced by Kwave::RIFFParser::addChunk(), Kwave::RIFFParser::chunkAt(), Kwave::RIFFParser::collectGarbage(), Kwave::RIFFParser::detectEndianness(), Kwave::RIFFParser::findMissingChunk(), Kwave::RIFFParser::fixGarbageEnds(), fixSize(), Kwave::RIFFParser::joinGarbageToEmpty(), and Kwave::WavDecoder::repair().
|
inline |
Sets the format to a new value, without any error checking
Definition at line 100 of file RIFFChunk.h.
References format(), and m_format.
Referenced by Kwave::RIFFParser::joinGarbageToEmpty().
void Kwave::RIFFChunk::setLength | ( | quint32 | length | ) |
Sets the data and physical length of the chunk both to a new value.
Definition at line 142 of file RIFFChunk.cpp.
References length(), m_chunk_length, and m_phys_length.
Referenced by Kwave::RIFFParser::collectGarbage(), Kwave::RIFFParser::fixGarbageEnds(), Kwave::RIFFParser::joinGarbageToEmpty(), and length().
|
inline |
Sets the type of the chunk
Definition at line 88 of file RIFFChunk.h.
References m_type, and type().
Referenced by Kwave::RIFFParser::addChunk(), Kwave::RIFFParser::collectGarbage(), Kwave::RIFFParser::joinGarbageToEmpty(), Kwave::RIFFParser::parse(), Kwave::WavDecoder::repair(), and Kwave::RIFFParser::RIFFParser().
|
inline |
Returns a reference to the list of sub-chunks (mutable).
Definition at line 151 of file RIFFChunk.h.
References m_sub_chunks.
Referenced by Kwave::RIFFParser::addChunk(), Kwave::RIFFParser::collectGarbage(), Kwave::RIFFParser::discardGarbage(), fixSize(), isSane(), Kwave::RIFFParser::joinGarbageToEmpty(), Kwave::RIFFParser::listAllChunks(), Kwave::WavDecoder::open(), Kwave::RIFFParser::parse(), path(), Kwave::WavDecoder::repair(), and Kwave::WavDecoder::repairChunk().
|
inline |
Returns a reference to the list of sub-chunks (const).
Definition at line 156 of file RIFFChunk.h.
References dumpStructure(), fixSize(), isChildOf(), and m_sub_chunks.
|
inline |
Returns the type of the chunk.
Definition at line 85 of file RIFFChunk.h.
References m_type.
Referenced by Kwave::RIFFParser::addChunk(), Kwave::RIFFParser::collectGarbage(), Kwave::RIFFParser::discardGarbage(), Kwave::RIFFParser::findMissingChunk(), Kwave::RIFFParser::fixGarbageEnds(), Kwave::RIFFParser::joinGarbageToEmpty(), path(), Kwave::WavDecoder::repair(), Kwave::WavDecoder::repairChunk(), and setType().
|
private |
length of the chunk
Definition at line 192 of file RIFFChunk.h.
Referenced by dataLength(), fixSize(), length(), and setLength().
|
private |
format of the chunk, only valid for main chunks
Definition at line 186 of file RIFFChunk.h.
Referenced by format(), path(), and setFormat().
|
private |
chunk name, always 4 bytes ASCII
Definition at line 183 of file RIFFChunk.h.
|
private |
path of the parent chunk
Definition at line 189 of file RIFFChunk.h.
Referenced by isChildOf(), parent(), and path().
|
private |
length used in the source (file)
Definition at line 198 of file RIFFChunk.h.
Referenced by fixSize(), isSane(), physEnd(), physLength(), and setLength().
|
private |
offset within the source (file)
Definition at line 195 of file RIFFChunk.h.
Referenced by dataStart(), dumpStructure(), physEnd(), and physStart().
|
private |
list of sub-chunks, empty if none known
Definition at line 201 of file RIFFChunk.h.
Referenced by dumpStructure(), isSane(), subChunks(), and ~RIFFChunk().
|
private |
type of this chunk: main or sub chunk
Definition at line 180 of file RIFFChunk.h.
Referenced by dataLength(), dataStart(), dumpStructure(), fixSize(), isChildOf(), isSane(), path(), physEnd(), setType(), and type().