tagparser/avc/avcinfo.h

205 lines
4.6 KiB
C
Raw Normal View History

#ifndef TAG_PARSER_AVCINFO_H
#define TAG_PARSER_AVCINFO_H
2015-04-22 19:22:01 +02:00
2018-03-07 01:17:50 +01:00
#include "../aspectratio.h"
2015-09-06 19:57:33 +02:00
#include "../margin.h"
#include "../size.h"
2016-02-17 20:19:05 +01:00
2019-06-10 22:49:11 +02:00
namespace CppUtilities {
2016-02-17 20:19:05 +01:00
class BinaryReader;
class BitReader;
2019-06-12 20:40:45 +02:00
} // namespace CppUtilities
2015-04-22 19:22:01 +02:00
namespace TagParser {
2015-04-22 19:22:01 +02:00
2016-02-17 20:19:05 +01:00
/*!
* \brief Type used to store unsigned integer values using golomb coding.
*/
2019-03-13 19:06:42 +01:00
using ugolomb = std::uint32_t;
2016-02-17 20:19:05 +01:00
/*!
* \brief Type used to store signed integer values using golomb coding.
*/
2019-03-13 19:06:42 +01:00
using sgolomb = std::int32_t;
2016-02-17 20:19:05 +01:00
2016-08-29 15:43:05 +02:00
struct TAG_PARSER_EXPORT TimingInfo {
2018-07-10 14:11:11 +02:00
constexpr TimingInfo();
2019-03-13 19:06:42 +01:00
std::uint32_t unitsInTick;
std::uint32_t timeScale;
std::uint8_t isPresent;
std::uint8_t fixedFrameRate;
constexpr std::int64_t defaultDuration() const;
2015-04-22 19:22:01 +02:00
};
2018-07-10 14:11:11 +02:00
constexpr TimingInfo::TimingInfo()
2018-03-07 01:17:50 +01:00
: unitsInTick(0)
, timeScale(0)
, isPresent(0)
, fixedFrameRate(0)
{
}
2015-04-22 19:22:01 +02:00
2019-03-13 19:06:42 +01:00
constexpr std::int64_t TimingInfo::defaultDuration() const
2015-04-22 19:22:01 +02:00
{
return 1000000000ll * unitsInTick / timeScale;
}
2016-08-29 15:43:05 +02:00
struct TAG_PARSER_EXPORT HrdParameters {
2018-07-10 14:11:11 +02:00
constexpr HrdParameters();
2016-02-17 20:19:05 +01:00
ugolomb cpbCount;
2019-03-13 19:06:42 +01:00
std::uint8_t bitRateScale;
std::uint8_t cpbSizeScale;
std::uint8_t initialCpbRemovalDelayLength;
std::uint8_t cpbRemovalDelayLength;
std::uint8_t cpbOutputDelayLength;
std::uint8_t timeOffsetLength;
2016-02-17 20:19:05 +01:00
2019-06-10 22:49:11 +02:00
void parse(CppUtilities::BitReader &reader);
2016-02-17 20:19:05 +01:00
};
2018-07-10 14:11:11 +02:00
constexpr HrdParameters::HrdParameters()
2018-03-07 01:17:50 +01:00
: cpbCount(0)
, bitRateScale(0)
, cpbSizeScale(0)
, initialCpbRemovalDelayLength(0)
, cpbRemovalDelayLength(0)
, cpbOutputDelayLength(0)
, timeOffsetLength(0)
{
}
2016-02-17 20:19:05 +01:00
2016-08-29 15:43:05 +02:00
struct TAG_PARSER_EXPORT SpsInfo {
2018-07-10 14:11:11 +02:00
constexpr SpsInfo();
2016-02-17 20:19:05 +01:00
ugolomb id;
2019-03-13 19:06:42 +01:00
std::uint8_t profileIndication;
std::uint8_t profileConstraints;
std::uint8_t levelIndication;
2016-02-17 20:19:05 +01:00
ugolomb chromaFormatIndication;
ugolomb pictureOrderCountType;
ugolomb log2MaxFrameNum;
ugolomb log2MaxPictureOrderCountLsb;
sgolomb offsetForNonRefPic;
sgolomb offsetForTopToBottomField;
ugolomb numRefFramesInPicOrderCntCycle;
2019-03-13 19:06:42 +01:00
std::uint8_t deltaPicOrderAlwaysZeroFlag;
std::uint8_t frameMbsOnly;
std::uint8_t vuiPresent;
2016-02-17 20:19:05 +01:00
AspectRatio pixelAspectRatio;
2015-04-22 19:22:01 +02:00
TimingInfo timingInfo;
Margin cropping;
2016-02-17 20:19:05 +01:00
Size pictureSize;
2019-03-13 19:06:42 +01:00
std::uint8_t hrdParametersPresent;
2016-02-17 20:19:05 +01:00
HrdParameters nalHrdParameters;
HrdParameters vclHrdParameters;
2019-03-13 19:06:42 +01:00
std::uint8_t pictureStructPresent;
std::uint16_t size;
static constexpr std::uint16_t minSize = 2;
2016-02-17 20:19:05 +01:00
2019-06-10 22:49:11 +02:00
void parse(CppUtilities::BinaryReader &reader, std::uint32_t maxSize);
2015-04-22 19:22:01 +02:00
};
2018-07-10 14:11:11 +02:00
constexpr SpsInfo::SpsInfo()
2018-03-07 01:17:50 +01:00
: id(0)
, profileIndication(0)
, profileConstraints(0)
, levelIndication(0)
, chromaFormatIndication(0)
, pictureOrderCountType(0)
, log2MaxFrameNum(0)
, log2MaxPictureOrderCountLsb(0)
, offsetForNonRefPic(0)
, offsetForTopToBottomField(0)
, numRefFramesInPicOrderCntCycle(0)
, deltaPicOrderAlwaysZeroFlag(0)
, frameMbsOnly(0)
, vuiPresent(0)
, hrdParametersPresent(0)
, pictureStructPresent(0)
, size(0)
{
}
2015-04-22 19:22:01 +02:00
2016-08-29 15:43:05 +02:00
struct TAG_PARSER_EXPORT PpsInfo {
2018-07-10 14:11:11 +02:00
constexpr PpsInfo();
2016-02-17 20:19:05 +01:00
ugolomb id;
ugolomb spsId;
2019-03-13 19:06:42 +01:00
std::uint8_t picOrderPresent;
std::uint16_t size;
static constexpr std::uint16_t minSize = 2;
2016-02-17 20:19:05 +01:00
2019-06-10 22:49:11 +02:00
void parse(CppUtilities::BinaryReader &reader, std::uint32_t maxSize);
2015-04-22 19:22:01 +02:00
};
2018-07-10 14:11:11 +02:00
constexpr PpsInfo::PpsInfo()
2018-03-07 01:17:50 +01:00
: id(0)
, spsId(0)
, picOrderPresent(false)
, size(0)
{
}
2015-04-22 19:22:01 +02:00
2016-08-29 15:43:05 +02:00
struct TAG_PARSER_EXPORT SliceInfo {
2018-07-10 14:11:11 +02:00
constexpr SliceInfo();
2019-03-13 19:06:42 +01:00
std::uint8_t naluType;
std::uint8_t naluRefIdc;
std::uint8_t type;
std::uint8_t ppsId;
std::uint32_t frameNum;
2015-04-22 19:22:01 +02:00
bool fieldPicFlag;
bool bottomFieldFlag;
2019-03-13 19:06:42 +01:00
std::uint32_t idrPicId;
std::uint32_t picOrderCntLsb;
std::uint32_t deltaPicOrderCntBottom;
std::uint32_t deltaPicOrderCnt[2];
std::uint32_t firstMbInSlice;
std::uint32_t sps;
std::uint32_t pps;
2015-04-22 19:22:01 +02:00
};
2018-07-10 14:11:11 +02:00
constexpr SliceInfo::SliceInfo()
2018-03-07 01:17:50 +01:00
: naluType(0)
, naluRefIdc(0)
, type(0)
, ppsId(0)
, frameNum(0)
, fieldPicFlag(false)
, bottomFieldFlag(false)
, idrPicId(0)
, picOrderCntLsb(0)
, deltaPicOrderCntBottom(0)
, deltaPicOrderCnt{ 0, 0 }
, firstMbInSlice(0)
, sps(0)
, pps(0)
{
}
2015-04-22 19:22:01 +02:00
2017-06-10 21:46:25 +02:00
struct TAG_PARSER_EXPORT AvcFrame {
2018-07-10 14:11:11 +02:00
constexpr AvcFrame();
2019-03-13 19:06:42 +01:00
std::uint64_t start;
std::uint64_t end;
std::uint64_t ref1;
std::uint64_t ref2;
2017-06-10 21:46:25 +02:00
SliceInfo sliceInfo;
2019-03-13 19:06:42 +01:00
std::uint32_t presentationOrder;
std::uint32_t decodeOrder;
2018-07-10 14:11:11 +02:00
bool keyframe;
bool hasProvidedTimecode;
2015-04-22 19:22:01 +02:00
};
2018-07-10 14:11:11 +02:00
constexpr AvcFrame::AvcFrame()
2018-03-07 01:17:50 +01:00
: start(0)
, end(0)
, ref1(0)
, ref2(0)
, presentationOrder(0)
, decodeOrder(0)
2018-07-10 14:11:11 +02:00
, keyframe(false)
, hasProvidedTimecode(false)
2018-03-07 01:17:50 +01:00
{
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser
#endif // TAG_PARSER_AVCINFO_H