WIP: Parse AV1 configuration
This commit is contained in:
parent
3c06590085
commit
d6728824f4
|
@ -3,9 +3,11 @@
|
||||||
#include "../diagnostics.h"
|
#include "../diagnostics.h"
|
||||||
#include "../exceptions.h"
|
#include "../exceptions.h"
|
||||||
|
|
||||||
|
#include <c++utilities/conversion/stringbuilder.h>
|
||||||
#include <c++utilities/io/binaryreader.h>
|
#include <c++utilities/io/binaryreader.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace ConversionUtilities;
|
||||||
using namespace IoUtilities;
|
using namespace IoUtilities;
|
||||||
|
|
||||||
namespace TagParser {
|
namespace TagParser {
|
||||||
|
@ -19,14 +21,20 @@ namespace TagParser {
|
||||||
* \brief Parses the AV1 configuration using the specified \a reader.
|
* \brief Parses the AV1 configuration using the specified \a reader.
|
||||||
* \throws Throws TruncatedDataException() when the config size exceeds the specified \a maxSize.
|
* \throws Throws TruncatedDataException() when the config size exceeds the specified \a maxSize.
|
||||||
* \remarks Logging/reporting parsing errors is not implemented yet.
|
* \remarks Logging/reporting parsing errors is not implemented yet.
|
||||||
* \todo Provide implementation
|
* \todo Read all fields.
|
||||||
*/
|
*/
|
||||||
void Av1Configuration::parse(BinaryReader &reader, uint64 maxSize, Diagnostics &diag)
|
void Av1Configuration::parse(BinaryReader &reader, uint64 maxSize, Diagnostics &diag)
|
||||||
{
|
{
|
||||||
VAR_UNUSED(reader)
|
if (maxSize < 4) {
|
||||||
VAR_UNUSED(maxSize)
|
throw TruncatedDataException();
|
||||||
VAR_UNUSED(diag)
|
}
|
||||||
throw NotImplementedException();
|
markerAndVersion = reader.readUInt32BE();
|
||||||
|
if (marker() != 1) {
|
||||||
|
diag.emplace_back(DiagLevel::Warning, argsToString("Marker is ", marker(), " (and not 1)."), "parsing AV1 config");
|
||||||
|
}
|
||||||
|
if (version() != 1) {
|
||||||
|
diag.emplace_back(DiagLevel::Warning, argsToString("Version ", version(), " is not supported (only 1)."), "parsing AV1 config");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TagParser
|
} // namespace TagParser
|
||||||
|
|
|
@ -15,8 +15,11 @@ class MediaFormat;
|
||||||
class Diagnostics;
|
class Diagnostics;
|
||||||
|
|
||||||
struct TAG_PARSER_EXPORT Av1Configuration {
|
struct TAG_PARSER_EXPORT Av1Configuration {
|
||||||
Av1Configuration();
|
constexpr Av1Configuration();
|
||||||
|
// FIXME: make this uint32 in v9
|
||||||
uint64 markerAndVersion;
|
uint64 markerAndVersion;
|
||||||
|
|
||||||
|
// FIXME: get rid of unused members in v9
|
||||||
uint64 profileAndLevel;
|
uint64 profileAndLevel;
|
||||||
byte tier;
|
byte tier;
|
||||||
byte highBitdepth;
|
byte highBitdepth;
|
||||||
|
@ -27,12 +30,24 @@ struct TAG_PARSER_EXPORT Av1Configuration {
|
||||||
uint16 chromaSamplePosition;
|
uint16 chromaSamplePosition;
|
||||||
|
|
||||||
void parse(IoUtilities::BinaryReader &reader, uint64 maxSize, Diagnostics &diag);
|
void parse(IoUtilities::BinaryReader &reader, uint64 maxSize, Diagnostics &diag);
|
||||||
|
|
||||||
|
constexpr byte marker() const;
|
||||||
|
constexpr byte version() const;
|
||||||
|
constexpr byte sequenceProfile() const;
|
||||||
|
constexpr byte sequenceLevelIndex() const;
|
||||||
|
constexpr byte sequenceTier() const;
|
||||||
|
constexpr byte isHighBitDepth() const;
|
||||||
|
constexpr byte isTwelveBit() const;
|
||||||
|
constexpr byte isMonochrome() const;
|
||||||
|
constexpr byte hasChromaSubsamplingX() const;
|
||||||
|
constexpr byte hasChromaSubsamplingY() const;
|
||||||
|
constexpr byte chromaSamplePos() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructs an empty AVC configuration.
|
* \brief Constructs an empty AVC configuration.
|
||||||
*/
|
*/
|
||||||
inline Av1Configuration::Av1Configuration()
|
constexpr Av1Configuration::Av1Configuration()
|
||||||
: markerAndVersion(0)
|
: markerAndVersion(0)
|
||||||
, profileAndLevel(0)
|
, profileAndLevel(0)
|
||||||
, tier(0)
|
, tier(0)
|
||||||
|
@ -45,6 +60,61 @@ inline Av1Configuration::Av1Configuration()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::marker() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1)) & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::version() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7)) & 0x7F);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::sequenceProfile() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3)) & 0x07);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::sequenceLevelIndex() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5)) & 0x1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::sequenceTier() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5 - 1)) & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::isHighBitDepth() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5 - 1 - 1)) & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::isTwelveBit() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5 - 1 - 1)) & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::isMonochrome() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5 - 1 - 1 - 1)) & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::hasChromaSubsamplingX() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5 - 1 - 1 - 1 - 1)) & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::hasChromaSubsamplingY() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5 - 1 - 1 - 1 - 1 - 1)) & 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr byte Av1Configuration::chromaSamplePos() const
|
||||||
|
{
|
||||||
|
return static_cast<byte>((markerAndVersion >> (32 - 1 - 7 - 3 - 5 - 1 - 1 - 1 - 1 - 1 - 1)) & 0x03);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace TagParser
|
} // namespace TagParser
|
||||||
|
|
||||||
#endif // TAG_PARSER_AV1CONFIGURATION_H
|
#endif // TAG_PARSER_AV1CONFIGURATION_H
|
||||||
|
|
Loading…
Reference in New Issue