GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
prediction_scheme_normal_octahedron_transform_base.h
Go to the documentation of this file.
1// Copyright 2016 The Draco Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_TRANSFORM_BASE_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_TRANSFORM_BASE_H_
17
18#include <cmath>
19
23#include "draco/core/macros.h"
24#include "draco/core/vector_d.h"
25
26namespace draco {
27
28// Base class containing shared functionality used by both encoding and decoding
29// octahedral normal prediction scheme transforms. See the encoding transform
30// for more details about the method.
31template <typename DataTypeT>
33 public:
35 typedef DataTypeT DataType;
36
38 // We expect the mod value to be of the form 2^b-1.
43
47
48 // We can return true as we keep correction values positive.
49 bool AreCorrectionsPositive() const { return true; }
50
51 inline DataTypeT max_quantized_value() const {
52 return octahedron_tool_box_.max_quantized_value();
53 }
54 inline DataTypeT center_value() const {
55 return octahedron_tool_box_.center_value();
56 }
57 inline int32_t quantization_bits() const {
58 return octahedron_tool_box_.quantization_bits();
59 }
60
61 protected:
63 if (max_quantized_value % 2 == 0) {
64 return false;
65 }
67 return octahedron_tool_box_.SetQuantizationBits(q);
68 }
69
70 bool IsInDiamond(DataTypeT s, DataTypeT t) const {
71 return octahedron_tool_box_.IsInDiamond(s, t);
72 }
73 void InvertDiamond(DataTypeT *s, DataTypeT *t) const {
74 return octahedron_tool_box_.InvertDiamond(s, t);
75 }
76
77 int32_t ModMax(int32_t x) const { return octahedron_tool_box_.ModMax(x); }
78
79 // For correction values.
80 int32_t MakePositive(int32_t x) const {
81 return octahedron_tool_box_.MakePositive(x);
82 }
83
84 private:
85 OctahedronToolBox octahedron_tool_box_;
86};
87
88} // namespace draco
89
90#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_TRANSFORM_BASE_H_
Definition normal_compression_utils.h:50
void InvertDiamond(DataTypeT *s, DataTypeT *t) const
Definition prediction_scheme_normal_octahedron_transform_base.h:73
DataTypeT max_quantized_value() const
Definition prediction_scheme_normal_octahedron_transform_base.h:51
static constexpr PredictionSchemeTransformType GetType()
Definition prediction_scheme_normal_octahedron_transform_base.h:44
PredictionSchemeNormalOctahedronTransformBase(DataType max_quantized_value)
Definition prediction_scheme_normal_octahedron_transform_base.h:39
PredictionSchemeNormalOctahedronTransformBase()
Definition prediction_scheme_normal_octahedron_transform_base.h:37
VectorD< DataTypeT, 2 > Point2
Definition prediction_scheme_normal_octahedron_transform_base.h:34
DataTypeT center_value() const
Definition prediction_scheme_normal_octahedron_transform_base.h:54
bool set_max_quantized_value(DataTypeT max_quantized_value)
Definition prediction_scheme_normal_octahedron_transform_base.h:62
int32_t ModMax(int32_t x) const
Definition prediction_scheme_normal_octahedron_transform_base.h:77
DataTypeT DataType
Definition prediction_scheme_normal_octahedron_transform_base.h:35
int32_t quantization_bits() const
Definition prediction_scheme_normal_octahedron_transform_base.h:57
bool IsInDiamond(DataTypeT s, DataTypeT t) const
Definition prediction_scheme_normal_octahedron_transform_base.h:70
int32_t MakePositive(int32_t x) const
Definition prediction_scheme_normal_octahedron_transform_base.h:80
bool AreCorrectionsPositive() const
Definition prediction_scheme_normal_octahedron_transform_base.h:49
Definition vector_d.h:30
Definition attribute_octahedron_transform.cc:21
int MostSignificantBit(uint32_t n)
Definition bit_utils.h:58
PredictionSchemeTransformType
Definition compression_shared.h:96
@ PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON
Definition compression_shared.h:105