GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
sequential_normal_attribute_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_SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_H_
17
23
24namespace draco {
25
26// Class for encoding normal vectors using an octahedral encoding, see Cigolle
27// et al.'14 “A Survey of Efficient Representations for Independent Unit
28// Vectors”. Compared to the basic quantization encoder, this encoder results
29// in a better compression rate under the same accuracy settings. Note that this
30// encoder doesn't preserve the lengths of input vectors, therefore it will not
31// work correctly when the input values are not normalized.
34 public:
35 uint8_t GetUniqueId() const override {
37 }
38 bool IsLossyEncoder() const override { return true; }
39
40 bool EncodeDataNeededByPortableTransform(EncoderBuffer *out_buffer) override;
41
42 protected:
43 bool Init(PointCloudEncoder *encoder, int attribute_id) override;
44
45 // Put quantized values in portable attribute for sequential encoding.
46 bool PrepareValues(const std::vector<PointIndex> &point_ids,
47 int num_points) override;
48
49 std::unique_ptr<PredictionSchemeTypedEncoderInterface<int32_t>>
52 int32_t>
53 Transform;
54 const int32_t quantization_bits = encoder()->options()->GetAttributeInt(
55 attribute_id(), "quantization_bits", -1);
56 const int32_t max_value = (1 << quantization_bits) - 1;
57 const Transform transform(max_value);
58 const PredictionSchemeMethod default_prediction_method =
60 const int32_t prediction_method = encoder()->options()->GetAttributeInt(
61 attribute_id(), "prediction_scheme", default_prediction_method);
62
63 if (prediction_method == MESH_PREDICTION_GEOMETRIC_NORMAL) {
66 transform);
67 }
68 if (prediction_method == PREDICTION_DIFFERENCE) {
71 }
72 DRACO_DCHECK(false); // Should never be reached.
73 return nullptr;
74 }
75
76 // Used for the conversion to quantized normals in octahedral format.
78};
79
80} // namespace draco
81
82#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_H_
Definition attribute_octahedron_transform.h:26
int GetAttributeInt(const AttributeKey &att_key, const std::string &name, int default_val) const
Definition draco_options.h:158
Definition encoder_buffer.h:29
Definition point_cloud_encoder.h:29
const EncoderOptions * options() const
Definition point_cloud_encoder.h:76
Definition prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h:51
PointCloudEncoder * encoder() const
Definition sequential_attribute_encoder.h:83
int attribute_id() const
Definition sequential_attribute_encoder.h:82
SequentialIntegerAttributeEncoder()
Definition sequential_integer_attribute_encoder.cc:24
Definition sequential_normal_attribute_encoder.h:33
bool IsLossyEncoder() const override
Definition sequential_normal_attribute_encoder.h:38
bool PrepareValues(const std::vector< PointIndex > &point_ids, int num_points) override
Definition sequential_normal_attribute_encoder.cc:46
AttributeOctahedronTransform attribute_octahedron_transform_
Definition sequential_normal_attribute_encoder.h:77
bool Init(PointCloudEncoder *encoder, int attribute_id) override
Definition sequential_normal_attribute_encoder.cc:21
std::unique_ptr< PredictionSchemeTypedEncoderInterface< int32_t > > CreateIntPredictionScheme(PredictionSchemeMethod) override
Definition sequential_normal_attribute_encoder.h:50
uint8_t GetUniqueId() const override
Definition sequential_normal_attribute_encoder.h:35
bool EncodeDataNeededByPortableTransform(EncoderBuffer *out_buffer) override
Definition sequential_normal_attribute_encoder.cc:41
#define DRACO_DCHECK(x)
Definition macros.h:80
Definition attribute_octahedron_transform.cc:21
PredictionSchemeMethod SelectPredictionMethod(int att_id, const PointCloudEncoder *encoder)
Definition prediction_scheme_encoder_factory.cc:21
@ SEQUENTIAL_ATTRIBUTE_ENCODER_NORMALS
Definition compression_shared.h:76
std::unique_ptr< PredictionSchemeEncoder< DataTypeT, TransformT > > CreatePredictionSchemeForEncoder(PredictionSchemeMethod method, int att_id, const PointCloudEncoder *encoder, const TransformT &transform)
Definition prediction_scheme_encoder_factory.h:86
PredictionSchemeMethod
Definition compression_shared.h:80
@ MESH_PREDICTION_GEOMETRIC_NORMAL
Definition compression_shared.h:91
@ PREDICTION_DIFFERENCE
Definition compression_shared.h:85