Tag Parser: avc/avcinfo.h Source File

Tag Parser 12.5.2 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
avcinfo.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_AVCINFO_H
2#define TAG_PARSER_AVCINFO_H
3
4#include "../aspectratio.h"
5#include "../margin.h"
6#include "../size.h"
7
8namespace CppUtilities {
9class BinaryReader;
10class BitReader;
11} // namespace CppUtilities
12
13namespace TagParser {
14
18 using ugolomb = std::uint32_t;
19
23 using sgolomb = std::int32_t;
24
25 struct TAG_PARSER_EXPORT TimingInfo {
26 constexpr TimingInfo();
27 std::uint32_t unitsInTick;
28 std::uint32_t timeScale;
29 std::uint8_t isPresent;
30 std::uint8_t fixedFrameRate;
31 constexpr std::int64_t defaultDuration() const;
32};
33
34 constexpr TimingInfo::TimingInfo()
35 : unitsInTick(0)
36 , timeScale(0)
37 , isPresent(0)
38 , fixedFrameRate(0)
39{
40}
41
42 constexpr std::int64_t TimingInfo::defaultDuration() const
43{
44 return 1000000000ll * unitsInTick / timeScale;
45}
46
47 struct TAG_PARSER_EXPORT HrdParameters {
48 constexpr HrdParameters();
49 ugolomb cpbCount;
50 std::uint8_t bitRateScale;
51 std::uint8_t cpbSizeScale;
52 std::uint8_t initialCpbRemovalDelayLength;
53 std::uint8_t cpbRemovalDelayLength;
54 std::uint8_t cpbOutputDelayLength;
55 std::uint8_t timeOffsetLength;
56
57 void parse(CppUtilities::BitReader &reader);
58};
59
60 constexpr HrdParameters::HrdParameters()
61 : cpbCount(0)
62 , bitRateScale(0)
63 , cpbSizeScale(0)
64 , initialCpbRemovalDelayLength(0)
65 , cpbRemovalDelayLength(0)
66 , cpbOutputDelayLength(0)
67 , timeOffsetLength(0)
68{
69}
70
71 struct TAG_PARSER_EXPORT SpsInfo {
72 constexpr SpsInfo();
73 ugolomb id;
74 std::uint8_t profileIndication;
75 std::uint8_t profileConstraints;
76 std::uint8_t levelIndication;
77 ugolomb chromaFormatIndication;
78 ugolomb pictureOrderCountType;
79 ugolomb log2MaxFrameNum;
80 ugolomb log2MaxPictureOrderCountLsb;
81 sgolomb offsetForNonRefPic;
82 sgolomb offsetForTopToBottomField;
83 ugolomb numRefFramesInPicOrderCntCycle;
84 std::uint8_t deltaPicOrderAlwaysZeroFlag;
85 std::uint8_t frameMbsOnly;
86 std::uint8_t vuiPresent;
87 AspectRatio pixelAspectRatio;
88 TimingInfo timingInfo;
89 Margin cropping;
90 Size pictureSize;
91 std::uint8_t hrdParametersPresent;
92 HrdParameters nalHrdParameters;
93 HrdParameters vclHrdParameters;
94 std::uint8_t pictureStructPresent;
95 std::uint16_t size;
96 static constexpr std::uint16_t minSize = 2;
97
98 void parse(CppUtilities::BinaryReader &reader, std::uint32_t maxSize);
99};
100
101 constexpr SpsInfo::SpsInfo()
102 : id(0)
103 , profileIndication(0)
104 , profileConstraints(0)
105 , levelIndication(0)
106 , chromaFormatIndication(0)
107 , pictureOrderCountType(0)
108 , log2MaxFrameNum(0)
109 , log2MaxPictureOrderCountLsb(0)
110 , offsetForNonRefPic(0)
111 , offsetForTopToBottomField(0)
112 , numRefFramesInPicOrderCntCycle(0)
113 , deltaPicOrderAlwaysZeroFlag(0)
114 , frameMbsOnly(0)
115 , vuiPresent(0)
116 , hrdParametersPresent(0)
117 , pictureStructPresent(0)
118 , size(0)
119{
120}
121
122 struct TAG_PARSER_EXPORT PpsInfo {
123 constexpr PpsInfo();
124 ugolomb id;
125 ugolomb spsId;
126 std::uint8_t picOrderPresent;
127 std::uint16_t size;
128 static constexpr std::uint16_t minSize = 2;
129
130 void parse(CppUtilities::BinaryReader &reader, std::uint32_t maxSize);
131};
132
133 constexpr PpsInfo::PpsInfo()
134 : id(0)
135 , spsId(0)
136 , picOrderPresent(false)
137 , size(0)
138{
139}
140
141 struct TAG_PARSER_EXPORT SliceInfo {
142 constexpr SliceInfo();
143 std::uint8_t naluType;
144 std::uint8_t naluRefIdc;
145 std::uint8_t type;
146 std::uint8_t ppsId;
147 std::uint32_t frameNum;
148 bool fieldPicFlag;
149 bool bottomFieldFlag;
150 std::uint32_t idrPicId;
151 std::uint32_t picOrderCntLsb;
152 std::uint32_t deltaPicOrderCntBottom;
153 std::uint32_t deltaPicOrderCnt[2];
154 std::uint32_t firstMbInSlice;
155 std::uint32_t sps;
156 std::uint32_t pps;
157};
158
159 constexpr SliceInfo::SliceInfo()
160 : naluType(0)
161 , naluRefIdc(0)
162 , type(0)
163 , ppsId(0)
164 , frameNum(0)
165 , fieldPicFlag(false)
166 , bottomFieldFlag(false)
167 , idrPicId(0)
168 , picOrderCntLsb(0)
169 , deltaPicOrderCntBottom(0)
170 , deltaPicOrderCnt{ 0, 0 }
171 , firstMbInSlice(0)
172 , sps(0)
173 , pps(0)
174{
175}
176
177 struct TAG_PARSER_EXPORT AvcFrame {
178 constexpr AvcFrame();
179 std::uint64_t start;
180 std::uint64_t end;
181 std::uint64_t ref1;
182 std::uint64_t ref2;
183 SliceInfo sliceInfo;
184 std::uint32_t presentationOrder;
185 std::uint32_t decodeOrder;
186 bool keyframe;
187 bool hasProvidedTimecode;
188};
189
190 constexpr AvcFrame::AvcFrame()
191 : start(0)
192 , end(0)
193 , ref1(0)
194 , ref2(0)
195 , presentationOrder(0)
196 , decodeOrder(0)
197 , keyframe(false)
198 , hasProvidedTimecode(false)
199{
200}
201
202} // namespace TagParser
203
204#endif // TAG_PARSER_AVCINFO_H
aspectratio.h
TagParser::Margin
The Margin class defines the four margins of a rectangle.
Definition margin.h:16
TagParser::Size
The Size class defines the size of a two-dimensional object using integer point precision.
Definition size.h:17
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
margin.h
CppUtilities
Definition abstractcontainer.h:16
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::ugolomb
std::uint32_t ugolomb
Type used to store unsigned integer values using golomb coding.
Definition avcinfo.h:18
TagParser::sgolomb
std::int32_t sgolomb
Type used to store signed integer values using golomb coding.
Definition avcinfo.h:23
size.h
TagParser::AspectRatio
The AspectRatio struct defines an aspect ratio.
Definition aspectratio.h:13
TagParser::AvcFrame::sliceInfo
SliceInfo sliceInfo
Definition avcinfo.h:183
TagParser::AvcFrame::ref1
std::uint64_t ref1
Definition avcinfo.h:181
TagParser::AvcFrame::start
std::uint64_t start
Definition avcinfo.h:179
TagParser::AvcFrame::AvcFrame
constexpr AvcFrame()
Definition avcinfo.h:190
TagParser::AvcFrame::presentationOrder
std::uint32_t presentationOrder
Definition avcinfo.h:184
TagParser::AvcFrame::hasProvidedTimecode
bool hasProvidedTimecode
Definition avcinfo.h:187
TagParser::AvcFrame::end
std::uint64_t end
Definition avcinfo.h:180
TagParser::AvcFrame::decodeOrder
std::uint32_t decodeOrder
Definition avcinfo.h:185
TagParser::AvcFrame::keyframe
bool keyframe
Definition avcinfo.h:186
TagParser::AvcFrame::ref2
std::uint64_t ref2
Definition avcinfo.h:182
TagParser::HrdParameters
The HrdParameters struct holds "Hypothetical Reference Decoder" parameters.
Definition avcinfo.h:47
TagParser::HrdParameters::initialCpbRemovalDelayLength
std::uint8_t initialCpbRemovalDelayLength
Definition avcinfo.h:52
TagParser::HrdParameters::bitRateScale
std::uint8_t bitRateScale
Definition avcinfo.h:50
TagParser::HrdParameters::parse
void parse(CppUtilities::BitReader &reader)
Parses HRD parameters.
Definition avcinfo.cpp:257
TagParser::HrdParameters::cpbRemovalDelayLength
std::uint8_t cpbRemovalDelayLength
Definition avcinfo.h:53
TagParser::HrdParameters::timeOffsetLength
std::uint8_t timeOffsetLength
Definition avcinfo.h:55
TagParser::HrdParameters::cpbOutputDelayLength
std::uint8_t cpbOutputDelayLength
Definition avcinfo.h:54
TagParser::HrdParameters::cpbSizeScale
std::uint8_t cpbSizeScale
Definition avcinfo.h:51
TagParser::HrdParameters::HrdParameters
constexpr HrdParameters()
Definition avcinfo.h:60
TagParser::HrdParameters::cpbCount
ugolomb cpbCount
Definition avcinfo.h:49
TagParser::PpsInfo::PpsInfo
constexpr PpsInfo()
Definition avcinfo.h:133
TagParser::PpsInfo::picOrderPresent
std::uint8_t picOrderPresent
Definition avcinfo.h:126
TagParser::PpsInfo::spsId
ugolomb spsId
Definition avcinfo.h:125
TagParser::PpsInfo::id
ugolomb id
Definition avcinfo.h:124
TagParser::PpsInfo::parse
void parse(CppUtilities::BinaryReader &reader, std::uint32_t maxSize)
Parses the PPS info.
Definition avcinfo.cpp:221
TagParser::PpsInfo::minSize
static constexpr std::uint16_t minSize
Definition avcinfo.h:128
TagParser::PpsInfo::size
std::uint16_t size
Definition avcinfo.h:127
TagParser::SliceInfo
The SliceInfo struct holds the slice information of an AVC frame.
Definition avcinfo.h:141
TagParser::SliceInfo::SliceInfo
constexpr SliceInfo()
Definition avcinfo.h:159
TagParser::SliceInfo::deltaPicOrderCnt
std::uint32_t deltaPicOrderCnt[2]
Definition avcinfo.h:153
TagParser::SliceInfo::deltaPicOrderCntBottom
std::uint32_t deltaPicOrderCntBottom
Definition avcinfo.h:152
TagParser::SliceInfo::sps
std::uint32_t sps
Definition avcinfo.h:155
TagParser::SliceInfo::idrPicId
std::uint32_t idrPicId
Definition avcinfo.h:150
TagParser::SliceInfo::frameNum
std::uint32_t frameNum
Definition avcinfo.h:147
TagParser::SliceInfo::firstMbInSlice
std::uint32_t firstMbInSlice
Definition avcinfo.h:154
TagParser::SliceInfo::bottomFieldFlag
bool bottomFieldFlag
Definition avcinfo.h:149
TagParser::SliceInfo::type
std::uint8_t type
Definition avcinfo.h:145
TagParser::SliceInfo::naluType
std::uint8_t naluType
Definition avcinfo.h:143
TagParser::SliceInfo::ppsId
std::uint8_t ppsId
Definition avcinfo.h:146
TagParser::SliceInfo::pps
std::uint32_t pps
Definition avcinfo.h:156
TagParser::SliceInfo::naluRefIdc
std::uint8_t naluRefIdc
Definition avcinfo.h:144
TagParser::SliceInfo::picOrderCntLsb
std::uint32_t picOrderCntLsb
Definition avcinfo.h:151
TagParser::SliceInfo::fieldPicFlag
bool fieldPicFlag
Definition avcinfo.h:148
TagParser::SpsInfo::id
ugolomb id
Definition avcinfo.h:73
TagParser::SpsInfo::SpsInfo
constexpr SpsInfo()
Definition avcinfo.h:101
TagParser::SpsInfo::deltaPicOrderAlwaysZeroFlag
std::uint8_t deltaPicOrderAlwaysZeroFlag
Definition avcinfo.h:84
TagParser::SpsInfo::pictureOrderCountType
ugolomb pictureOrderCountType
Definition avcinfo.h:78
TagParser::SpsInfo::parse
void parse(CppUtilities::BinaryReader &reader, std::uint32_t maxSize)
Parses the SPS info.
Definition avcinfo.cpp:24
TagParser::SpsInfo::pixelAspectRatio
AspectRatio pixelAspectRatio
Definition avcinfo.h:87
TagParser::SpsInfo::vclHrdParameters
HrdParameters vclHrdParameters
Definition avcinfo.h:93
TagParser::SpsInfo::nalHrdParameters
HrdParameters nalHrdParameters
Definition avcinfo.h:92
TagParser::SpsInfo::timingInfo
TimingInfo timingInfo
Definition avcinfo.h:88
TagParser::SpsInfo::cropping
Margin cropping
Definition avcinfo.h:89
TagParser::SpsInfo::frameMbsOnly
std::uint8_t frameMbsOnly
Definition avcinfo.h:85
TagParser::SpsInfo::hrdParametersPresent
std::uint8_t hrdParametersPresent
Definition avcinfo.h:91
TagParser::SpsInfo::vuiPresent
std::uint8_t vuiPresent
Definition avcinfo.h:86
TagParser::SpsInfo::minSize
static constexpr std::uint16_t minSize
Definition avcinfo.h:96
TagParser::SpsInfo::log2MaxPictureOrderCountLsb
ugolomb log2MaxPictureOrderCountLsb
Definition avcinfo.h:80
TagParser::SpsInfo::offsetForTopToBottomField
sgolomb offsetForTopToBottomField
Definition avcinfo.h:82
TagParser::SpsInfo::log2MaxFrameNum
ugolomb log2MaxFrameNum
Definition avcinfo.h:79
TagParser::SpsInfo::profileConstraints
std::uint8_t profileConstraints
Definition avcinfo.h:75
TagParser::SpsInfo::numRefFramesInPicOrderCntCycle
ugolomb numRefFramesInPicOrderCntCycle
Definition avcinfo.h:83
TagParser::SpsInfo::pictureSize
Size pictureSize
Definition avcinfo.h:90
TagParser::SpsInfo::profileIndication
std::uint8_t profileIndication
Definition avcinfo.h:74
TagParser::SpsInfo::levelIndication
std::uint8_t levelIndication
Definition avcinfo.h:76
TagParser::SpsInfo::size
std::uint16_t size
Definition avcinfo.h:95
TagParser::SpsInfo::offsetForNonRefPic
sgolomb offsetForNonRefPic
Definition avcinfo.h:81
TagParser::SpsInfo::pictureStructPresent
std::uint8_t pictureStructPresent
Definition avcinfo.h:94
TagParser::SpsInfo::chromaFormatIndication
ugolomb chromaFormatIndication
Definition avcinfo.h:77
TagParser::TimingInfo
The TimingInfo struct holds timing information (part of SPS info).
Definition avcinfo.h:25
TagParser::TimingInfo::defaultDuration
constexpr std::int64_t defaultDuration() const
Definition avcinfo.h:42
TagParser::TimingInfo::isPresent
std::uint8_t isPresent
Definition avcinfo.h:29
TagParser::TimingInfo::TimingInfo
constexpr TimingInfo()
Definition avcinfo.h:34
TagParser::TimingInfo::fixedFrameRate
std::uint8_t fixedFrameRate
Definition avcinfo.h:30
TagParser::TimingInfo::unitsInTick
std::uint32_t unitsInTick
Definition avcinfo.h:27
TagParser::TimingInfo::timeScale
std::uint32_t timeScale
Definition avcinfo.h:28