Tag Parser
12.5.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Toggle main menu visibility
Loading...
Searching...
No Matches
matroska
matroskacues.h
Go to the documentation of this file.
1
#ifndef TAG_PARSER_MATROSKACUES_H
2
#define TAG_PARSER_MATROSKACUES_H
3
4
#include "
./ebmlelement.h
"
5
6
#include <ostream>
7
#include <unordered_map>
8
9
namespace
TagParser
{
10
11
class
TAG_PARSER_EXPORT
MatroskaOffsetStates
{
12
public
:
13
constexpr
MatroskaOffsetStates
(std::uint64_t
initialValue
);
14
constexpr
std::uint64_t
currentValue
()
const
;
15
void
update
(std::uint64_t newValue);
16
constexpr
std::uint64_t
initialValue
()
const
;
17
18
private
:
19
std::uint64_t m_initialValue;
20
std::uint64_t m_currentValue;
21
};
22
23
constexpr
MatroskaOffsetStates::MatroskaOffsetStates
(std::uint64_t
initialValue
)
24
: m_initialValue(
initialValue
)
25
, m_currentValue(
initialValue
)
26
{
27
}
28
29
constexpr
std::uint64_t
MatroskaOffsetStates::currentValue
()
const
30
{
31
return
m_currentValue;
32
}
33
34
inline
void
MatroskaOffsetStates::update
(std::uint64_t newValue)
35
{
36
m_currentValue = newValue;
37
}
38
39
constexpr
std::uint64_t
MatroskaOffsetStates::initialValue
()
const
40
{
41
return
m_initialValue;
42
}
43
44
class
TAG_PARSER_EXPORT
MatroskaReferenceOffsetPair
:
public
MatroskaOffsetStates
{
45
public
:
46
constexpr
MatroskaReferenceOffsetPair
(std::uint64_t
referenceOffset
, std::uint64_t
initialValue
);
47
constexpr
std::uint64_t
referenceOffset
()
const
;
48
49
private
:
50
std::uint64_t m_referenceOffset;
51
};
52
53
constexpr
MatroskaReferenceOffsetPair::MatroskaReferenceOffsetPair
(std::uint64_t
referenceOffset
, std::uint64_t
initialValue
)
54
:
MatroskaOffsetStates
(
initialValue
)
55
, m_referenceOffset(
referenceOffset
)
56
{
57
}
58
59
constexpr
std::uint64_t
MatroskaReferenceOffsetPair::referenceOffset
()
const
60
{
61
return
m_referenceOffset;
62
}
63
64
class
TAG_PARSER_EXPORT
MatroskaCuePositionUpdater
{
65
public
:
66
MatroskaCuePositionUpdater
();
67
68
EbmlElement
*
cuesElement
()
const
;
69
std::uint64_t
totalSize
()
const
;
70
71
void
parse
(
EbmlElement
*
cuesElement
,
Diagnostics
&diag);
72
bool
updateOffsets
(std::uint64_t originalOffset, std::uint64_t newOffset);
73
bool
updateRelativeOffsets
(std::uint64_t referenceOffset, std::uint64_t originalRelativeOffset, std::uint64_t newRelativeOffset);
74
void
make
(std::ostream &stream,
Diagnostics
&diag);
75
void
clear
();
76
77
private
:
78
struct
PairHash {
79
template
<
class
T1,
class
T2>
inline
std::size_t operator()(
const
std::pair<T1, T2> &pair)
const
80
{
81
std::size_t seed = 0;
82
seed ^= std::hash<T1>()(pair.first) + 0x9e3779b9;
83
seed ^= std::hash<T2>()(pair.second) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
84
return
seed;
85
}
86
};
87
88
bool
updateSize(
EbmlElement
*element,
int
shift);
89
90
EbmlElement
*m_cuesElement;
91
std::unordered_map<EbmlElement *, MatroskaOffsetStates> m_offsets;
92
std::unordered_multimap<std::uint64_t, EbmlElement *> m_cueElementByOriginalOffset;
93
std::unordered_map<EbmlElement *, MatroskaReferenceOffsetPair> m_relativeOffsets;
94
std::unordered_multimap<std::pair<std::uint64_t, std::uint64_t>,
EbmlElement
*, PairHash> m_cueRelativePositionElementByOriginalOffsets;
95
std::unordered_map<EbmlElement *, std::uint64_t> m_sizes;
96
};
97
103
inline
MatroskaCuePositionUpdater::MatroskaCuePositionUpdater
()
104
: m_cuesElement(nullptr)
105
{
106
}
107
113
inline
EbmlElement
*
MatroskaCuePositionUpdater::cuesElement
()
const
114
{
115
return
m_cuesElement;
116
}
117
121
inline
void
MatroskaCuePositionUpdater::clear
()
122
{
123
m_cuesElement =
nullptr
;
124
m_offsets.
clear
();
125
m_sizes.clear();
126
}
127
128
}
// namespace TagParser
129
130
#endif
// TAG_PARSER_MATROSKACUES_H
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition
diagnostics.h:156
TagParser::EbmlElement
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition
ebmlelement.h:32
TagParser::GenericFileElement::clear
void clear()
Clears the status of the element.
Definition
genericfileelement.h:753
TagParser::MatroskaCuePositionUpdater::totalSize
std::uint64_t totalSize() const
Returns how many bytes will be written when calling the make() method.
Definition
matroskacues.cpp:40
TagParser::MatroskaCuePositionUpdater::updateOffsets
bool updateOffsets(std::uint64_t originalOffset, std::uint64_t newOffset)
Sets the offset of the entries with the specified originalOffset to newOffset.
Definition
matroskacues.cpp:179
TagParser::MatroskaCuePositionUpdater::updateRelativeOffsets
bool updateRelativeOffsets(std::uint64_t referenceOffset, std::uint64_t originalRelativeOffset, std::uint64_t newRelativeOffset)
Sets the relative offset of the entries with the specified originalRelativeOffset and the specified r...
Definition
matroskacues.cpp:205
TagParser::MatroskaCuePositionUpdater::clear
void clear()
Resets the object to its initial state.
Definition
matroskacues.h:121
TagParser::MatroskaCuePositionUpdater::MatroskaCuePositionUpdater
MatroskaCuePositionUpdater()
Creates a new MatroskaCuePositionUpdater.
Definition
matroskacues.h:103
TagParser::MatroskaCuePositionUpdater::make
void make(std::ostream &stream, Diagnostics &diag)
Writes the previously parsed "Cues"-element with updated positions to the specified stream.
Definition
matroskacues.cpp:262
TagParser::MatroskaCuePositionUpdater::parse
void parse(EbmlElement *cuesElement, Diagnostics &diag)
Parses the specified cuesElement.
Definition
matroskacues.cpp:54
TagParser::MatroskaCuePositionUpdater::cuesElement
EbmlElement * cuesElement() const
Returns the "Cues"-element specified when calling the parse() method.
Definition
matroskacues.h:113
TagParser::MatroskaOffsetStates::update
void update(std::uint64_t newValue)
Definition
matroskacues.h:34
TagParser::MatroskaOffsetStates::currentValue
constexpr std::uint64_t currentValue() const
Definition
matroskacues.h:29
TagParser::MatroskaOffsetStates::initialValue
constexpr std::uint64_t initialValue() const
Definition
matroskacues.h:39
TagParser::MatroskaOffsetStates::MatroskaOffsetStates
constexpr MatroskaOffsetStates(std::uint64_t initialValue)
Definition
matroskacues.h:23
TagParser::MatroskaReferenceOffsetPair::referenceOffset
constexpr std::uint64_t referenceOffset() const
Definition
matroskacues.h:59
TagParser::MatroskaReferenceOffsetPair::MatroskaReferenceOffsetPair
constexpr MatroskaReferenceOffsetPair(std::uint64_t referenceOffset, std::uint64_t initialValue)
Definition
matroskacues.h:53
ebmlelement.h
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition
global.h:14
TagParser
Contains all classes and functions of the TagInfo library.
Definition
aaccodebook.h:10
Generated on
for Tag Parser by
1.18.0