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,139 @@
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_MESH_MESH_EDGEBREAKER_TRAVERSAL_ENCODER_H_
16
+ #define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_ENCODER_H_
17
+
18
+ #include "draco/compression/bit_coders/rans_bit_encoder.h"
19
+ #include "draco/compression/mesh/mesh_edgebreaker_encoder.h"
20
+ #include "draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h"
21
+ #include "draco/core/macros.h"
22
+
23
+ namespace draco {
24
+
25
+ typedef RAnsBitEncoder BinaryEncoder;
26
+
27
+ // Default implementation of the edgebreaker traversal encoder. Face
28
+ // configurations are stored directly into the output buffer and the symbols
29
+ // are first collected and then encoded in the reverse order to make the
30
+ // decoding faster.
31
+ class MeshEdgebreakerTraversalEncoder {
32
+ public:
33
+ MeshEdgebreakerTraversalEncoder()
34
+ : encoder_impl_(nullptr),
35
+ attribute_connectivity_encoders_(nullptr),
36
+ num_attribute_data_(0) {}
37
+ bool Init(MeshEdgebreakerEncoderImplInterface *encoder) {
38
+ encoder_impl_ = encoder;
39
+ return true;
40
+ }
41
+
42
+ // Set the number of non-position attribute data for which we need to encode
43
+ // the connectivity.
44
+ void SetNumAttributeData(int num_data) { num_attribute_data_ = num_data; }
45
+
46
+ // Called before the traversal encoding is started.
47
+ void Start() {
48
+ start_face_encoder_.StartEncoding();
49
+ if (num_attribute_data_ > 0) {
50
+ // Init and start arithmetic encoders for storing configuration types
51
+ // of non-position attributes.
52
+ attribute_connectivity_encoders_ = std::unique_ptr<BinaryEncoder[]>(
53
+ new BinaryEncoder[num_attribute_data_]);
54
+ for (int i = 0; i < num_attribute_data_; ++i) {
55
+ attribute_connectivity_encoders_[i].StartEncoding();
56
+ }
57
+ }
58
+ }
59
+
60
+ // Called when a traversal starts from a new initial face.
61
+ inline void EncodeStartFaceConfiguration(bool interior) {
62
+ start_face_encoder_.EncodeBit(interior);
63
+ }
64
+
65
+ // Called when a new corner is reached during the traversal. No-op for the
66
+ // default encoder.
67
+ inline void NewCornerReached(CornerIndex /* corner */) {}
68
+
69
+ // Called whenever a new symbol is reached during the edgebreaker traversal.
70
+ inline void EncodeSymbol(EdgebreakerTopologyBitPattern symbol) {
71
+ // Store the symbol. It will be encoded after all symbols are processed.
72
+ symbols_.push_back(symbol);
73
+ }
74
+
75
+ // Called for every pair of connected and visited faces. |is_seam| specifies
76
+ // whether there is an attribute seam between the two faces.
77
+
78
+ inline void EncodeAttributeSeam(int attribute, bool is_seam) {
79
+ attribute_connectivity_encoders_[attribute].EncodeBit(is_seam ? 1 : 0);
80
+ }
81
+
82
+ // Called when the traversal is finished.
83
+ void Done() {
84
+ EncodeTraversalSymbols();
85
+ EncodeStartFaces();
86
+ EncodeAttributeSeams();
87
+ }
88
+
89
+ // Returns the number of encoded symbols.
90
+ int NumEncodedSymbols() const { return static_cast<int>(symbols_.size()); }
91
+
92
+ const EncoderBuffer &buffer() const { return traversal_buffer_; }
93
+
94
+ protected:
95
+ void EncodeTraversalSymbols() {
96
+ // Bit encode the collected symbols.
97
+ // Allocate enough storage for the bit encoder.
98
+ // It's guaranteed that each face will need only up to 3 bits.
99
+ traversal_buffer_.StartBitEncoding(
100
+ encoder_impl_->GetEncoder()->mesh()->num_faces() * 3, true);
101
+ for (int i = static_cast<int>(symbols_.size() - 1); i >= 0; --i) {
102
+ traversal_buffer_.EncodeLeastSignificantBits32(
103
+ edge_breaker_topology_bit_pattern_length[symbols_[i]], symbols_[i]);
104
+ }
105
+ traversal_buffer_.EndBitEncoding();
106
+ }
107
+
108
+ void EncodeStartFaces() {
109
+ start_face_encoder_.EndEncoding(&traversal_buffer_);
110
+ }
111
+
112
+ void EncodeAttributeSeams() {
113
+ if (attribute_connectivity_encoders_ != nullptr) {
114
+ for (int i = 0; i < num_attribute_data_; ++i) {
115
+ attribute_connectivity_encoders_[i].EndEncoding(&traversal_buffer_);
116
+ }
117
+ }
118
+ }
119
+
120
+ EncoderBuffer *GetOutputBuffer() { return &traversal_buffer_; }
121
+ const MeshEdgebreakerEncoderImplInterface *encoder_impl() const {
122
+ return encoder_impl_;
123
+ }
124
+
125
+ private:
126
+ BinaryEncoder start_face_encoder_;
127
+ EncoderBuffer traversal_buffer_;
128
+ const MeshEdgebreakerEncoderImplInterface *encoder_impl_;
129
+ // Symbols collected during the traversal.
130
+ std::vector<EdgebreakerTopologyBitPattern> symbols_;
131
+ // Arithmetic encoder for encoding attribute seams.
132
+ // One context for each non-position attribute.
133
+ std::unique_ptr<BinaryEncoder[]> attribute_connectivity_encoders_;
134
+ int num_attribute_data_;
135
+ };
136
+
137
+ } // namespace draco
138
+
139
+ #endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_ENCODER_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
+ #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
16
+ #ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_DECODER_H_
17
+ #define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_DECODER_H_
18
+
19
+ #include "draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h"
20
+ #include "draco/draco_features.h"
21
+
22
+ namespace draco {
23
+
24
+ // Decoder for traversal encoded with the
25
+ // MeshEdgebreakerTraversalPredictiveEncoder. The decoder maintains valences
26
+ // of the decoded portion of the traversed mesh and it uses them to predict
27
+ // symbols that are about to be decoded.
28
+ class MeshEdgebreakerTraversalPredictiveDecoder
29
+ : public MeshEdgebreakerTraversalDecoder {
30
+ public:
31
+ MeshEdgebreakerTraversalPredictiveDecoder()
32
+ : corner_table_(nullptr),
33
+ num_vertices_(0),
34
+ last_symbol_(-1),
35
+ predicted_symbol_(-1) {}
36
+ void Init(MeshEdgebreakerDecoderImplInterface *decoder) {
37
+ MeshEdgebreakerTraversalDecoder::Init(decoder);
38
+ corner_table_ = decoder->GetCornerTable();
39
+ }
40
+ void SetNumEncodedVertices(int num_vertices) { num_vertices_ = num_vertices; }
41
+
42
+ bool Start(DecoderBuffer *out_buffer) {
43
+ if (!MeshEdgebreakerTraversalDecoder::Start(out_buffer)) {
44
+ return false;
45
+ }
46
+ int32_t num_split_symbols;
47
+ if (!out_buffer->Decode(&num_split_symbols) || num_split_symbols < 0)
48
+ return false;
49
+ if (num_split_symbols >= num_vertices_) {
50
+ return false;
51
+ }
52
+ // Set the valences of all initial vertices to 0.
53
+ vertex_valences_.resize(num_vertices_, 0);
54
+ if (!prediction_decoder_.StartDecoding(out_buffer)) {
55
+ return false;
56
+ }
57
+ return true;
58
+ }
59
+
60
+ inline uint32_t DecodeSymbol() {
61
+ // First check if we have a predicted symbol.
62
+ if (predicted_symbol_ != -1) {
63
+ // Double check that the predicted symbol was predicted correctly.
64
+ if (prediction_decoder_.DecodeNextBit()) {
65
+ last_symbol_ = predicted_symbol_;
66
+ return predicted_symbol_;
67
+ }
68
+ }
69
+ // We don't have a predicted symbol or the symbol was mis-predicted.
70
+ // Decode it directly.
71
+ last_symbol_ = MeshEdgebreakerTraversalDecoder::DecodeSymbol();
72
+ return last_symbol_;
73
+ }
74
+
75
+ inline void NewActiveCornerReached(CornerIndex corner) {
76
+ const CornerIndex next = corner_table_->Next(corner);
77
+ const CornerIndex prev = corner_table_->Previous(corner);
78
+ // Update valences.
79
+ switch (last_symbol_) {
80
+ case TOPOLOGY_C:
81
+ case TOPOLOGY_S:
82
+ vertex_valences_[corner_table_->Vertex(next).value()] += 1;
83
+ vertex_valences_[corner_table_->Vertex(prev).value()] += 1;
84
+ break;
85
+ case TOPOLOGY_R:
86
+ vertex_valences_[corner_table_->Vertex(corner).value()] += 1;
87
+ vertex_valences_[corner_table_->Vertex(next).value()] += 1;
88
+ vertex_valences_[corner_table_->Vertex(prev).value()] += 2;
89
+ break;
90
+ case TOPOLOGY_L:
91
+ vertex_valences_[corner_table_->Vertex(corner).value()] += 1;
92
+ vertex_valences_[corner_table_->Vertex(next).value()] += 2;
93
+ vertex_valences_[corner_table_->Vertex(prev).value()] += 1;
94
+ break;
95
+ case TOPOLOGY_E:
96
+ vertex_valences_[corner_table_->Vertex(corner).value()] += 2;
97
+ vertex_valences_[corner_table_->Vertex(next).value()] += 2;
98
+ vertex_valences_[corner_table_->Vertex(prev).value()] += 2;
99
+ break;
100
+ default:
101
+ break;
102
+ }
103
+ // Compute the new predicted symbol.
104
+ if (last_symbol_ == TOPOLOGY_C || last_symbol_ == TOPOLOGY_R) {
105
+ const VertexIndex pivot =
106
+ corner_table_->Vertex(corner_table_->Next(corner));
107
+ if (vertex_valences_[pivot.value()] < 6) {
108
+ predicted_symbol_ = TOPOLOGY_R;
109
+ } else {
110
+ predicted_symbol_ = TOPOLOGY_C;
111
+ }
112
+ } else {
113
+ predicted_symbol_ = -1;
114
+ }
115
+ }
116
+
117
+ inline void MergeVertices(VertexIndex dest, VertexIndex source) {
118
+ // Update valences on the merged vertices.
119
+ vertex_valences_[dest.value()] += vertex_valences_[source.value()];
120
+ }
121
+
122
+ private:
123
+ const CornerTable *corner_table_;
124
+ int num_vertices_;
125
+ std::vector<int> vertex_valences_;
126
+ BinaryDecoder prediction_decoder_;
127
+ int last_symbol_;
128
+ int predicted_symbol_;
129
+ };
130
+
131
+ } // namespace draco
132
+
133
+ #endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_DECODER_H_
134
+ #endif
@@ -0,0 +1,172 @@
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_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_ENCODER_H_
16
+ #define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_ENCODER_H_
17
+
18
+ #include "draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h"
19
+
20
+ namespace draco {
21
+
22
+ // Encoder that tries to predict the edgebreaker traversal symbols based on the
23
+ // vertex valences of the unencoded portion of the mesh. The current prediction
24
+ // scheme assumes that each vertex has valence 6 which can be used to predict
25
+ // the symbol preceding the one that is currently encoded. Predictions are
26
+ // encoded using an arithmetic coding which can lead to less than 1 bit per
27
+ // triangle encoding for highly regular meshes.
28
+ class MeshEdgebreakerTraversalPredictiveEncoder
29
+ : public MeshEdgebreakerTraversalEncoder {
30
+ public:
31
+ MeshEdgebreakerTraversalPredictiveEncoder()
32
+ : corner_table_(nullptr),
33
+ prev_symbol_(-1),
34
+ num_split_symbols_(0),
35
+ last_corner_(kInvalidCornerIndex),
36
+ num_symbols_(0) {}
37
+
38
+ bool Init(MeshEdgebreakerEncoderImplInterface *encoder) {
39
+ if (!MeshEdgebreakerTraversalEncoder::Init(encoder)) {
40
+ return false;
41
+ }
42
+ corner_table_ = encoder->GetCornerTable();
43
+ // Initialize valences of all vertices.
44
+ vertex_valences_.resize(corner_table_->num_vertices());
45
+ for (uint32_t i = 0; i < vertex_valences_.size(); ++i) {
46
+ vertex_valences_[i] = corner_table_->Valence(VertexIndex(i));
47
+ }
48
+ return true;
49
+ }
50
+
51
+ inline void NewCornerReached(CornerIndex corner) { last_corner_ = corner; }
52
+
53
+ inline int32_t ComputePredictedSymbol(VertexIndex pivot) {
54
+ const int valence = vertex_valences_[pivot.value()];
55
+ if (valence < 0) {
56
+ // This situation can happen only for split vertices. Returning
57
+ // TOPOLOGY_INVALID always cases misprediction.
58
+ return TOPOLOGY_INVALID;
59
+ }
60
+ if (valence < 6) {
61
+ return TOPOLOGY_R;
62
+ }
63
+ return TOPOLOGY_C;
64
+ }
65
+
66
+ inline void EncodeSymbol(EdgebreakerTopologyBitPattern symbol) {
67
+ ++num_symbols_;
68
+ // Update valences on the mesh. And compute the predicted preceding symbol.
69
+ // Note that the valences are computed for the so far unencoded part of the
70
+ // mesh. Adding a new symbol either reduces valences on the vertices or
71
+ // leaves the valence unchanged.
72
+ int32_t predicted_symbol = -1;
73
+ const CornerIndex next = corner_table_->Next(last_corner_);
74
+ const CornerIndex prev = corner_table_->Previous(last_corner_);
75
+ switch (symbol) {
76
+ case TOPOLOGY_C:
77
+ // Compute prediction.
78
+ predicted_symbol = ComputePredictedSymbol(corner_table_->Vertex(next));
79
+ FALLTHROUGH_INTENDED;
80
+ case TOPOLOGY_S:
81
+ // Update valences.
82
+ vertex_valences_[corner_table_->Vertex(next).value()] -= 1;
83
+ vertex_valences_[corner_table_->Vertex(prev).value()] -= 1;
84
+ if (symbol == TOPOLOGY_S) {
85
+ // Whenever we reach a split symbol, mark its tip vertex as invalid by
86
+ // setting the valence to a negative value. Any prediction that will
87
+ // use this vertex will then cause a misprediction. This is currently
88
+ // necessary because the decoding works in the reverse direction and
89
+ // the decoder doesn't know about these vertices until the split
90
+ // symbol is decoded at which point two vertices are merged into one.
91
+ // This can be most likely solved on the encoder side by splitting the
92
+ // tip vertex into two, but since split symbols are relatively rare,
93
+ // it's probably not worth doing it.
94
+ vertex_valences_[corner_table_->Vertex(last_corner_).value()] = -1;
95
+ ++num_split_symbols_;
96
+ }
97
+ break;
98
+ case TOPOLOGY_R:
99
+ // Compute prediction.
100
+ predicted_symbol = ComputePredictedSymbol(corner_table_->Vertex(next));
101
+ // Update valences.
102
+ vertex_valences_[corner_table_->Vertex(last_corner_).value()] -= 1;
103
+ vertex_valences_[corner_table_->Vertex(next).value()] -= 1;
104
+ vertex_valences_[corner_table_->Vertex(prev).value()] -= 2;
105
+ break;
106
+ case TOPOLOGY_L:
107
+ vertex_valences_[corner_table_->Vertex(last_corner_).value()] -= 1;
108
+ vertex_valences_[corner_table_->Vertex(next).value()] -= 2;
109
+ vertex_valences_[corner_table_->Vertex(prev).value()] -= 1;
110
+ break;
111
+ case TOPOLOGY_E:
112
+ vertex_valences_[corner_table_->Vertex(last_corner_).value()] -= 2;
113
+ vertex_valences_[corner_table_->Vertex(next).value()] -= 2;
114
+ vertex_valences_[corner_table_->Vertex(prev).value()] -= 2;
115
+ break;
116
+ default:
117
+ break;
118
+ }
119
+ // Flag used when it's necessary to explicitly store the previous symbol.
120
+ bool store_prev_symbol = true;
121
+ if (predicted_symbol != -1) {
122
+ if (predicted_symbol == prev_symbol_) {
123
+ predictions_.push_back(true);
124
+ store_prev_symbol = false;
125
+ } else if (prev_symbol_ != -1) {
126
+ predictions_.push_back(false);
127
+ }
128
+ }
129
+ if (store_prev_symbol && prev_symbol_ != -1) {
130
+ MeshEdgebreakerTraversalEncoder::EncodeSymbol(
131
+ static_cast<EdgebreakerTopologyBitPattern>(prev_symbol_));
132
+ }
133
+ prev_symbol_ = symbol;
134
+ }
135
+
136
+ void Done() {
137
+ // We still need to store the last encoded symbol.
138
+ if (prev_symbol_ != -1) {
139
+ MeshEdgebreakerTraversalEncoder::EncodeSymbol(
140
+ static_cast<EdgebreakerTopologyBitPattern>(prev_symbol_));
141
+ }
142
+ // Store the init face configurations and the explicitly encoded symbols.
143
+ MeshEdgebreakerTraversalEncoder::Done();
144
+ // Encode the number of split symbols.
145
+ GetOutputBuffer()->Encode(num_split_symbols_);
146
+ // Store the predictions.
147
+ BinaryEncoder prediction_encoder;
148
+ prediction_encoder.StartEncoding();
149
+ for (int i = static_cast<int>(predictions_.size()) - 1; i >= 0; --i) {
150
+ prediction_encoder.EncodeBit(predictions_[i]);
151
+ }
152
+ prediction_encoder.EndEncoding(GetOutputBuffer());
153
+ }
154
+
155
+ int NumEncodedSymbols() const { return num_symbols_; }
156
+
157
+ private:
158
+ const CornerTable *corner_table_;
159
+ std::vector<int> vertex_valences_;
160
+ std::vector<bool> predictions_;
161
+ // Previously encoded symbol.
162
+ int32_t prev_symbol_;
163
+ // The total number of encoded split symbols.
164
+ int32_t num_split_symbols_;
165
+ CornerIndex last_corner_;
166
+ // Explicitly count the number of encoded symbols.
167
+ int num_symbols_;
168
+ };
169
+
170
+ } // namespace draco
171
+
172
+ #endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_ENCODER_H_
@@ -0,0 +1,219 @@
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_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_
16
+ #define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_
17
+
18
+ #include "draco/compression/entropy/symbol_decoding.h"
19
+ #include "draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h"
20
+ #include "draco/core/varint_decoding.h"
21
+ #include "draco/draco_features.h"
22
+
23
+ namespace draco {
24
+
25
+ // Decoder for traversal encoded with MeshEdgebreakerTraversalValenceEncoder.
26
+ // The decoder maintains valences of the decoded portion of the traversed mesh
27
+ // and it uses them to select entropy context used for decoding of the actual
28
+ // symbols.
29
+ class MeshEdgebreakerTraversalValenceDecoder
30
+ : public MeshEdgebreakerTraversalDecoder {
31
+ public:
32
+ MeshEdgebreakerTraversalValenceDecoder()
33
+ : corner_table_(nullptr),
34
+ num_vertices_(0),
35
+ last_symbol_(-1),
36
+ active_context_(-1),
37
+ min_valence_(2),
38
+ max_valence_(7) {}
39
+ void Init(MeshEdgebreakerDecoderImplInterface *decoder) {
40
+ MeshEdgebreakerTraversalDecoder::Init(decoder);
41
+ corner_table_ = decoder->GetCornerTable();
42
+ }
43
+ void SetNumEncodedVertices(int num_vertices) { num_vertices_ = num_vertices; }
44
+
45
+ bool Start(DecoderBuffer *out_buffer) {
46
+ #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
47
+ if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) {
48
+ if (!MeshEdgebreakerTraversalDecoder::DecodeTraversalSymbols()) {
49
+ return false;
50
+ }
51
+ }
52
+ #endif
53
+ if (!MeshEdgebreakerTraversalDecoder::DecodeStartFaces()) {
54
+ return false;
55
+ }
56
+ if (!MeshEdgebreakerTraversalDecoder::DecodeAttributeSeams()) {
57
+ return false;
58
+ }
59
+ *out_buffer = *buffer();
60
+
61
+ #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
62
+ if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) {
63
+ uint32_t num_split_symbols;
64
+ if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 0)) {
65
+ if (!out_buffer->Decode(&num_split_symbols)) {
66
+ return false;
67
+ }
68
+ } else {
69
+ if (!DecodeVarint(&num_split_symbols, out_buffer)) {
70
+ return false;
71
+ }
72
+ }
73
+ if (num_split_symbols >= static_cast<uint32_t>(num_vertices_)) {
74
+ return false;
75
+ }
76
+
77
+ int8_t mode;
78
+ if (!out_buffer->Decode(&mode)) {
79
+ return false;
80
+ }
81
+ if (mode == EDGEBREAKER_VALENCE_MODE_2_7) {
82
+ min_valence_ = 2;
83
+ max_valence_ = 7;
84
+ } else {
85
+ // Unsupported mode.
86
+ return false;
87
+ }
88
+
89
+ } else
90
+ #endif
91
+ {
92
+ min_valence_ = 2;
93
+ max_valence_ = 7;
94
+ }
95
+
96
+ if (num_vertices_ < 0) {
97
+ return false;
98
+ }
99
+ // Set the valences of all initial vertices to 0.
100
+ vertex_valences_.resize(num_vertices_, 0);
101
+
102
+ const int num_unique_valences = max_valence_ - min_valence_ + 1;
103
+
104
+ // Decode all symbols for all contexts.
105
+ context_symbols_.resize(num_unique_valences);
106
+ context_counters_.resize(context_symbols_.size());
107
+ for (int i = 0; i < context_symbols_.size(); ++i) {
108
+ uint32_t num_symbols;
109
+ if (!DecodeVarint<uint32_t>(&num_symbols, out_buffer)) {
110
+ return false;
111
+ }
112
+ if (num_symbols > static_cast<uint32_t>(corner_table_->num_faces())) {
113
+ return false;
114
+ }
115
+ if (num_symbols > 0) {
116
+ context_symbols_[i].resize(num_symbols);
117
+ DecodeSymbols(num_symbols, 1, out_buffer, context_symbols_[i].data());
118
+ // All symbols are going to be processed from the back.
119
+ context_counters_[i] = num_symbols;
120
+ }
121
+ }
122
+ return true;
123
+ }
124
+
125
+ inline uint32_t DecodeSymbol() {
126
+ // First check if we have a valid context.
127
+ if (active_context_ != -1) {
128
+ const int context_counter = --context_counters_[active_context_];
129
+ if (context_counter < 0) {
130
+ return TOPOLOGY_INVALID;
131
+ }
132
+ const uint32_t symbol_id =
133
+ context_symbols_[active_context_][context_counter];
134
+ if (symbol_id > 4) {
135
+ return TOPOLOGY_INVALID;
136
+ }
137
+ last_symbol_ = edge_breaker_symbol_to_topology_id[symbol_id];
138
+ } else {
139
+ #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
140
+ if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) {
141
+ // We don't have a predicted symbol or the symbol was mis-predicted.
142
+ // Decode it directly.
143
+ last_symbol_ = MeshEdgebreakerTraversalDecoder::DecodeSymbol();
144
+
145
+ } else
146
+ #endif
147
+ {
148
+ // The first symbol must be E.
149
+ last_symbol_ = TOPOLOGY_E;
150
+ }
151
+ }
152
+ return last_symbol_;
153
+ }
154
+
155
+ inline void NewActiveCornerReached(CornerIndex corner) {
156
+ const CornerIndex next = corner_table_->Next(corner);
157
+ const CornerIndex prev = corner_table_->Previous(corner);
158
+ // Update valences.
159
+ switch (last_symbol_) {
160
+ case TOPOLOGY_C:
161
+ case TOPOLOGY_S:
162
+ vertex_valences_[corner_table_->Vertex(next)] += 1;
163
+ vertex_valences_[corner_table_->Vertex(prev)] += 1;
164
+ break;
165
+ case TOPOLOGY_R:
166
+ vertex_valences_[corner_table_->Vertex(corner)] += 1;
167
+ vertex_valences_[corner_table_->Vertex(next)] += 1;
168
+ vertex_valences_[corner_table_->Vertex(prev)] += 2;
169
+ break;
170
+ case TOPOLOGY_L:
171
+ vertex_valences_[corner_table_->Vertex(corner)] += 1;
172
+ vertex_valences_[corner_table_->Vertex(next)] += 2;
173
+ vertex_valences_[corner_table_->Vertex(prev)] += 1;
174
+ break;
175
+ case TOPOLOGY_E:
176
+ vertex_valences_[corner_table_->Vertex(corner)] += 2;
177
+ vertex_valences_[corner_table_->Vertex(next)] += 2;
178
+ vertex_valences_[corner_table_->Vertex(prev)] += 2;
179
+ break;
180
+ default:
181
+ break;
182
+ }
183
+ // Compute the new context that is going to be used to decode the next
184
+ // symbol.
185
+ const int active_valence = vertex_valences_[corner_table_->Vertex(next)];
186
+ int clamped_valence;
187
+ if (active_valence < min_valence_) {
188
+ clamped_valence = min_valence_;
189
+ } else if (active_valence > max_valence_) {
190
+ clamped_valence = max_valence_;
191
+ } else {
192
+ clamped_valence = active_valence;
193
+ }
194
+
195
+ active_context_ = (clamped_valence - min_valence_);
196
+ }
197
+
198
+ inline void MergeVertices(VertexIndex dest, VertexIndex source) {
199
+ // Update valences on the merged vertices.
200
+ vertex_valences_[dest] += vertex_valences_[source];
201
+ }
202
+
203
+ private:
204
+ const CornerTable *corner_table_;
205
+ int num_vertices_;
206
+ IndexTypeVector<VertexIndex, int> vertex_valences_;
207
+ int last_symbol_;
208
+ int active_context_;
209
+
210
+ int min_valence_;
211
+ int max_valence_;
212
+ std::vector<std::vector<uint32_t>> context_symbols_;
213
+ // Points to the active symbol in each context.
214
+ std::vector<int> context_counters_;
215
+ };
216
+
217
+ } // namespace draco
218
+
219
+ #endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_