feat: add QBIN V3 decoder for particle.9
This commit is contained in:
@@ -15,19 +15,42 @@ struct EncodedFieldRuntimeMetadata {
|
||||
uint64_t dataVersion = 0;
|
||||
};
|
||||
|
||||
enum class QbinV2DecodeErrorCode : uint8_t {
|
||||
Accepted, InvalidRuntimeMetadata, InputTooSmall, BadMagic, UnsupportedVersion, UnsupportedLayout,
|
||||
UnsupportedProjection, UnsupportedSampleOrder, UnsupportedGridRegistration, InvalidHeader, InvalidBounds,
|
||||
InvalidTime, LimitExceeded, LengthMismatch, ReservedNonZero, InvalidDescriptor,
|
||||
NonCanonicalDescriptorOrder, DuplicatePlaneKey, NonCanonicalPacking, NonZeroPadding, CrcMismatch,
|
||||
InvalidValidity, InvalidCellPayload, InvalidFrame,
|
||||
enum class QbinDecodeErrorCode : uint8_t {
|
||||
Accepted,
|
||||
InvalidRuntimeMetadata,
|
||||
InputTooSmall,
|
||||
BadMagic,
|
||||
UnsupportedVersion,
|
||||
UnsupportedLayout,
|
||||
UnsupportedProjection,
|
||||
UnsupportedSampleOrder,
|
||||
UnsupportedGridRegistration,
|
||||
InvalidHeader,
|
||||
InvalidBounds,
|
||||
InvalidTime,
|
||||
LimitExceeded,
|
||||
LengthMismatch,
|
||||
ReservedNonZero,
|
||||
InvalidDescriptor,
|
||||
NonCanonicalDescriptorOrder,
|
||||
DuplicatePlaneKey,
|
||||
NonCanonicalPacking,
|
||||
NonZeroPadding,
|
||||
CrcMismatch,
|
||||
InvalidValidity,
|
||||
InvalidCellPayload,
|
||||
InvalidFrame,
|
||||
MalformedRice,
|
||||
ResidualOutOfRange,
|
||||
};
|
||||
|
||||
using QbinV2DecodeErrorCode = QbinDecodeErrorCode;
|
||||
|
||||
struct QbinV2DecodeResult {
|
||||
QbinV2DecodeErrorCode code = QbinV2DecodeErrorCode::InvalidHeader;
|
||||
QbinDecodeErrorCode code = QbinDecodeErrorCode::InvalidHeader;
|
||||
std::string detail;
|
||||
std::shared_ptr<const DecodedFieldFrame> frame;
|
||||
bool accepted() const { return code == QbinV2DecodeErrorCode::Accepted && static_cast<bool>(frame); }
|
||||
bool accepted() const { return code == QbinDecodeErrorCode::Accepted && static_cast<bool>(frame); }
|
||||
};
|
||||
|
||||
class QbinV2Decoder final {
|
||||
@@ -40,7 +63,7 @@ enum class EncodedFieldIngressCode : uint8_t { Accepted, DecodeRejected, Contrac
|
||||
struct EncodedFieldIngressResult {
|
||||
EncodedFieldIngressCode code = EncodedFieldIngressCode::DecodeRejected;
|
||||
std::string detail;
|
||||
QbinV2DecodeErrorCode decodeCode = QbinV2DecodeErrorCode::InvalidHeader;
|
||||
QbinDecodeErrorCode decodeCode = QbinDecodeErrorCode::InvalidHeader;
|
||||
FieldProfileValidationCode contractCode = FieldProfileValidationCode::InvalidContract;
|
||||
std::shared_ptr<const DecodedFieldFrame> frame;
|
||||
bool accepted() const { return code == EncodedFieldIngressCode::Accepted && static_cast<bool>(frame); }
|
||||
|
||||
27
include/mbgl/particle/ingress/qbin_v3_decoder.hpp
Normal file
27
include/mbgl/particle/ingress/qbin_v3_decoder.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/particle/ingress/qbin_v2_decoder.hpp>
|
||||
|
||||
namespace mbgl::particle::ingress {
|
||||
|
||||
using QbinV3DecodeErrorCode = QbinDecodeErrorCode;
|
||||
|
||||
struct QbinV3DecodeResult {
|
||||
QbinDecodeErrorCode code = QbinDecodeErrorCode::InvalidHeader;
|
||||
std::string detail;
|
||||
std::shared_ptr<const DecodedFieldFrame> frame;
|
||||
|
||||
bool accepted() const {
|
||||
return code == QbinDecodeErrorCode::Accepted && static_cast<bool>(frame);
|
||||
}
|
||||
};
|
||||
|
||||
class QbinV3Decoder final {
|
||||
public:
|
||||
static constexpr uint32_t BlockWidth = 16;
|
||||
static constexpr uint32_t BlockHeight = 16;
|
||||
|
||||
static QbinV3DecodeResult decode(const EncodedFieldRuntimeMetadata&, std::span<const uint8_t>);
|
||||
};
|
||||
|
||||
} // namespace mbgl::particle::ingress
|
||||
Reference in New Issue
Block a user