GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
prediction_scheme_decoding_transform.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_DECODING_TRANSFORM_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODING_TRANSFORM_H_
17
20
21namespace draco {
22
23// PredictionSchemeDecodingTransform is used to transform predicted values and
24// correction values into the final original attribute values.
25// DataTypeT is the data type of predicted values.
26// CorrTypeT is the data type used for storing corrected values. It allows
27// transforms to store corrections into a different type or format compared to
28// the predicted data.
29template <typename DataTypeT, typename CorrTypeT>
31 public:
32 typedef CorrTypeT CorrType;
33 PredictionSchemeDecodingTransform() : num_components_(0) {}
34
35 void Init(int num_components) { num_components_ = num_components; }
36
37 // Computes the original value from the input predicted value and the decoded
38 // corrections. The default implementation is equal to std:plus.
39 inline void ComputeOriginalValue(const DataTypeT *predicted_vals,
40 const CorrTypeT *corr_vals,
41 DataTypeT *out_original_vals) const {
42 static_assert(std::is_same<DataTypeT, CorrTypeT>::value,
43 "For the default prediction transform, correction and input "
44 "data must be of the same type.");
45 for (int i = 0; i < num_components_; ++i) {
46 out_original_vals[i] = predicted_vals[i] + corr_vals[i];
47 }
48 }
49
50 // Decodes any transform specific data. Called before Init() method.
51 bool DecodeTransformData(DecoderBuffer * /* buffer */) { return true; }
52
53 // Should return true if all corrected values are guaranteed to be positive.
54 bool AreCorrectionsPositive() const { return false; }
55
56 protected:
57 int num_components() const { return num_components_; }
58
59 private:
60 int num_components_;
61};
62
63} // namespace draco
64
65#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODING_TRANSFORM_H_
Definition decoder_buffer.h:30
bool DecodeTransformData(DecoderBuffer *)
Definition prediction_scheme_decoding_transform.h:51
bool AreCorrectionsPositive() const
Definition prediction_scheme_decoding_transform.h:54
void Init(int num_components)
Definition prediction_scheme_decoding_transform.h:35
CorrTypeT CorrType
Definition prediction_scheme_decoding_transform.h:32
int num_components() const
Definition prediction_scheme_decoding_transform.h:57
void ComputeOriginalValue(const DataTypeT *predicted_vals, const CorrTypeT *corr_vals, DataTypeT *out_original_vals) const
Definition prediction_scheme_decoding_transform.h:39
PredictionSchemeDecodingTransform()
Definition prediction_scheme_decoding_transform.h:33
Definition attribute_octahedron_transform.cc:21