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.
Files changed (214) hide show
  1. bin/draco_decoder.exe +0 -0
  2. bin/draco_encoder.exe +0 -0
  3. dracox/__init__.py +252 -0
  4. dracox/dracox_ext.cp39-win_amd64.pyd +0 -0
  5. dracox-0.0.1.dist-info/METADATA +14 -0
  6. dracox-0.0.1.dist-info/RECORD +214 -0
  7. dracox-0.0.1.dist-info/WHEEL +5 -0
  8. include/draco/animation/keyframe_animation.h +107 -0
  9. include/draco/animation/keyframe_animation_decoder.h +34 -0
  10. include/draco/animation/keyframe_animation_encoder.h +39 -0
  11. include/draco/attributes/attribute_octahedron_transform.h +81 -0
  12. include/draco/attributes/attribute_quantization_transform.h +102 -0
  13. include/draco/attributes/attribute_transform.h +76 -0
  14. include/draco/attributes/attribute_transform_data.h +71 -0
  15. include/draco/attributes/attribute_transform_type.h +30 -0
  16. include/draco/attributes/geometry_attribute.h +541 -0
  17. include/draco/attributes/geometry_indices.h +54 -0
  18. include/draco/attributes/point_attribute.h +196 -0
  19. include/draco/compression/attributes/attributes_decoder.h +97 -0
  20. include/draco/compression/attributes/attributes_decoder_interface.h +62 -0
  21. include/draco/compression/attributes/attributes_encoder.h +154 -0
  22. include/draco/compression/attributes/kd_tree_attributes_decoder.h +50 -0
  23. include/draco/compression/attributes/kd_tree_attributes_encoder.h +51 -0
  24. include/draco/compression/attributes/kd_tree_attributes_shared.h +28 -0
  25. include/draco/compression/attributes/linear_sequencer.h +51 -0
  26. include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h +58 -0
  27. include/draco/compression/attributes/normal_compression_utils.h +372 -0
  28. include/draco/compression/attributes/point_d_vector.h +288 -0
  29. include/draco/compression/attributes/points_sequencer.h +63 -0
  30. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h +236 -0
  31. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h +413 -0
  32. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h +34 -0
  33. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h +72 -0
  34. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h +46 -0
  35. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h +46 -0
  36. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h +176 -0
  37. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h +180 -0
  38. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h +117 -0
  39. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h +96 -0
  40. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h +128 -0
  41. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h +133 -0
  42. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h +111 -0
  43. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h +78 -0
  44. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h +372 -0
  45. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h +318 -0
  46. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h +143 -0
  47. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h +136 -0
  48. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h +282 -0
  49. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h +90 -0
  50. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h +194 -0
  51. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h +53 -0
  52. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h +65 -0
  53. include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h +65 -0
  54. include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h +69 -0
  55. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h +90 -0
  56. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h +134 -0
  57. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h +55 -0
  58. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h +77 -0
  59. include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h +85 -0
  60. include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h +60 -0
  61. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h +118 -0
  62. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h +116 -0
  63. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h +102 -0
  64. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h +115 -0
  65. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h +105 -0
  66. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h +90 -0
  67. include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h +88 -0
  68. include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h +81 -0
  69. include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h +120 -0
  70. include/draco/compression/attributes/sequential_attribute_decoder.h +86 -0
  71. include/draco/compression/attributes/sequential_attribute_decoders_controller.h +61 -0
  72. include/draco/compression/attributes/sequential_attribute_encoder.h +134 -0
  73. include/draco/compression/attributes/sequential_attribute_encoders_controller.h +115 -0
  74. include/draco/compression/attributes/sequential_integer_attribute_decoder.h +76 -0
  75. include/draco/compression/attributes/sequential_integer_attribute_encoder.h +67 -0
  76. include/draco/compression/attributes/sequential_normal_attribute_decoder.h +83 -0
  77. include/draco/compression/attributes/sequential_normal_attribute_encoder.h +82 -0
  78. include/draco/compression/attributes/sequential_quantization_attribute_decoder.h +52 -0
  79. include/draco/compression/attributes/sequential_quantization_attribute_encoder.h +52 -0
  80. include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h +43 -0
  81. include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h +54 -0
  82. include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h +61 -0
  83. include/draco/compression/bit_coders/direct_bit_decoder.h +89 -0
  84. include/draco/compression/bit_coders/direct_bit_encoder.h +89 -0
  85. include/draco/compression/bit_coders/folded_integer_bit_decoder.h +77 -0
  86. include/draco/compression/bit_coders/folded_integer_bit_encoder.h +82 -0
  87. include/draco/compression/bit_coders/rans_bit_decoder.h +55 -0
  88. include/draco/compression/bit_coders/rans_bit_encoder.h +57 -0
  89. include/draco/compression/bit_coders/symbol_bit_decoder.h +36 -0
  90. include/draco/compression/bit_coders/symbol_bit_encoder.h +36 -0
  91. include/draco/compression/config/compression_shared.h +155 -0
  92. include/draco/compression/config/decoder_options.h +34 -0
  93. include/draco/compression/config/draco_options.h +249 -0
  94. include/draco/compression/config/encoder_options.h +101 -0
  95. include/draco/compression/config/encoding_features.h +39 -0
  96. include/draco/compression/decode.h +80 -0
  97. include/draco/compression/draco_compression_options.h +141 -0
  98. include/draco/compression/encode.h +139 -0
  99. include/draco/compression/encode_base.h +131 -0
  100. include/draco/compression/entropy/ans.h +526 -0
  101. include/draco/compression/entropy/rans_symbol_coding.h +53 -0
  102. include/draco/compression/entropy/rans_symbol_decoder.h +171 -0
  103. include/draco/compression/entropy/rans_symbol_encoder.h +290 -0
  104. include/draco/compression/entropy/shannon_entropy.h +110 -0
  105. include/draco/compression/entropy/symbol_decoding.h +29 -0
  106. include/draco/compression/entropy/symbol_encoding.h +47 -0
  107. include/draco/compression/expert_encode.h +160 -0
  108. include/draco/compression/mesh/mesh_decoder.h +68 -0
  109. include/draco/compression/mesh/mesh_edgebreaker_decoder.h +54 -0
  110. include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h +228 -0
  111. include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h +47 -0
  112. include/draco/compression/mesh/mesh_edgebreaker_encoder.h +73 -0
  113. include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h +209 -0
  114. include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h +57 -0
  115. include/draco/compression/mesh/mesh_edgebreaker_shared.h +129 -0
  116. include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h +201 -0
  117. include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h +139 -0
  118. include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h +134 -0
  119. include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h +172 -0
  120. include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h +219 -0
  121. include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h +226 -0
  122. include/draco/compression/mesh/mesh_encoder.h +84 -0
  123. include/draco/compression/mesh/mesh_sequential_decoder.h +39 -0
  124. include/draco/compression/mesh/mesh_sequential_encoder.h +56 -0
  125. include/draco/compression/mesh/traverser/depth_first_traverser.h +172 -0
  126. include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h +226 -0
  127. include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h +76 -0
  128. include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h +113 -0
  129. include/draco/compression/mesh/traverser/traverser_base.h +87 -0
  130. include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h +369 -0
  131. include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h +372 -0
  132. include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h +141 -0
  133. include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h +126 -0
  134. include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h +34 -0
  135. include/draco/compression/point_cloud/algorithms/point_cloud_types.h +76 -0
  136. include/draco/compression/point_cloud/algorithms/quantize_points_3.h +84 -0
  137. include/draco/compression/point_cloud/algorithms/queuing_policy.h +75 -0
  138. include/draco/compression/point_cloud/point_cloud_decoder.h +118 -0
  139. include/draco/compression/point_cloud/point_cloud_encoder.h +158 -0
  140. include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h +31 -0
  141. include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h +45 -0
  142. include/draco/compression/point_cloud/point_cloud_sequential_decoder.h +33 -0
  143. include/draco/compression/point_cloud/point_cloud_sequential_encoder.h +43 -0
  144. include/draco/core/bit_utils.h +127 -0
  145. include/draco/core/bounding_box.h +77 -0
  146. include/draco/core/constants.h +6 -0
  147. include/draco/core/cycle_timer.h +51 -0
  148. include/draco/core/data_buffer.h +82 -0
  149. include/draco/core/decoder_buffer.h +216 -0
  150. include/draco/core/divide.h +42 -0
  151. include/draco/core/draco_index_type.h +184 -0
  152. include/draco/core/draco_index_type_vector.h +90 -0
  153. include/draco/core/draco_types.h +52 -0
  154. include/draco/core/draco_version.h +25 -0
  155. include/draco/core/encoder_buffer.h +152 -0
  156. include/draco/core/hash_utils.h +64 -0
  157. include/draco/core/macros.h +124 -0
  158. include/draco/core/math_utils.h +79 -0
  159. include/draco/core/options.h +151 -0
  160. include/draco/core/quantization_utils.h +82 -0
  161. include/draco/core/status.h +83 -0
  162. include/draco/core/status_or.h +81 -0
  163. include/draco/core/varint_decoding.h +81 -0
  164. include/draco/core/varint_encoding.h +61 -0
  165. include/draco/core/vector_d.h +355 -0
  166. include/draco/draco_features.h +25 -0
  167. include/draco/io/file_reader_factory.h +34 -0
  168. include/draco/io/file_reader_interface.h +32 -0
  169. include/draco/io/file_utils.h +86 -0
  170. include/draco/io/file_writer_factory.h +34 -0
  171. include/draco/io/file_writer_interface.h +26 -0
  172. include/draco/io/file_writer_utils.h +38 -0
  173. include/draco/io/mesh_io.h +107 -0
  174. include/draco/io/obj_decoder.h +147 -0
  175. include/draco/io/obj_encoder.h +107 -0
  176. include/draco/io/parser_utils.h +66 -0
  177. include/draco/io/ply_decoder.h +69 -0
  178. include/draco/io/ply_encoder.h +54 -0
  179. include/draco/io/ply_property_reader.h +96 -0
  180. include/draco/io/ply_property_writer.h +94 -0
  181. include/draco/io/ply_reader.h +155 -0
  182. include/draco/io/point_cloud_io.h +89 -0
  183. include/draco/io/stdio_file_reader.h +48 -0
  184. include/draco/io/stdio_file_writer.h +42 -0
  185. include/draco/io/stl_decoder.h +38 -0
  186. include/draco/io/stl_encoder.h +52 -0
  187. include/draco/mesh/corner_table.h +397 -0
  188. include/draco/mesh/corner_table_iterators.h +309 -0
  189. include/draco/mesh/mesh.h +378 -0
  190. include/draco/mesh/mesh_are_equivalent.h +71 -0
  191. include/draco/mesh/mesh_attribute_corner_table.h +202 -0
  192. include/draco/mesh/mesh_cleanup.h +61 -0
  193. include/draco/mesh/mesh_features.h +93 -0
  194. include/draco/mesh/mesh_indices.h +37 -0
  195. include/draco/mesh/mesh_misc_functions.h +105 -0
  196. include/draco/mesh/mesh_stripifier.h +258 -0
  197. include/draco/mesh/triangle_soup_mesh_builder.h +134 -0
  198. include/draco/mesh/valence_cache.h +142 -0
  199. include/draco/metadata/geometry_metadata.h +142 -0
  200. include/draco/metadata/metadata.h +209 -0
  201. include/draco/metadata/metadata_decoder.h +42 -0
  202. include/draco/metadata/metadata_encoder.h +41 -0
  203. include/draco/metadata/property_attribute.h +107 -0
  204. include/draco/metadata/property_table.h +222 -0
  205. include/draco/metadata/structural_metadata.h +78 -0
  206. include/draco/metadata/structural_metadata_schema.h +118 -0
  207. include/draco/point_cloud/point_cloud.h +289 -0
  208. include/draco/point_cloud/point_cloud_builder.h +101 -0
  209. lib/draco.lib +0 -0
  210. lib/pkgconfig/draco.pc +6 -0
  211. share/cmake/draco/draco-config-version.cmake +43 -0
  212. share/cmake/draco/draco-config.cmake +27 -0
  213. share/cmake/draco/draco-targets-release.cmake +19 -0
  214. share/cmake/draco/draco-targets.cmake +107 -0
@@ -0,0 +1,413 @@
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_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_ENCODER_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_ENCODER_H_
17
+
18
+ #include <algorithm>
19
+ #include <cmath>
20
+
21
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h"
22
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h"
23
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h"
24
+ #include "draco/compression/bit_coders/rans_bit_encoder.h"
25
+ #include "draco/compression/entropy/shannon_entropy.h"
26
+ #include "draco/core/varint_encoding.h"
27
+
28
+ namespace draco {
29
+
30
+ // Compared to standard multi-parallelogram, constrained multi-parallelogram can
31
+ // explicitly select which of the available parallelograms are going to be used
32
+ // for the prediction by marking crease edges between two triangles. This
33
+ // requires storing extra data, but it allows the predictor to avoid using
34
+ // parallelograms that would lead to poor predictions. For improved efficiency,
35
+ // our current implementation limits the maximum number of used parallelograms
36
+ // to four, which covers >95% of the cases (on average, there are only two
37
+ // parallelograms available for any given vertex).
38
+ // All bits of the explicitly chosen configuration are stored together in a
39
+ // single context chosen by the total number of parallelograms available to
40
+ // choose from.
41
+ template <typename DataTypeT, class TransformT, class MeshDataT>
42
+ class MeshPredictionSchemeConstrainedMultiParallelogramEncoder
43
+ : public MeshPredictionSchemeEncoder<DataTypeT, TransformT, MeshDataT> {
44
+ public:
45
+ using CorrType =
46
+ typename PredictionSchemeEncoder<DataTypeT, TransformT>::CorrType;
47
+ using CornerTable = typename MeshDataT::CornerTable;
48
+
49
+ explicit MeshPredictionSchemeConstrainedMultiParallelogramEncoder(
50
+ const PointAttribute *attribute)
51
+ : MeshPredictionSchemeEncoder<DataTypeT, TransformT, MeshDataT>(
52
+ attribute),
53
+ selected_mode_(Mode::OPTIMAL_MULTI_PARALLELOGRAM) {}
54
+ MeshPredictionSchemeConstrainedMultiParallelogramEncoder(
55
+ const PointAttribute *attribute, const TransformT &transform,
56
+ const MeshDataT &mesh_data)
57
+ : MeshPredictionSchemeEncoder<DataTypeT, TransformT, MeshDataT>(
58
+ attribute, transform, mesh_data),
59
+ selected_mode_(Mode::OPTIMAL_MULTI_PARALLELOGRAM) {}
60
+
61
+ bool ComputeCorrectionValues(
62
+ const DataTypeT *in_data, CorrType *out_corr, int size,
63
+ int num_components, const PointIndex *entry_to_point_id_map) override;
64
+
65
+ bool EncodePredictionData(EncoderBuffer *buffer) override;
66
+
67
+ PredictionSchemeMethod GetPredictionMethod() const override {
68
+ return MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM;
69
+ }
70
+
71
+ bool IsInitialized() const override {
72
+ return this->mesh_data().IsInitialized();
73
+ }
74
+
75
+ private:
76
+ // Function used to compute number of bits needed to store overhead of the
77
+ // predictor. In this case, we consider overhead to be all bits that mark
78
+ // whether a parallelogram should be used for prediction or not. The input
79
+ // to this method is the total number of parallelograms that were evaluated so
80
+ // far(total_parallelogram), and the number of parallelograms we decided to
81
+ // use for prediction (total_used_parallelograms).
82
+ // Returns number of bits required to store the overhead.
83
+ int64_t ComputeOverheadBits(int64_t total_used_parallelograms,
84
+ int64_t total_parallelogram) const {
85
+ // For now we assume RAns coding for the bits where the total required size
86
+ // is directly correlated to the binary entropy of the input stream.
87
+ // TODO(ostava): This should be generalized in case we use other binary
88
+ // coding scheme.
89
+ const double entropy = ComputeBinaryShannonEntropy(
90
+ static_cast<uint32_t>(total_parallelogram),
91
+ static_cast<uint32_t>(total_used_parallelograms));
92
+
93
+ // Round up to the nearest full bit.
94
+ return static_cast<int64_t>(
95
+ ceil(static_cast<double>(total_parallelogram) * entropy));
96
+ }
97
+
98
+ // Struct that contains data used for measuring the error of each available
99
+ // parallelogram configuration.
100
+ struct Error {
101
+ Error() : num_bits(0), residual_error(0) {}
102
+
103
+ // Primary metric: number of bits required to store the data as a result of
104
+ // the selected prediction configuration.
105
+ int num_bits;
106
+ // Secondary metric: absolute difference of residuals for the given
107
+ // configuration.
108
+ int residual_error;
109
+
110
+ bool operator<(const Error &e) const {
111
+ if (num_bits < e.num_bits) {
112
+ return true;
113
+ }
114
+ if (num_bits > e.num_bits) {
115
+ return false;
116
+ }
117
+ return residual_error < e.residual_error;
118
+ }
119
+ };
120
+
121
+ // Computes error for predicting |predicted_val| instead of |actual_val|.
122
+ // Error is computed as the number of bits needed to encode the difference
123
+ // between the values.
124
+ Error ComputeError(const DataTypeT *predicted_val,
125
+ const DataTypeT *actual_val, int *out_residuals,
126
+ int num_components) {
127
+ Error error;
128
+
129
+ for (int i = 0; i < num_components; ++i) {
130
+ const int dif = (predicted_val[i] - actual_val[i]);
131
+ error.residual_error += std::abs(dif);
132
+ out_residuals[i] = dif;
133
+ // Entropy needs unsigned symbols, so convert the signed difference to an
134
+ // unsigned symbol.
135
+ entropy_symbols_[i] = ConvertSignedIntToSymbol(dif);
136
+ }
137
+
138
+ // Generate entropy data for case that this configuration was used.
139
+ // Note that the entropy stream is NOT updated in this case.
140
+ const auto entropy_data =
141
+ entropy_tracker_.Peek(entropy_symbols_.data(), num_components);
142
+
143
+ error.num_bits = entropy_tracker_.GetNumberOfDataBits(entropy_data) +
144
+ entropy_tracker_.GetNumberOfRAnsTableBits(entropy_data);
145
+ return error;
146
+ }
147
+
148
+ typedef constrained_multi_parallelogram::Mode Mode;
149
+ static constexpr int kMaxNumParallelograms =
150
+ constrained_multi_parallelogram::kMaxNumParallelograms;
151
+ // Crease edges are used to store whether any given edge should be used for
152
+ // parallelogram prediction or not. New values are added in the order in which
153
+ // the edges are processed. For better compression, the flags are stored in
154
+ // in separate contexts based on the number of available parallelograms at a
155
+ // given vertex.
156
+ // TODO(draco-eng) reconsider std::vector<bool> (performance/space).
157
+ std::vector<bool> is_crease_edge_[kMaxNumParallelograms];
158
+ Mode selected_mode_;
159
+
160
+ ShannonEntropyTracker entropy_tracker_;
161
+
162
+ // Temporary storage for symbols that are fed into the |entropy_stream|.
163
+ // Always contains only |num_components| entries.
164
+ std::vector<uint32_t> entropy_symbols_;
165
+ };
166
+
167
+ template <typename DataTypeT, class TransformT, class MeshDataT>
168
+ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
169
+ DataTypeT, TransformT, MeshDataT>::
170
+ ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr,
171
+ int size, int num_components,
172
+ const PointIndex * /* entry_to_point_id_map */) {
173
+ this->transform().Init(in_data, size, num_components);
174
+ const CornerTable *const table = this->mesh_data().corner_table();
175
+ const std::vector<int32_t> *const vertex_to_data_map =
176
+ this->mesh_data().vertex_to_data_map();
177
+
178
+ // Predicted values for all simple parallelograms encountered at any given
179
+ // vertex.
180
+ std::vector<DataTypeT> pred_vals[kMaxNumParallelograms];
181
+ for (int i = 0; i < kMaxNumParallelograms; ++i) {
182
+ pred_vals[i].resize(num_components);
183
+ }
184
+ // Used to store predicted value for various multi-parallelogram predictions
185
+ // (combinations of simple parallelogram predictions).
186
+ std::vector<DataTypeT> multi_pred_vals(num_components);
187
+ entropy_symbols_.resize(num_components);
188
+
189
+ // Struct for holding data about prediction configuration for different sets
190
+ // of used parallelograms.
191
+ struct PredictionConfiguration {
192
+ PredictionConfiguration()
193
+ : error(), configuration(0), num_used_parallelograms(0) {}
194
+ Error error;
195
+ uint8_t configuration; // Bitfield, 1 use parallelogram, 0 don't use it.
196
+ int num_used_parallelograms;
197
+ std::vector<DataTypeT> predicted_value;
198
+ std::vector<int32_t> residuals;
199
+ };
200
+
201
+ // Bit-field used for computing permutations of excluded edges
202
+ // (parallelograms).
203
+ bool excluded_parallelograms[kMaxNumParallelograms];
204
+
205
+ // Data about the number of used parallelogram and total number of available
206
+ // parallelogram for each context. Used to compute overhead needed for storing
207
+ // the parallelogram choices made by the encoder.
208
+ int64_t total_used_parallelograms[kMaxNumParallelograms] = {0};
209
+ int64_t total_parallelograms[kMaxNumParallelograms] = {0};
210
+
211
+ std::vector<int> current_residuals(num_components);
212
+
213
+ // We start processing the vertices from the end because this prediction uses
214
+ // data from previous entries that could be overwritten when an entry is
215
+ // processed.
216
+ for (int p =
217
+ static_cast<int>(this->mesh_data().data_to_corner_map()->size()) - 1;
218
+ p > 0; --p) {
219
+ const CornerIndex start_corner_id =
220
+ this->mesh_data().data_to_corner_map()->at(p);
221
+
222
+ // Go over all corners attached to the vertex and compute the predicted
223
+ // value from the parallelograms defined by their opposite faces.
224
+ CornerIndex corner_id(start_corner_id);
225
+ int num_parallelograms = 0;
226
+ bool first_pass = true;
227
+ while (corner_id != kInvalidCornerIndex) {
228
+ if (ComputeParallelogramPrediction(
229
+ p, corner_id, table, *vertex_to_data_map, in_data, num_components,
230
+ &(pred_vals[num_parallelograms][0]))) {
231
+ // Parallelogram prediction applied and stored in
232
+ // |pred_vals[num_parallelograms]|
233
+ ++num_parallelograms;
234
+ // Stop processing when we reach the maximum number of allowed
235
+ // parallelograms.
236
+ if (num_parallelograms == kMaxNumParallelograms) {
237
+ break;
238
+ }
239
+ }
240
+
241
+ // Proceed to the next corner attached to the vertex. First swing left
242
+ // and if we reach a boundary, swing right from the start corner.
243
+ if (first_pass) {
244
+ corner_id = table->SwingLeft(corner_id);
245
+ } else {
246
+ corner_id = table->SwingRight(corner_id);
247
+ }
248
+ if (corner_id == start_corner_id) {
249
+ break;
250
+ }
251
+ if (corner_id == kInvalidCornerIndex && first_pass) {
252
+ first_pass = false;
253
+ corner_id = table->SwingRight(start_corner_id);
254
+ }
255
+ }
256
+
257
+ // Offset to the target (destination) vertex.
258
+ const int dst_offset = p * num_components;
259
+ Error error;
260
+
261
+ // Compute all prediction errors for all possible configurations of
262
+ // available parallelograms.
263
+
264
+ // Variable for holding the best configuration that has been found so far.
265
+ PredictionConfiguration best_prediction;
266
+
267
+ // Compute delta coding error (configuration when no parallelogram is
268
+ // selected).
269
+ const int src_offset = (p - 1) * num_components;
270
+ error = ComputeError(in_data + src_offset, in_data + dst_offset,
271
+ &current_residuals[0], num_components);
272
+
273
+ if (num_parallelograms > 0) {
274
+ total_parallelograms[num_parallelograms - 1] += num_parallelograms;
275
+ const int64_t new_overhead_bits =
276
+ ComputeOverheadBits(total_used_parallelograms[num_parallelograms - 1],
277
+ total_parallelograms[num_parallelograms - 1]);
278
+ error.num_bits += new_overhead_bits;
279
+ }
280
+
281
+ best_prediction.error = error;
282
+ best_prediction.configuration = 0;
283
+ best_prediction.num_used_parallelograms = 0;
284
+ best_prediction.predicted_value.assign(
285
+ in_data + src_offset, in_data + src_offset + num_components);
286
+ best_prediction.residuals.assign(current_residuals.begin(),
287
+ current_residuals.end());
288
+
289
+ // Compute prediction error for different cases of used parallelograms.
290
+ for (int num_used_parallelograms = 1;
291
+ num_used_parallelograms <= num_parallelograms;
292
+ ++num_used_parallelograms) {
293
+ // Mark all parallelograms as excluded.
294
+ std::fill(excluded_parallelograms,
295
+ excluded_parallelograms + num_parallelograms, true);
296
+ // TODO(draco-eng) maybe this should be another std::fill.
297
+ // Mark the first |num_used_parallelograms| as not excluded.
298
+ for (int j = 0; j < num_used_parallelograms; ++j) {
299
+ excluded_parallelograms[j] = false;
300
+ }
301
+ // Permute over the excluded edges and compute error for each
302
+ // configuration (permutation of excluded parallelograms).
303
+ do {
304
+ // Reset the multi-parallelogram predicted values.
305
+ for (int j = 0; j < num_components; ++j) {
306
+ multi_pred_vals[j] = 0;
307
+ }
308
+ uint8_t configuration = 0;
309
+ for (int j = 0; j < num_parallelograms; ++j) {
310
+ if (excluded_parallelograms[j]) {
311
+ continue;
312
+ }
313
+ for (int c = 0; c < num_components; ++c) {
314
+ multi_pred_vals[c] += pred_vals[j][c];
315
+ }
316
+ // Set jth bit of the configuration.
317
+ configuration |= (1 << j);
318
+ }
319
+
320
+ for (int j = 0; j < num_components; ++j) {
321
+ multi_pred_vals[j] /= num_used_parallelograms;
322
+ }
323
+ error = ComputeError(multi_pred_vals.data(), in_data + dst_offset,
324
+ &current_residuals[0], num_components);
325
+ const int64_t new_overhead_bits = ComputeOverheadBits(
326
+ total_used_parallelograms[num_parallelograms - 1] +
327
+ num_used_parallelograms,
328
+ total_parallelograms[num_parallelograms - 1]);
329
+
330
+ // Add overhead bits to the total error.
331
+ error.num_bits += new_overhead_bits;
332
+ if (error < best_prediction.error) {
333
+ best_prediction.error = error;
334
+ best_prediction.configuration = configuration;
335
+ best_prediction.num_used_parallelograms = num_used_parallelograms;
336
+ best_prediction.predicted_value.assign(multi_pred_vals.begin(),
337
+ multi_pred_vals.end());
338
+ best_prediction.residuals.assign(current_residuals.begin(),
339
+ current_residuals.end());
340
+ }
341
+ } while (
342
+ std::next_permutation(excluded_parallelograms,
343
+ excluded_parallelograms + num_parallelograms));
344
+ }
345
+ if (num_parallelograms > 0) {
346
+ total_used_parallelograms[num_parallelograms - 1] +=
347
+ best_prediction.num_used_parallelograms;
348
+ }
349
+
350
+ // Update the entropy stream by adding selected residuals as symbols to the
351
+ // stream.
352
+ for (int i = 0; i < num_components; ++i) {
353
+ entropy_symbols_[i] =
354
+ ConvertSignedIntToSymbol(best_prediction.residuals[i]);
355
+ }
356
+ entropy_tracker_.Push(entropy_symbols_.data(), num_components);
357
+
358
+ for (int i = 0; i < num_parallelograms; ++i) {
359
+ if ((best_prediction.configuration & (1 << i)) == 0) {
360
+ // Parallelogram not used, mark the edge as crease.
361
+ is_crease_edge_[num_parallelograms - 1].push_back(true);
362
+ } else {
363
+ // Parallelogram used. Add it to the predicted value and mark the
364
+ // edge as not a crease.
365
+ is_crease_edge_[num_parallelograms - 1].push_back(false);
366
+ }
367
+ }
368
+ this->transform().ComputeCorrection(in_data + dst_offset,
369
+ best_prediction.predicted_value.data(),
370
+ out_corr + dst_offset);
371
+ }
372
+ // First element is always fixed because it cannot be predicted.
373
+ for (int i = 0; i < num_components; ++i) {
374
+ pred_vals[0][i] = static_cast<DataTypeT>(0);
375
+ }
376
+ this->transform().ComputeCorrection(in_data, pred_vals[0].data(), out_corr);
377
+ return true;
378
+ }
379
+
380
+ template <typename DataTypeT, class TransformT, class MeshDataT>
381
+ bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
382
+ DataTypeT, TransformT, MeshDataT>::EncodePredictionData(EncoderBuffer
383
+ *buffer) {
384
+ // Encode selected edges using separate rans bit coder for each context.
385
+ for (int i = 0; i < kMaxNumParallelograms; ++i) {
386
+ // |i| is the context based on the number of available parallelograms, which
387
+ // is always equal to |i + 1|.
388
+ const int num_used_parallelograms = i + 1;
389
+ EncodeVarint<uint32_t>(is_crease_edge_[i].size(), buffer);
390
+ if (is_crease_edge_[i].size()) {
391
+ RAnsBitEncoder encoder;
392
+ encoder.StartEncoding();
393
+ // Encode the crease edge flags in the reverse vertex order that is needed
394
+ // by the decoder. Note that for the currently supported mode, each vertex
395
+ // has exactly |num_used_parallelograms| edges that need to be encoded.
396
+ for (int j = static_cast<int>(is_crease_edge_[i].size()) -
397
+ num_used_parallelograms;
398
+ j >= 0; j -= num_used_parallelograms) {
399
+ // Go over all edges of the current vertex.
400
+ for (int k = 0; k < num_used_parallelograms; ++k) {
401
+ encoder.EncodeBit(is_crease_edge_[i][j + k]);
402
+ }
403
+ }
404
+ encoder.EndEncoding(buffer);
405
+ }
406
+ }
407
+ return MeshPredictionSchemeEncoder<DataTypeT, TransformT,
408
+ MeshDataT>::EncodePredictionData(buffer);
409
+ }
410
+
411
+ } // namespace draco
412
+
413
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_ENCODER_H_
@@ -0,0 +1,34 @@
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_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_SHARED_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_SHARED_H_
17
+
18
+ namespace draco {
19
+
20
+ // Data shared between constrained multi-parallelogram encoder and decoder.
21
+ namespace constrained_multi_parallelogram {
22
+
23
+ enum Mode {
24
+ // Selects the optimal multi-parallelogram from up to 4 available
25
+ // parallelograms.
26
+ OPTIMAL_MULTI_PARALLELOGRAM = 0,
27
+ };
28
+
29
+ static constexpr int kMaxNumParallelograms = 4;
30
+
31
+ } // namespace constrained_multi_parallelogram
32
+ } // namespace draco
33
+
34
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_SHARED_H_
@@ -0,0 +1,72 @@
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_MESH_PREDICTION_SCHEME_DATA_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DATA_H_
17
+
18
+ #include "draco/mesh/corner_table.h"
19
+ #include "draco/mesh/mesh.h"
20
+
21
+ namespace draco {
22
+
23
+ // Class stores data about the connectivity data of the mesh and information
24
+ // about how the connectivity was encoded/decoded.
25
+ template <class CornerTableT>
26
+ class MeshPredictionSchemeData {
27
+ public:
28
+ typedef CornerTableT CornerTable;
29
+ MeshPredictionSchemeData()
30
+ : mesh_(nullptr),
31
+ corner_table_(nullptr),
32
+ vertex_to_data_map_(nullptr),
33
+ data_to_corner_map_(nullptr) {}
34
+
35
+ void Set(const Mesh *mesh, const CornerTable *table,
36
+ const std::vector<CornerIndex> *data_to_corner_map,
37
+ const std::vector<int32_t> *vertex_to_data_map) {
38
+ mesh_ = mesh;
39
+ corner_table_ = table;
40
+ data_to_corner_map_ = data_to_corner_map;
41
+ vertex_to_data_map_ = vertex_to_data_map;
42
+ }
43
+
44
+ const Mesh *mesh() const { return mesh_; }
45
+ const CornerTable *corner_table() const { return corner_table_; }
46
+ const std::vector<int32_t> *vertex_to_data_map() const {
47
+ return vertex_to_data_map_;
48
+ }
49
+ const std::vector<CornerIndex> *data_to_corner_map() const {
50
+ return data_to_corner_map_;
51
+ }
52
+ bool IsInitialized() const {
53
+ return mesh_ != nullptr && corner_table_ != nullptr &&
54
+ vertex_to_data_map_ != nullptr && data_to_corner_map_ != nullptr;
55
+ }
56
+
57
+ private:
58
+ const Mesh *mesh_;
59
+ const CornerTable *corner_table_;
60
+
61
+ // Mapping between vertices and their encoding order. I.e. when an attribute
62
+ // entry on a given vertex was encoded.
63
+ const std::vector<int32_t> *vertex_to_data_map_;
64
+
65
+ // Array that stores which corner was processed when a given attribute entry
66
+ // was encoded or decoded.
67
+ const std::vector<CornerIndex> *data_to_corner_map_;
68
+ };
69
+
70
+ } // namespace draco
71
+
72
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DATA_H_
@@ -0,0 +1,46 @@
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_MESH_PREDICTION_SCHEME_DECODER_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DECODER_H_
17
+
18
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h"
19
+ #include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h"
20
+
21
+ namespace draco {
22
+
23
+ // Base class for all mesh prediction scheme decoders that use the mesh
24
+ // connectivity data. |MeshDataT| can be any class that provides the same
25
+ // interface as the PredictionSchemeMeshData class.
26
+ template <typename DataTypeT, class TransformT, class MeshDataT>
27
+ class MeshPredictionSchemeDecoder
28
+ : public PredictionSchemeDecoder<DataTypeT, TransformT> {
29
+ public:
30
+ typedef MeshDataT MeshData;
31
+ MeshPredictionSchemeDecoder(const PointAttribute *attribute,
32
+ const TransformT &transform,
33
+ const MeshDataT &mesh_data)
34
+ : PredictionSchemeDecoder<DataTypeT, TransformT>(attribute, transform),
35
+ mesh_data_(mesh_data) {}
36
+
37
+ protected:
38
+ const MeshData &mesh_data() const { return mesh_data_; }
39
+
40
+ private:
41
+ MeshData mesh_data_;
42
+ };
43
+
44
+ } // namespace draco
45
+
46
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DECODER_H_
@@ -0,0 +1,46 @@
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_MESH_PREDICTION_SCHEME_ENCODER_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_ENCODER_H_
17
+
18
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h"
19
+ #include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h"
20
+
21
+ namespace draco {
22
+
23
+ // Base class for all mesh prediction scheme encoders that use the mesh
24
+ // connectivity data. |MeshDataT| can be any class that provides the same
25
+ // interface as the PredictionSchemeMeshData class.
26
+ template <typename DataTypeT, class TransformT, class MeshDataT>
27
+ class MeshPredictionSchemeEncoder
28
+ : public PredictionSchemeEncoder<DataTypeT, TransformT> {
29
+ public:
30
+ typedef MeshDataT MeshData;
31
+ MeshPredictionSchemeEncoder(const PointAttribute *attribute,
32
+ const TransformT &transform,
33
+ const MeshDataT &mesh_data)
34
+ : PredictionSchemeEncoder<DataTypeT, TransformT>(attribute, transform),
35
+ mesh_data_(mesh_data) {}
36
+
37
+ protected:
38
+ const MeshData &mesh_data() const { return mesh_data_; }
39
+
40
+ private:
41
+ MeshData mesh_data_;
42
+ };
43
+
44
+ } // namespace draco
45
+
46
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_ENCODER_H_