GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
prediction_scheme_encoder.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_ENCODER_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_H_
17
18#include <type_traits>
19
22
23// Prediction schemes can be used during encoding and decoding of vertex
24// attributes to predict attribute values based on the previously
25// encoded/decoded data. The differences between the original and predicted
26// attribute values are used to compute correction values that can be usually
27// encoded with fewer bits compared to the original data.
28namespace draco {
29
30// Abstract base class for typed prediction schemes. It provides basic access
31// to the encoded attribute and to the supplied prediction transform.
32template <typename DataTypeT,
33 class TransformT =
36 DataTypeT, typename TransformT::CorrType> {
37 public:
38 typedef DataTypeT DataType;
39 typedef TransformT Transform;
40 // Correction type needs to be defined in the prediction transform class.
41 typedef typename Transform::CorrType CorrType;
45 const Transform &transform)
46 : attribute_(attribute), transform_(transform) {}
47
48 bool EncodePredictionData(EncoderBuffer *buffer) override {
49 if (!transform_.EncodeTransformData(buffer)) {
50 return false;
51 }
52 return true;
53 }
54
55 const PointAttribute *GetAttribute() const override { return attribute(); }
56
57 // Returns the number of parent attributes that are needed for the prediction.
58 int GetNumParentAttributes() const override { return 0; }
59
60 // Returns the type of each of the parent attribute.
61 GeometryAttribute::Type GetParentAttributeType(int /* i */) const override {
63 }
64
65 // Sets the required parent attribute.
66 bool SetParentAttribute(const PointAttribute * /* att */) override {
67 return false;
68 }
69
70 bool AreCorrectionsPositive() override {
71 return transform_.AreCorrectionsPositive();
72 }
73
75 return transform_.GetType();
76 }
77
78 protected:
79 inline const PointAttribute *attribute() const { return attribute_; }
80 inline const Transform &transform() const { return transform_; }
81 inline Transform &transform() { return transform_; }
82
83 private:
84 const PointAttribute *attribute_;
85 Transform transform_;
86};
87
88} // namespace draco
89
90#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_H_
Definition encoder_buffer.h:29
Type
Definition geometry_attribute.h:46
@ INVALID
Definition geometry_attribute.h:47
Definition point_attribute.h:33
GeometryAttribute::Type GetParentAttributeType(int) const override
Definition prediction_scheme_encoder.h:61
const PointAttribute * attribute() const
Definition prediction_scheme_encoder.h:79
DataTypeT DataType
Definition prediction_scheme_encoder.h:38
int GetNumParentAttributes() const override
Definition prediction_scheme_encoder.h:58
Transform::CorrType CorrType
Definition prediction_scheme_encoder.h:41
PredictionSchemeEncoder(const PointAttribute *attribute, const Transform &transform)
Definition prediction_scheme_encoder.h:44
PredictionSchemeEncoder(const PointAttribute *attribute)
Definition prediction_scheme_encoder.h:42
bool AreCorrectionsPositive() override
Definition prediction_scheme_encoder.h:70
PredictionSchemeTransformType GetTransformType() const override
Definition prediction_scheme_encoder.h:74
Transform & transform()
Definition prediction_scheme_encoder.h:81
bool SetParentAttribute(const PointAttribute *) override
Definition prediction_scheme_encoder.h:66
const Transform & transform() const
Definition prediction_scheme_encoder.h:80
TransformT Transform
Definition prediction_scheme_encoder.h:39
bool EncodePredictionData(EncoderBuffer *buffer) override
Definition prediction_scheme_encoder.h:48
const PointAttribute * GetAttribute() const override
Definition prediction_scheme_encoder.h:55
Definition prediction_scheme_encoding_transform.h:29
Definition prediction_scheme_encoder_interface.h:43
Definition attribute_octahedron_transform.cc:21
PredictionSchemeTransformType
Definition compression_shared.h:96