dracox 0.0.1__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bin/draco_decoder.exe +0 -0
- bin/draco_encoder.exe +0 -0
- dracox/__init__.py +252 -0
- dracox/dracox_ext.cp39-win_amd64.pyd +0 -0
- dracox-0.0.1.dist-info/METADATA +14 -0
- dracox-0.0.1.dist-info/RECORD +214 -0
- dracox-0.0.1.dist-info/WHEEL +5 -0
- include/draco/animation/keyframe_animation.h +107 -0
- include/draco/animation/keyframe_animation_decoder.h +34 -0
- include/draco/animation/keyframe_animation_encoder.h +39 -0
- include/draco/attributes/attribute_octahedron_transform.h +81 -0
- include/draco/attributes/attribute_quantization_transform.h +102 -0
- include/draco/attributes/attribute_transform.h +76 -0
- include/draco/attributes/attribute_transform_data.h +71 -0
- include/draco/attributes/attribute_transform_type.h +30 -0
- include/draco/attributes/geometry_attribute.h +541 -0
- include/draco/attributes/geometry_indices.h +54 -0
- include/draco/attributes/point_attribute.h +196 -0
- include/draco/compression/attributes/attributes_decoder.h +97 -0
- include/draco/compression/attributes/attributes_decoder_interface.h +62 -0
- include/draco/compression/attributes/attributes_encoder.h +154 -0
- include/draco/compression/attributes/kd_tree_attributes_decoder.h +50 -0
- include/draco/compression/attributes/kd_tree_attributes_encoder.h +51 -0
- include/draco/compression/attributes/kd_tree_attributes_shared.h +28 -0
- include/draco/compression/attributes/linear_sequencer.h +51 -0
- include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h +58 -0
- include/draco/compression/attributes/normal_compression_utils.h +372 -0
- include/draco/compression/attributes/point_d_vector.h +288 -0
- include/draco/compression/attributes/points_sequencer.h +63 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h +236 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h +413 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h +34 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h +72 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h +46 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h +46 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h +176 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h +180 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h +117 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h +96 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h +128 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h +133 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h +111 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h +78 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h +372 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h +318 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h +143 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h +136 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h +282 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h +194 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h +53 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h +65 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h +65 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h +69 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h +134 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h +55 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h +77 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h +85 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h +60 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h +118 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h +116 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h +102 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h +115 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h +105 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h +88 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h +81 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h +120 -0
- include/draco/compression/attributes/sequential_attribute_decoder.h +86 -0
- include/draco/compression/attributes/sequential_attribute_decoders_controller.h +61 -0
- include/draco/compression/attributes/sequential_attribute_encoder.h +134 -0
- include/draco/compression/attributes/sequential_attribute_encoders_controller.h +115 -0
- include/draco/compression/attributes/sequential_integer_attribute_decoder.h +76 -0
- include/draco/compression/attributes/sequential_integer_attribute_encoder.h +67 -0
- include/draco/compression/attributes/sequential_normal_attribute_decoder.h +83 -0
- include/draco/compression/attributes/sequential_normal_attribute_encoder.h +82 -0
- include/draco/compression/attributes/sequential_quantization_attribute_decoder.h +52 -0
- include/draco/compression/attributes/sequential_quantization_attribute_encoder.h +52 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h +43 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h +54 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h +61 -0
- include/draco/compression/bit_coders/direct_bit_decoder.h +89 -0
- include/draco/compression/bit_coders/direct_bit_encoder.h +89 -0
- include/draco/compression/bit_coders/folded_integer_bit_decoder.h +77 -0
- include/draco/compression/bit_coders/folded_integer_bit_encoder.h +82 -0
- include/draco/compression/bit_coders/rans_bit_decoder.h +55 -0
- include/draco/compression/bit_coders/rans_bit_encoder.h +57 -0
- include/draco/compression/bit_coders/symbol_bit_decoder.h +36 -0
- include/draco/compression/bit_coders/symbol_bit_encoder.h +36 -0
- include/draco/compression/config/compression_shared.h +155 -0
- include/draco/compression/config/decoder_options.h +34 -0
- include/draco/compression/config/draco_options.h +249 -0
- include/draco/compression/config/encoder_options.h +101 -0
- include/draco/compression/config/encoding_features.h +39 -0
- include/draco/compression/decode.h +80 -0
- include/draco/compression/draco_compression_options.h +141 -0
- include/draco/compression/encode.h +139 -0
- include/draco/compression/encode_base.h +131 -0
- include/draco/compression/entropy/ans.h +526 -0
- include/draco/compression/entropy/rans_symbol_coding.h +53 -0
- include/draco/compression/entropy/rans_symbol_decoder.h +171 -0
- include/draco/compression/entropy/rans_symbol_encoder.h +290 -0
- include/draco/compression/entropy/shannon_entropy.h +110 -0
- include/draco/compression/entropy/symbol_decoding.h +29 -0
- include/draco/compression/entropy/symbol_encoding.h +47 -0
- include/draco/compression/expert_encode.h +160 -0
- include/draco/compression/mesh/mesh_decoder.h +68 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder.h +54 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h +228 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h +47 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder.h +73 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h +209 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h +57 -0
- include/draco/compression/mesh/mesh_edgebreaker_shared.h +129 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h +201 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h +139 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h +134 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h +172 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h +219 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h +226 -0
- include/draco/compression/mesh/mesh_encoder.h +84 -0
- include/draco/compression/mesh/mesh_sequential_decoder.h +39 -0
- include/draco/compression/mesh/mesh_sequential_encoder.h +56 -0
- include/draco/compression/mesh/traverser/depth_first_traverser.h +172 -0
- include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h +226 -0
- include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h +76 -0
- include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h +113 -0
- include/draco/compression/mesh/traverser/traverser_base.h +87 -0
- include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h +369 -0
- include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h +372 -0
- include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h +141 -0
- include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h +126 -0
- include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h +34 -0
- include/draco/compression/point_cloud/algorithms/point_cloud_types.h +76 -0
- include/draco/compression/point_cloud/algorithms/quantize_points_3.h +84 -0
- include/draco/compression/point_cloud/algorithms/queuing_policy.h +75 -0
- include/draco/compression/point_cloud/point_cloud_decoder.h +118 -0
- include/draco/compression/point_cloud/point_cloud_encoder.h +158 -0
- include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h +31 -0
- include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h +45 -0
- include/draco/compression/point_cloud/point_cloud_sequential_decoder.h +33 -0
- include/draco/compression/point_cloud/point_cloud_sequential_encoder.h +43 -0
- include/draco/core/bit_utils.h +127 -0
- include/draco/core/bounding_box.h +77 -0
- include/draco/core/constants.h +6 -0
- include/draco/core/cycle_timer.h +51 -0
- include/draco/core/data_buffer.h +82 -0
- include/draco/core/decoder_buffer.h +216 -0
- include/draco/core/divide.h +42 -0
- include/draco/core/draco_index_type.h +184 -0
- include/draco/core/draco_index_type_vector.h +90 -0
- include/draco/core/draco_types.h +52 -0
- include/draco/core/draco_version.h +25 -0
- include/draco/core/encoder_buffer.h +152 -0
- include/draco/core/hash_utils.h +64 -0
- include/draco/core/macros.h +124 -0
- include/draco/core/math_utils.h +79 -0
- include/draco/core/options.h +151 -0
- include/draco/core/quantization_utils.h +82 -0
- include/draco/core/status.h +83 -0
- include/draco/core/status_or.h +81 -0
- include/draco/core/varint_decoding.h +81 -0
- include/draco/core/varint_encoding.h +61 -0
- include/draco/core/vector_d.h +355 -0
- include/draco/draco_features.h +25 -0
- include/draco/io/file_reader_factory.h +34 -0
- include/draco/io/file_reader_interface.h +32 -0
- include/draco/io/file_utils.h +86 -0
- include/draco/io/file_writer_factory.h +34 -0
- include/draco/io/file_writer_interface.h +26 -0
- include/draco/io/file_writer_utils.h +38 -0
- include/draco/io/mesh_io.h +107 -0
- include/draco/io/obj_decoder.h +147 -0
- include/draco/io/obj_encoder.h +107 -0
- include/draco/io/parser_utils.h +66 -0
- include/draco/io/ply_decoder.h +69 -0
- include/draco/io/ply_encoder.h +54 -0
- include/draco/io/ply_property_reader.h +96 -0
- include/draco/io/ply_property_writer.h +94 -0
- include/draco/io/ply_reader.h +155 -0
- include/draco/io/point_cloud_io.h +89 -0
- include/draco/io/stdio_file_reader.h +48 -0
- include/draco/io/stdio_file_writer.h +42 -0
- include/draco/io/stl_decoder.h +38 -0
- include/draco/io/stl_encoder.h +52 -0
- include/draco/mesh/corner_table.h +397 -0
- include/draco/mesh/corner_table_iterators.h +309 -0
- include/draco/mesh/mesh.h +378 -0
- include/draco/mesh/mesh_are_equivalent.h +71 -0
- include/draco/mesh/mesh_attribute_corner_table.h +202 -0
- include/draco/mesh/mesh_cleanup.h +61 -0
- include/draco/mesh/mesh_features.h +93 -0
- include/draco/mesh/mesh_indices.h +37 -0
- include/draco/mesh/mesh_misc_functions.h +105 -0
- include/draco/mesh/mesh_stripifier.h +258 -0
- include/draco/mesh/triangle_soup_mesh_builder.h +134 -0
- include/draco/mesh/valence_cache.h +142 -0
- include/draco/metadata/geometry_metadata.h +142 -0
- include/draco/metadata/metadata.h +209 -0
- include/draco/metadata/metadata_decoder.h +42 -0
- include/draco/metadata/metadata_encoder.h +41 -0
- include/draco/metadata/property_attribute.h +107 -0
- include/draco/metadata/property_table.h +222 -0
- include/draco/metadata/structural_metadata.h +78 -0
- include/draco/metadata/structural_metadata_schema.h +118 -0
- include/draco/point_cloud/point_cloud.h +289 -0
- include/draco/point_cloud/point_cloud_builder.h +101 -0
- lib/draco.lib +0 -0
- lib/pkgconfig/draco.pc +6 -0
- share/cmake/draco/draco-config-version.cmake +43 -0
- share/cmake/draco/draco-config.cmake +27 -0
- share/cmake/draco/draco-targets-release.cmake +19 -0
- share/cmake/draco/draco-targets.cmake +107 -0
include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
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_WRAP_TRANSFORM_BASE_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_
|
|
17
|
+
|
|
18
|
+
#include <limits>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
#include "draco/compression/config/compression_shared.h"
|
|
22
|
+
#include "draco/core/macros.h"
|
|
23
|
+
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
// PredictionSchemeWrapTransform uses the min and max bounds of the original
|
|
27
|
+
// data to wrap stored correction values around these bounds centered at 0,
|
|
28
|
+
// i.e., when the range of the original values O is between <MIN, MAX> and
|
|
29
|
+
// N = MAX-MIN, we can then store any correction X = O - P, as:
|
|
30
|
+
// X + N, if X < -N / 2
|
|
31
|
+
// X - N, if X > N / 2
|
|
32
|
+
// X otherwise
|
|
33
|
+
// To unwrap this value, the decoder then simply checks whether the final
|
|
34
|
+
// corrected value F = P + X is out of the bounds of the input values.
|
|
35
|
+
// All out of bounds values are unwrapped using
|
|
36
|
+
// F + N, if F < MIN
|
|
37
|
+
// F - N, if F > MAX
|
|
38
|
+
// This wrapping can reduce the number of unique values, which translates to a
|
|
39
|
+
// better entropy of the stored values and better compression rates.
|
|
40
|
+
template <typename DataTypeT>
|
|
41
|
+
class PredictionSchemeWrapTransformBase {
|
|
42
|
+
public:
|
|
43
|
+
PredictionSchemeWrapTransformBase()
|
|
44
|
+
: num_components_(0),
|
|
45
|
+
min_value_(0),
|
|
46
|
+
max_value_(0),
|
|
47
|
+
max_dif_(0),
|
|
48
|
+
max_correction_(0),
|
|
49
|
+
min_correction_(0) {}
|
|
50
|
+
|
|
51
|
+
static constexpr PredictionSchemeTransformType GetType() {
|
|
52
|
+
return PREDICTION_TRANSFORM_WRAP;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void Init(int num_components) {
|
|
56
|
+
num_components_ = num_components;
|
|
57
|
+
clamped_value_.resize(num_components);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
bool AreCorrectionsPositive() const { return false; }
|
|
61
|
+
|
|
62
|
+
inline const DataTypeT *ClampPredictedValue(
|
|
63
|
+
const DataTypeT *predicted_val) const {
|
|
64
|
+
for (int i = 0; i < this->num_components(); ++i) {
|
|
65
|
+
if (predicted_val[i] > max_value_) {
|
|
66
|
+
clamped_value_[i] = max_value_;
|
|
67
|
+
} else if (predicted_val[i] < min_value_) {
|
|
68
|
+
clamped_value_[i] = min_value_;
|
|
69
|
+
} else {
|
|
70
|
+
clamped_value_[i] = predicted_val[i];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return clamped_value_.data();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// TODO(b/199760123): Consider refactoring to avoid this dummy.
|
|
77
|
+
int quantization_bits() const {
|
|
78
|
+
DRACO_DCHECK(false);
|
|
79
|
+
return -1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected:
|
|
83
|
+
bool InitCorrectionBounds() {
|
|
84
|
+
const int64_t dif =
|
|
85
|
+
static_cast<int64_t>(max_value_) - static_cast<int64_t>(min_value_);
|
|
86
|
+
if (dif < 0 || dif >= std::numeric_limits<DataTypeT>::max()) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
max_dif_ = 1 + static_cast<DataTypeT>(dif);
|
|
90
|
+
max_correction_ = max_dif_ / 2;
|
|
91
|
+
min_correction_ = -max_correction_;
|
|
92
|
+
if ((max_dif_ & 1) == 0) {
|
|
93
|
+
max_correction_ -= 1;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
inline int num_components() const { return num_components_; }
|
|
99
|
+
inline DataTypeT min_value() const { return min_value_; }
|
|
100
|
+
inline void set_min_value(const DataTypeT &v) { min_value_ = v; }
|
|
101
|
+
inline DataTypeT max_value() const { return max_value_; }
|
|
102
|
+
inline void set_max_value(const DataTypeT &v) { max_value_ = v; }
|
|
103
|
+
inline DataTypeT max_dif() const { return max_dif_; }
|
|
104
|
+
inline DataTypeT min_correction() const { return min_correction_; }
|
|
105
|
+
inline DataTypeT max_correction() const { return max_correction_; }
|
|
106
|
+
|
|
107
|
+
private:
|
|
108
|
+
int num_components_;
|
|
109
|
+
DataTypeT min_value_;
|
|
110
|
+
DataTypeT max_value_;
|
|
111
|
+
DataTypeT max_dif_;
|
|
112
|
+
DataTypeT max_correction_;
|
|
113
|
+
DataTypeT min_correction_;
|
|
114
|
+
// This is in fact just a tmp variable to avoid reallocation.
|
|
115
|
+
mutable std::vector<DataTypeT> clamped_value_;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
} // namespace draco
|
|
119
|
+
|
|
120
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_
|
|
@@ -0,0 +1,86 @@
|
|
|
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_ATTRIBUTE_DECODER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h"
|
|
19
|
+
#include "draco/compression/point_cloud/point_cloud_decoder.h"
|
|
20
|
+
#include "draco/draco_features.h"
|
|
21
|
+
|
|
22
|
+
namespace draco {
|
|
23
|
+
|
|
24
|
+
// A base class for decoding attribute values encoded by the
|
|
25
|
+
// SequentialAttributeEncoder.
|
|
26
|
+
class SequentialAttributeDecoder {
|
|
27
|
+
public:
|
|
28
|
+
SequentialAttributeDecoder();
|
|
29
|
+
virtual ~SequentialAttributeDecoder() = default;
|
|
30
|
+
|
|
31
|
+
virtual bool Init(PointCloudDecoder *decoder, int attribute_id);
|
|
32
|
+
|
|
33
|
+
// Initialization for a specific attribute. This can be used mostly for
|
|
34
|
+
// standalone decoding of an attribute without an PointCloudDecoder.
|
|
35
|
+
virtual bool InitializeStandalone(PointAttribute *attribute);
|
|
36
|
+
|
|
37
|
+
// Performs lossless decoding of the portable attribute data.
|
|
38
|
+
virtual bool DecodePortableAttribute(const std::vector<PointIndex> &point_ids,
|
|
39
|
+
DecoderBuffer *in_buffer);
|
|
40
|
+
|
|
41
|
+
// Decodes any data needed to revert portable transform of the decoded
|
|
42
|
+
// attribute.
|
|
43
|
+
virtual bool DecodeDataNeededByPortableTransform(
|
|
44
|
+
const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer);
|
|
45
|
+
|
|
46
|
+
// Reverts transformation performed by encoder in
|
|
47
|
+
// SequentialAttributeEncoder::TransformAttributeToPortableFormat() method.
|
|
48
|
+
virtual bool TransformAttributeToOriginalFormat(
|
|
49
|
+
const std::vector<PointIndex> &point_ids);
|
|
50
|
+
|
|
51
|
+
const PointAttribute *GetPortableAttribute();
|
|
52
|
+
|
|
53
|
+
const PointAttribute *attribute() const { return attribute_; }
|
|
54
|
+
PointAttribute *attribute() { return attribute_; }
|
|
55
|
+
int attribute_id() const { return attribute_id_; }
|
|
56
|
+
PointCloudDecoder *decoder() const { return decoder_; }
|
|
57
|
+
|
|
58
|
+
protected:
|
|
59
|
+
// Should be used to initialize newly created prediction scheme.
|
|
60
|
+
// Returns false when the initialization failed (in which case the scheme
|
|
61
|
+
// cannot be used).
|
|
62
|
+
virtual bool InitPredictionScheme(PredictionSchemeInterface *ps);
|
|
63
|
+
|
|
64
|
+
// The actual implementation of the attribute decoding. Should be overridden
|
|
65
|
+
// for specialized decoders.
|
|
66
|
+
virtual bool DecodeValues(const std::vector<PointIndex> &point_ids,
|
|
67
|
+
DecoderBuffer *in_buffer);
|
|
68
|
+
|
|
69
|
+
void SetPortableAttribute(std::unique_ptr<PointAttribute> att) {
|
|
70
|
+
portable_attribute_ = std::move(att);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
PointAttribute *portable_attribute() { return portable_attribute_.get(); }
|
|
74
|
+
|
|
75
|
+
private:
|
|
76
|
+
PointCloudDecoder *decoder_;
|
|
77
|
+
PointAttribute *attribute_;
|
|
78
|
+
int attribute_id_;
|
|
79
|
+
|
|
80
|
+
// Storage for decoded portable attribute (after lossless decoding).
|
|
81
|
+
std::unique_ptr<PointAttribute> portable_attribute_;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace draco
|
|
85
|
+
|
|
86
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODER_H_
|
|
@@ -0,0 +1,61 @@
|
|
|
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_ATTRIBUTE_DECODERS_CONTROLLER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/attributes_decoder.h"
|
|
19
|
+
#include "draco/compression/attributes/points_sequencer.h"
|
|
20
|
+
#include "draco/compression/attributes/sequential_attribute_decoder.h"
|
|
21
|
+
|
|
22
|
+
namespace draco {
|
|
23
|
+
|
|
24
|
+
// A basic implementation of an attribute decoder that decodes data encoded by
|
|
25
|
+
// the SequentialAttributeEncodersController class. The
|
|
26
|
+
// SequentialAttributeDecodersController creates a single
|
|
27
|
+
// AttributeIndexedValuesDecoder for each of the decoded attribute, where the
|
|
28
|
+
// type of the values decoder is determined by the unique identifier that was
|
|
29
|
+
// encoded by the encoder.
|
|
30
|
+
class SequentialAttributeDecodersController : public AttributesDecoder {
|
|
31
|
+
public:
|
|
32
|
+
explicit SequentialAttributeDecodersController(
|
|
33
|
+
std::unique_ptr<PointsSequencer> sequencer);
|
|
34
|
+
|
|
35
|
+
bool DecodeAttributesDecoderData(DecoderBuffer *buffer) override;
|
|
36
|
+
bool DecodeAttributes(DecoderBuffer *buffer) override;
|
|
37
|
+
const PointAttribute *GetPortableAttribute(
|
|
38
|
+
int32_t point_attribute_id) override {
|
|
39
|
+
const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id);
|
|
40
|
+
if (loc_id < 0) {
|
|
41
|
+
return nullptr;
|
|
42
|
+
}
|
|
43
|
+
return sequential_decoders_[loc_id]->GetPortableAttribute();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected:
|
|
47
|
+
bool DecodePortableAttributes(DecoderBuffer *in_buffer) override;
|
|
48
|
+
bool DecodeDataNeededByPortableTransforms(DecoderBuffer *in_buffer) override;
|
|
49
|
+
bool TransformAttributesToOriginalFormat() override;
|
|
50
|
+
virtual std::unique_ptr<SequentialAttributeDecoder> CreateSequentialDecoder(
|
|
51
|
+
uint8_t decoder_type);
|
|
52
|
+
|
|
53
|
+
private:
|
|
54
|
+
std::vector<std::unique_ptr<SequentialAttributeDecoder>> sequential_decoders_;
|
|
55
|
+
std::vector<PointIndex> point_ids_;
|
|
56
|
+
std::unique_ptr<PointsSequencer> sequencer_;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace draco
|
|
60
|
+
|
|
61
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_H_
|
|
@@ -0,0 +1,134 @@
|
|
|
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_ATTRIBUTE_ENCODER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h"
|
|
19
|
+
#include "draco/compression/point_cloud/point_cloud_encoder.h"
|
|
20
|
+
|
|
21
|
+
namespace draco {
|
|
22
|
+
|
|
23
|
+
// A base class for encoding attribute values of a single attribute using a
|
|
24
|
+
// given sequence of point ids. The default implementation encodes all attribute
|
|
25
|
+
// values directly to the buffer but derived classes can perform any custom
|
|
26
|
+
// encoding (such as quantization) by overriding the EncodeValues() method.
|
|
27
|
+
class SequentialAttributeEncoder {
|
|
28
|
+
public:
|
|
29
|
+
SequentialAttributeEncoder();
|
|
30
|
+
virtual ~SequentialAttributeEncoder() = default;
|
|
31
|
+
|
|
32
|
+
// Method that can be used for custom initialization of an attribute encoder,
|
|
33
|
+
// such as creation of prediction schemes and initialization of attribute
|
|
34
|
+
// encoder dependencies.
|
|
35
|
+
// |encoder| is the parent PointCloudEncoder,
|
|
36
|
+
// |attribute_id| is the id of the attribute that is being encoded by this
|
|
37
|
+
// encoder.
|
|
38
|
+
// This method is automatically called by the PointCloudEncoder after all
|
|
39
|
+
// attribute encoders are created and it should not be called explicitly from
|
|
40
|
+
// other places.
|
|
41
|
+
virtual bool Init(PointCloudEncoder *encoder, int attribute_id);
|
|
42
|
+
|
|
43
|
+
// Initialization for a specific attribute. This can be used mostly for
|
|
44
|
+
// standalone encoding of an attribute without an PointCloudEncoder.
|
|
45
|
+
virtual bool InitializeStandalone(PointAttribute *attribute);
|
|
46
|
+
|
|
47
|
+
// Transforms attribute data into format that is going to be encoded
|
|
48
|
+
// losslessly. The transform itself can be lossy.
|
|
49
|
+
virtual bool TransformAttributeToPortableFormat(
|
|
50
|
+
const std::vector<PointIndex> &point_ids);
|
|
51
|
+
|
|
52
|
+
// Performs lossless encoding of the transformed attribute data.
|
|
53
|
+
virtual bool EncodePortableAttribute(const std::vector<PointIndex> &point_ids,
|
|
54
|
+
EncoderBuffer *out_buffer);
|
|
55
|
+
|
|
56
|
+
// Encodes any data related to the portable attribute transform.
|
|
57
|
+
virtual bool EncodeDataNeededByPortableTransform(EncoderBuffer *out_buffer);
|
|
58
|
+
|
|
59
|
+
virtual bool IsLossyEncoder() const { return false; }
|
|
60
|
+
|
|
61
|
+
int NumParentAttributes() const {
|
|
62
|
+
return static_cast<int>(parent_attributes_.size());
|
|
63
|
+
}
|
|
64
|
+
int GetParentAttributeId(int i) const { return parent_attributes_[i]; }
|
|
65
|
+
|
|
66
|
+
const PointAttribute *GetPortableAttribute() const {
|
|
67
|
+
if (portable_attribute_ != nullptr) {
|
|
68
|
+
return portable_attribute_.get();
|
|
69
|
+
}
|
|
70
|
+
return attribute();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Called when this attribute encoder becomes a parent encoder of another
|
|
74
|
+
// encoder.
|
|
75
|
+
void MarkParentAttribute();
|
|
76
|
+
|
|
77
|
+
virtual uint8_t GetUniqueId() const {
|
|
78
|
+
return SEQUENTIAL_ATTRIBUTE_ENCODER_GENERIC;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const PointAttribute *attribute() const { return attribute_; }
|
|
82
|
+
int attribute_id() const { return attribute_id_; }
|
|
83
|
+
PointCloudEncoder *encoder() const { return encoder_; }
|
|
84
|
+
|
|
85
|
+
protected:
|
|
86
|
+
// Should be used to initialize newly created prediction scheme.
|
|
87
|
+
// Returns false when the initialization failed (in which case the scheme
|
|
88
|
+
// cannot be used).
|
|
89
|
+
virtual bool InitPredictionScheme(PredictionSchemeInterface *ps);
|
|
90
|
+
|
|
91
|
+
// Sets parent attributes for a given prediction scheme. Must be called
|
|
92
|
+
// after all prediction schemes are initialized, but before the prediction
|
|
93
|
+
// scheme is used.
|
|
94
|
+
virtual bool SetPredictionSchemeParentAttributes(
|
|
95
|
+
PredictionSchemeInterface *ps);
|
|
96
|
+
|
|
97
|
+
// Encodes all attribute values in the specified order. Should be overridden
|
|
98
|
+
// for specialized encoders.
|
|
99
|
+
virtual bool EncodeValues(const std::vector<PointIndex> &point_ids,
|
|
100
|
+
EncoderBuffer *out_buffer);
|
|
101
|
+
|
|
102
|
+
bool is_parent_encoder() const { return is_parent_encoder_; }
|
|
103
|
+
|
|
104
|
+
void SetPortableAttribute(std::unique_ptr<PointAttribute> att) {
|
|
105
|
+
portable_attribute_ = std::move(att);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Returns a mutable attribute that should be filled by derived encoders with
|
|
109
|
+
// the transformed version of the attribute data. To get a public const
|
|
110
|
+
// version, use the GetPortableAttribute() method.
|
|
111
|
+
PointAttribute *portable_attribute() { return portable_attribute_.get(); }
|
|
112
|
+
|
|
113
|
+
private:
|
|
114
|
+
PointCloudEncoder *encoder_;
|
|
115
|
+
const PointAttribute *attribute_;
|
|
116
|
+
int attribute_id_;
|
|
117
|
+
|
|
118
|
+
// List of attribute encoders that need to be encoded before this attribute.
|
|
119
|
+
// E.g. The parent attributes may be used to predict values used by this
|
|
120
|
+
// attribute encoder.
|
|
121
|
+
std::vector<int32_t> parent_attributes_;
|
|
122
|
+
|
|
123
|
+
bool is_parent_encoder_;
|
|
124
|
+
|
|
125
|
+
// Attribute that stores transformed data from the source attribute after it
|
|
126
|
+
// is processed through the ApplyTransform() method. Attribute data stored
|
|
127
|
+
// within this attribute is guaranteed to be encoded losslessly and it can be
|
|
128
|
+
// safely used for prediction of other attributes.
|
|
129
|
+
std::unique_ptr<PointAttribute> portable_attribute_;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
} // namespace draco
|
|
133
|
+
|
|
134
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODER_H_
|
|
@@ -0,0 +1,115 @@
|
|
|
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_ATTRIBUTE_ENCODERS_CONTROLLER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/attributes_encoder.h"
|
|
19
|
+
#include "draco/compression/attributes/points_sequencer.h"
|
|
20
|
+
#include "draco/compression/attributes/sequential_attribute_encoder.h"
|
|
21
|
+
|
|
22
|
+
namespace draco {
|
|
23
|
+
|
|
24
|
+
// A basic implementation of an attribute encoder that can be used to encode
|
|
25
|
+
// an arbitrary set of attributes. The encoder creates a sequential attribute
|
|
26
|
+
// encoder for each encoded attribute (see sequential_attribute_encoder.h) and
|
|
27
|
+
// then it encodes all attribute values in an order defined by a point sequence
|
|
28
|
+
// generated in the GeneratePointSequence() method. The default implementation
|
|
29
|
+
// generates a linear sequence of all points, but derived classes can generate
|
|
30
|
+
// any custom sequence.
|
|
31
|
+
class SequentialAttributeEncodersController : public AttributesEncoder {
|
|
32
|
+
public:
|
|
33
|
+
explicit SequentialAttributeEncodersController(
|
|
34
|
+
std::unique_ptr<PointsSequencer> sequencer);
|
|
35
|
+
SequentialAttributeEncodersController(
|
|
36
|
+
std::unique_ptr<PointsSequencer> sequencer, int point_attrib_id);
|
|
37
|
+
|
|
38
|
+
bool Init(PointCloudEncoder *encoder, const PointCloud *pc) override;
|
|
39
|
+
bool EncodeAttributesEncoderData(EncoderBuffer *out_buffer) override;
|
|
40
|
+
bool EncodeAttributes(EncoderBuffer *buffer) override;
|
|
41
|
+
uint8_t GetUniqueId() const override { return BASIC_ATTRIBUTE_ENCODER; }
|
|
42
|
+
|
|
43
|
+
int NumParentAttributes(int32_t point_attribute_id) const override {
|
|
44
|
+
const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id);
|
|
45
|
+
if (loc_id < 0) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
return sequential_encoders_[loc_id]->NumParentAttributes();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
int GetParentAttributeId(int32_t point_attribute_id,
|
|
52
|
+
int32_t parent_i) const override {
|
|
53
|
+
const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id);
|
|
54
|
+
if (loc_id < 0) {
|
|
55
|
+
return -1;
|
|
56
|
+
}
|
|
57
|
+
return sequential_encoders_[loc_id]->GetParentAttributeId(parent_i);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
bool MarkParentAttribute(int32_t point_attribute_id) override {
|
|
61
|
+
const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id);
|
|
62
|
+
if (loc_id < 0) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Mark the attribute encoder as parent (even when if it is not created
|
|
66
|
+
// yet).
|
|
67
|
+
if (sequential_encoder_marked_as_parent_.size() <= loc_id) {
|
|
68
|
+
sequential_encoder_marked_as_parent_.resize(loc_id + 1, false);
|
|
69
|
+
}
|
|
70
|
+
sequential_encoder_marked_as_parent_[loc_id] = true;
|
|
71
|
+
|
|
72
|
+
if (sequential_encoders_.size() <= loc_id) {
|
|
73
|
+
return true; // Sequential encoders not generated yet.
|
|
74
|
+
}
|
|
75
|
+
sequential_encoders_[loc_id]->MarkParentAttribute();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const PointAttribute *GetPortableAttribute(
|
|
80
|
+
int32_t point_attribute_id) override {
|
|
81
|
+
const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id);
|
|
82
|
+
if (loc_id < 0) {
|
|
83
|
+
return nullptr;
|
|
84
|
+
}
|
|
85
|
+
return sequential_encoders_[loc_id]->GetPortableAttribute();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
protected:
|
|
89
|
+
bool TransformAttributesToPortableFormat() override;
|
|
90
|
+
bool EncodePortableAttributes(EncoderBuffer *out_buffer) override;
|
|
91
|
+
bool EncodeDataNeededByPortableTransforms(EncoderBuffer *out_buffer) override;
|
|
92
|
+
|
|
93
|
+
// Creates all sequential encoders (one for each attribute associated with the
|
|
94
|
+
// encoder).
|
|
95
|
+
virtual bool CreateSequentialEncoders();
|
|
96
|
+
|
|
97
|
+
// Create a sequential encoder for a given attribute based on the attribute
|
|
98
|
+
// type
|
|
99
|
+
// and the provided encoder options.
|
|
100
|
+
virtual std::unique_ptr<SequentialAttributeEncoder> CreateSequentialEncoder(
|
|
101
|
+
int i);
|
|
102
|
+
|
|
103
|
+
private:
|
|
104
|
+
std::vector<std::unique_ptr<SequentialAttributeEncoder>> sequential_encoders_;
|
|
105
|
+
|
|
106
|
+
// Flag for each sequential attribute encoder indicating whether it was marked
|
|
107
|
+
// as parent attribute or not.
|
|
108
|
+
std::vector<bool> sequential_encoder_marked_as_parent_;
|
|
109
|
+
std::vector<PointIndex> point_ids_;
|
|
110
|
+
std::unique_ptr<PointsSequencer> sequencer_;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
} // namespace draco
|
|
114
|
+
|
|
115
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_H_
|
|
@@ -0,0 +1,76 @@
|
|
|
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_INTEGER_ATTRIBUTE_DECODER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h"
|
|
19
|
+
#include "draco/compression/attributes/sequential_attribute_decoder.h"
|
|
20
|
+
#include "draco/draco_features.h"
|
|
21
|
+
|
|
22
|
+
namespace draco {
|
|
23
|
+
|
|
24
|
+
// Decoder for attributes encoded with the SequentialIntegerAttributeEncoder.
|
|
25
|
+
class SequentialIntegerAttributeDecoder : public SequentialAttributeDecoder {
|
|
26
|
+
public:
|
|
27
|
+
SequentialIntegerAttributeDecoder();
|
|
28
|
+
bool Init(PointCloudDecoder *decoder, int attribute_id) override;
|
|
29
|
+
|
|
30
|
+
bool TransformAttributeToOriginalFormat(
|
|
31
|
+
const std::vector<PointIndex> &point_ids) override;
|
|
32
|
+
|
|
33
|
+
protected:
|
|
34
|
+
bool DecodeValues(const std::vector<PointIndex> &point_ids,
|
|
35
|
+
DecoderBuffer *in_buffer) override;
|
|
36
|
+
virtual bool DecodeIntegerValues(const std::vector<PointIndex> &point_ids,
|
|
37
|
+
DecoderBuffer *in_buffer);
|
|
38
|
+
|
|
39
|
+
// Returns a prediction scheme that should be used for decoding of the
|
|
40
|
+
// integer values.
|
|
41
|
+
virtual std::unique_ptr<PredictionSchemeTypedDecoderInterface<int32_t>>
|
|
42
|
+
CreateIntPredictionScheme(PredictionSchemeMethod method,
|
|
43
|
+
PredictionSchemeTransformType transform_type);
|
|
44
|
+
|
|
45
|
+
// Returns the number of integer attribute components. In general, this
|
|
46
|
+
// can be different from the number of components of the input attribute.
|
|
47
|
+
virtual int32_t GetNumValueComponents() const {
|
|
48
|
+
return attribute()->num_components();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Called after all integer values are decoded. The implementation should
|
|
52
|
+
// use this method to store the values into the attribute.
|
|
53
|
+
virtual bool StoreValues(uint32_t num_values);
|
|
54
|
+
|
|
55
|
+
void PreparePortableAttribute(int num_entries, int num_components);
|
|
56
|
+
|
|
57
|
+
int32_t *GetPortableAttributeData() {
|
|
58
|
+
if (portable_attribute()->size() == 0) {
|
|
59
|
+
return nullptr;
|
|
60
|
+
}
|
|
61
|
+
return reinterpret_cast<int32_t *>(
|
|
62
|
+
portable_attribute()->GetAddress(AttributeValueIndex(0)));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private:
|
|
66
|
+
// Stores decoded values into the attribute with a data type AttributeTypeT.
|
|
67
|
+
template <typename AttributeTypeT>
|
|
68
|
+
void StoreTypedValues(uint32_t num_values);
|
|
69
|
+
|
|
70
|
+
std::unique_ptr<PredictionSchemeTypedDecoderInterface<int32_t>>
|
|
71
|
+
prediction_scheme_;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace draco
|
|
75
|
+
|
|
76
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_H_
|
|
@@ -0,0 +1,67 @@
|
|
|
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_INTEGER_ATTRIBUTE_ENCODER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h"
|
|
19
|
+
#include "draco/compression/attributes/sequential_attribute_encoder.h"
|
|
20
|
+
|
|
21
|
+
namespace draco {
|
|
22
|
+
|
|
23
|
+
// Attribute encoder designed for lossless encoding of integer attributes. The
|
|
24
|
+
// attribute values can be pre-processed by a prediction scheme and compressed
|
|
25
|
+
// with a built-in entropy coder.
|
|
26
|
+
class SequentialIntegerAttributeEncoder : public SequentialAttributeEncoder {
|
|
27
|
+
public:
|
|
28
|
+
SequentialIntegerAttributeEncoder();
|
|
29
|
+
uint8_t GetUniqueId() const override {
|
|
30
|
+
return SEQUENTIAL_ATTRIBUTE_ENCODER_INTEGER;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
bool Init(PointCloudEncoder *encoder, int attribute_id) override;
|
|
34
|
+
bool TransformAttributeToPortableFormat(
|
|
35
|
+
const std::vector<PointIndex> &point_ids) override;
|
|
36
|
+
|
|
37
|
+
protected:
|
|
38
|
+
bool EncodeValues(const std::vector<PointIndex> &point_ids,
|
|
39
|
+
EncoderBuffer *out_buffer) override;
|
|
40
|
+
|
|
41
|
+
// Returns a prediction scheme that should be used for encoding of the
|
|
42
|
+
// integer values.
|
|
43
|
+
virtual std::unique_ptr<PredictionSchemeTypedEncoderInterface<int32_t>>
|
|
44
|
+
CreateIntPredictionScheme(PredictionSchemeMethod method);
|
|
45
|
+
|
|
46
|
+
// Prepares the integer values that are going to be encoded.
|
|
47
|
+
virtual bool PrepareValues(const std::vector<PointIndex> &point_ids,
|
|
48
|
+
int num_points);
|
|
49
|
+
|
|
50
|
+
void PreparePortableAttribute(int num_entries, int num_components,
|
|
51
|
+
int num_points);
|
|
52
|
+
|
|
53
|
+
int32_t *GetPortableAttributeData() {
|
|
54
|
+
return reinterpret_cast<int32_t *>(
|
|
55
|
+
portable_attribute()->GetAddress(AttributeValueIndex(0)));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
// Optional prediction scheme can be used to modify the integer values in
|
|
60
|
+
// order to make them easier to compress.
|
|
61
|
+
std::unique_ptr<PredictionSchemeTypedEncoderInterface<int32_t>>
|
|
62
|
+
prediction_scheme_;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace draco
|
|
66
|
+
|
|
67
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_H_
|