Tag Parser 12.1.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
ivfstream.cpp
Go to the documentation of this file.
1#include "./ivfstream.h"
2
3#include "../mp4/mp4ids.h"
4
5#include "../exceptions.h"
6
7#include <c++utilities/conversion/stringbuilder.h>
8#include <c++utilities/conversion/stringconversion.h>
9
10#include <string>
11
12using namespace std;
13using namespace CppUtilities;
14
15namespace TagParser {
16
24{
25 CPP_UTILITIES_UNUSED(progress)
26
27 static const string context("parsing IVF header");
28 if (!m_istream) {
30 }
31
32 // check signature and version
33 if (m_reader.readUInt32BE() != 0x444B4946u) {
34 diag.emplace_back(DiagLevel::Critical, "Signature not \"DKIF\".", context);
36 }
37 const auto version = m_reader.readUInt16LE();
39 if (version != 0) {
40 diag.emplace_back(DiagLevel::Warning, argsToString("Version ", version, " is not supported."), context);
41 }
42
43 // read remaining header
44 m_headerLength = m_reader.readUInt16LE();
45 const auto formatId = m_reader.readUInt32BE();
46 m_formatId = interpretIntegerAsString(formatId);
47 m_pixelSize.setWidth(m_reader.readUInt16LE());
48 m_pixelSize.setHeight(m_reader.readUInt16LE());
49 m_fps = m_reader.readUInt32LE();
50 m_timeScale = m_reader.readUInt32LE();
51 m_sampleCount = m_reader.readUInt32LE();
52
53 // compute further values
55 m_duration = TimeSpan::fromSeconds(static_cast<double>(m_sampleCount) / m_fps);
56
57 // skip unused bytes
58 m_istream->seekg(4, ios_base::cur);
59}
60
62{
63 m_frames.emplace_back();
64 m_frames.back().parseHeader(m_reader, diag);
65}
66
67} // namespace TagParser
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
double version() const
Returns the version/level of the track if known; otherwise returns 0.
CppUtilities::TimeSpan m_duration
const std::string & formatId() const
Returns the format/codec ID.
CppUtilities::BinaryReader m_reader
The Diagnostics class is a container for DiagMessage.
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
Definition exceptions.h:25
void readFrame(Diagnostics &diag)
Definition ivfstream.cpp:61
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
This method is internally called to parse header information.
Definition ivfstream.cpp:23
The exception that is thrown when the data to be parsed holds no parsable information (e....
Definition exceptions.h:18
void setWidth(std::uint32_t value)
Sets the width.
Definition size.h:76
void setHeight(std::uint32_t value)
Sets the height.
Definition size.h:84
TAG_PARSER_EXPORT MediaFormat fourccToMediaFormat(std::uint32_t fourccId)
Definition mp4ids.cpp:48
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10