15#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
16#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_DECODING_TRANSFORM_H_
17#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_DECODING_TRANSFORM_H_
33template <
typename DataTypeT>
34class PredictionSchemeNormalOctahedronDecodingTransform
37 typedef VectorD<DataTypeT, 2> Point2;
38 typedef DataTypeT CorrType;
41 PredictionSchemeNormalOctahedronDecodingTransform() {}
44 void Init(
int num_components) {}
45 bool DecodeTransformData(DecoderBuffer *buffer) {
46 DataTypeT max_quantized_value, center_value;
47 if (!buffer->Decode(&max_quantized_value)) {
51 if (!buffer->Decode(¢er_value)) {
56 return this->set_max_quantized_value(max_quantized_value);
59 inline void ComputeOriginalValue(
const DataType *pred_vals,
60 const CorrType *corr_vals,
61 DataType *out_orig_vals)
const {
72 const Point2 pred = Point2(pred_vals[0], pred_vals[1]);
73 const Point2 corr = Point2(corr_vals[0], corr_vals[1]);
74 const Point2 orig = ComputeOriginalValue(pred, corr);
76 out_orig_vals[0] = orig[0];
77 out_orig_vals[1] = orig[1];
81 Point2 ComputeOriginalValue(Point2 pred,
const Point2 &corr)
const {
82 const Point2 t(this->center_value(), this->center_value());
83 typedef typename std::make_unsigned<DataTypeT>::type UnsignedDataTypeT;
84 typedef VectorD<UnsignedDataTypeT, 2> Point2u;
88 pred = Point2(Point2u(pred) - Point2u(t));
90 const bool pred_is_in_diamond = this->IsInDiamond(pred[0], pred[1]);
91 if (!pred_is_in_diamond) {
92 this->InvertDiamond(&pred[0], &pred[1]);
97 Point2 orig(Point2u(pred) + Point2u(corr));
99 orig[0] = this->ModMax(orig[0]);
100 orig[1] = this->ModMax(orig[1]);
101 if (!pred_is_in_diamond) {
102 this->InvertDiamond(&orig[0], &orig[1]);
107 orig = Point2(Point2u(orig) + Point2u(t));
#define DRACO_BITSTREAM_VERSION(MAJOR, MINOR)
Definition macros.h:114
#define DRACO_DCHECK_LE(a, b)
Definition macros.h:85
Definition attribute_octahedron_transform.cc:21
DataType
Definition draco_types.h:26