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
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
// File containing a basic set of bit manipulation utilities used within the
|
|
16
|
+
// Draco library.
|
|
17
|
+
|
|
18
|
+
#ifndef DRACO_CORE_BIT_UTILS_H_
|
|
19
|
+
#define DRACO_CORE_BIT_UTILS_H_
|
|
20
|
+
|
|
21
|
+
#include <inttypes.h>
|
|
22
|
+
#include <stdint.h>
|
|
23
|
+
|
|
24
|
+
#include <type_traits>
|
|
25
|
+
|
|
26
|
+
#if defined(_MSC_VER)
|
|
27
|
+
#include <intrin.h>
|
|
28
|
+
#endif // defined(_MSC_VER)
|
|
29
|
+
|
|
30
|
+
namespace draco {
|
|
31
|
+
|
|
32
|
+
// Returns the number of '1' bits within the input 32 bit integer.
|
|
33
|
+
inline int CountOneBits32(uint32_t n) {
|
|
34
|
+
n -= ((n >> 1) & 0x55555555);
|
|
35
|
+
n = ((n >> 2) & 0x33333333) + (n & 0x33333333);
|
|
36
|
+
return (((n + (n >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
inline uint32_t ReverseBits32(uint32_t n) {
|
|
40
|
+
n = ((n >> 1) & 0x55555555) | ((n & 0x55555555) << 1);
|
|
41
|
+
n = ((n >> 2) & 0x33333333) | ((n & 0x33333333) << 2);
|
|
42
|
+
n = ((n >> 4) & 0x0F0F0F0F) | ((n & 0x0F0F0F0F) << 4);
|
|
43
|
+
n = ((n >> 8) & 0x00FF00FF) | ((n & 0x00FF00FF) << 8);
|
|
44
|
+
return (n >> 16) | (n << 16);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Copies the |nbits| from the src integer into the |dst| integer using the
|
|
48
|
+
// provided bit offsets |dst_offset| and |src_offset|.
|
|
49
|
+
inline void CopyBits32(uint32_t *dst, int dst_offset, uint32_t src,
|
|
50
|
+
int src_offset, int nbits) {
|
|
51
|
+
const uint32_t mask = (~static_cast<uint32_t>(0)) >> (32 - nbits)
|
|
52
|
+
<< dst_offset;
|
|
53
|
+
*dst = (*dst & (~mask)) | (((src >> src_offset) << dst_offset) & mask);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Returns the location of the most significant bit in the input integer |n|.
|
|
57
|
+
// The functionality is not defined for |n == 0|.
|
|
58
|
+
inline int MostSignificantBit(uint32_t n) {
|
|
59
|
+
#if defined(__GNUC__)
|
|
60
|
+
return 31 ^ __builtin_clz(n);
|
|
61
|
+
#elif defined(_MSC_VER)
|
|
62
|
+
unsigned long where;
|
|
63
|
+
_BitScanReverse(&where, n);
|
|
64
|
+
return (int)where;
|
|
65
|
+
#else
|
|
66
|
+
uint32_t msb = 0;
|
|
67
|
+
if (n) {
|
|
68
|
+
if (0xFFFF0000 & n) { n >>= (1 << 4); msb |= (1 << 4); }
|
|
69
|
+
if (0x0000FF00 & n) { n >>= (1 << 3); msb |= (1 << 3); }
|
|
70
|
+
if (0x000000F0 & n) { n >>= (1 << 2); msb |= (1 << 2); }
|
|
71
|
+
if (0x0000000C & n) { n >>= (1 << 1); msb |= (1 << 1); }
|
|
72
|
+
if (0x00000002 & n) { msb |= (1 << 0); }
|
|
73
|
+
} else {
|
|
74
|
+
msb = -1;
|
|
75
|
+
}
|
|
76
|
+
return msb;
|
|
77
|
+
#endif
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Helper function that converts signed integer values into unsigned integer
|
|
81
|
+
// symbols that can be encoded using an entropy encoder.
|
|
82
|
+
void ConvertSignedIntsToSymbols(const int32_t *in, int in_values,
|
|
83
|
+
uint32_t *out);
|
|
84
|
+
|
|
85
|
+
// Converts unsigned integer symbols encoded with an entropy encoder back to
|
|
86
|
+
// signed values.
|
|
87
|
+
void ConvertSymbolsToSignedInts(const uint32_t *in, int in_values,
|
|
88
|
+
int32_t *out);
|
|
89
|
+
|
|
90
|
+
// Helper function that converts a single signed integer value into an unsigned
|
|
91
|
+
// integer symbol that can be encoded using an entropy encoder.
|
|
92
|
+
template <class IntTypeT>
|
|
93
|
+
typename std::make_unsigned<IntTypeT>::type ConvertSignedIntToSymbol(
|
|
94
|
+
IntTypeT val) {
|
|
95
|
+
typedef typename std::make_unsigned<IntTypeT>::type UnsignedType;
|
|
96
|
+
static_assert(std::is_integral<IntTypeT>::value, "IntTypeT is not integral.");
|
|
97
|
+
// Early exit if val is positive.
|
|
98
|
+
if (val >= 0) {
|
|
99
|
+
return static_cast<UnsignedType>(val) << 1;
|
|
100
|
+
}
|
|
101
|
+
val = -(val + 1); // Map -1 to 0, -2 to -1, etc..
|
|
102
|
+
UnsignedType ret = static_cast<UnsignedType>(val);
|
|
103
|
+
ret <<= 1;
|
|
104
|
+
ret |= 1;
|
|
105
|
+
return ret;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Converts a single unsigned integer symbol encoded with an entropy encoder
|
|
109
|
+
// back to a signed value.
|
|
110
|
+
template <class IntTypeT>
|
|
111
|
+
typename std::make_signed<IntTypeT>::type ConvertSymbolToSignedInt(
|
|
112
|
+
IntTypeT val) {
|
|
113
|
+
static_assert(std::is_integral<IntTypeT>::value, "IntTypeT is not integral.");
|
|
114
|
+
typedef typename std::make_signed<IntTypeT>::type SignedType;
|
|
115
|
+
const bool is_positive = !static_cast<bool>(val & 1);
|
|
116
|
+
val >>= 1;
|
|
117
|
+
if (is_positive) {
|
|
118
|
+
return static_cast<SignedType>(val);
|
|
119
|
+
}
|
|
120
|
+
SignedType ret = static_cast<SignedType>(val);
|
|
121
|
+
ret = -ret - 1;
|
|
122
|
+
return ret;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
} // namespace draco
|
|
126
|
+
|
|
127
|
+
#endif // DRACO_CORE_BIT_UTILS_H_
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright 2018 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_CORE_BOUNDING_BOX_H_
|
|
16
|
+
#define DRACO_CORE_BOUNDING_BOX_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/core/vector_d.h"
|
|
19
|
+
|
|
20
|
+
namespace draco {
|
|
21
|
+
|
|
22
|
+
// Class for computing the bounding box of points in 3D space.
|
|
23
|
+
class BoundingBox {
|
|
24
|
+
public:
|
|
25
|
+
// Creates bounding box object with minimum and maximum points initialized to
|
|
26
|
+
// the largest positive and the smallest negative values, respectively. The
|
|
27
|
+
// resulting abstract bounding box effectively has no points and can be
|
|
28
|
+
// updated by providing any point to Update() method.
|
|
29
|
+
BoundingBox();
|
|
30
|
+
|
|
31
|
+
// Creates bounding box object with minimum and maximum points initialized to
|
|
32
|
+
// |min_point| and |max_point|, respectively.
|
|
33
|
+
BoundingBox(const Vector3f &min_point, const Vector3f &max_point);
|
|
34
|
+
|
|
35
|
+
// Returns the minimum point of the bounding box.
|
|
36
|
+
inline const Vector3f &GetMinPoint() const { return min_point_; }
|
|
37
|
+
|
|
38
|
+
// Returns the maximum point of the bounding box.
|
|
39
|
+
inline const Vector3f &GetMaxPoint() const { return max_point_; }
|
|
40
|
+
|
|
41
|
+
// Checks if the bounding box object was created with the default constructor
|
|
42
|
+
// then never updated. Internally, checks if the bounding box minimum and
|
|
43
|
+
// maximum points hold the largest positive and smallest negative values.
|
|
44
|
+
bool IsValid() const;
|
|
45
|
+
|
|
46
|
+
// Conditionally updates the bounding box with a given |new_point|.
|
|
47
|
+
void Update(const Vector3f &new_point) {
|
|
48
|
+
for (int i = 0; i < 3; i++) {
|
|
49
|
+
if (new_point[i] < min_point_[i]) {
|
|
50
|
+
min_point_[i] = new_point[i];
|
|
51
|
+
}
|
|
52
|
+
if (new_point[i] > max_point_[i]) {
|
|
53
|
+
max_point_[i] = new_point[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Updates bounding box with minimum and maximum points of the |other|
|
|
59
|
+
// bounding box.
|
|
60
|
+
void Update(const BoundingBox &other) {
|
|
61
|
+
Update(other.GetMinPoint());
|
|
62
|
+
Update(other.GetMaxPoint());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Returns the size of the bounding box along each axis.
|
|
66
|
+
Vector3f Size() const { return max_point_ - min_point_; }
|
|
67
|
+
|
|
68
|
+
// Returns the center of the bounding box.
|
|
69
|
+
Vector3f Center() const { return (min_point_ + max_point_) / 2; }
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
Vector3f min_point_;
|
|
73
|
+
Vector3f max_point_;
|
|
74
|
+
};
|
|
75
|
+
} // namespace draco
|
|
76
|
+
|
|
77
|
+
#endif // DRACO_CORE_BOUNDING_BOX_H_
|
|
@@ -0,0 +1,51 @@
|
|
|
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_CORE_CYCLE_TIMER_H_
|
|
16
|
+
#define DRACO_CORE_CYCLE_TIMER_H_
|
|
17
|
+
|
|
18
|
+
#ifdef _WIN32
|
|
19
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
|
20
|
+
#define WIN32_LEAN_AND_MEAN
|
|
21
|
+
#endif
|
|
22
|
+
#include <windows.h>
|
|
23
|
+
typedef LARGE_INTEGER DracoTimeVal;
|
|
24
|
+
#else
|
|
25
|
+
#include <sys/time.h>
|
|
26
|
+
typedef timeval DracoTimeVal;
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#include <cinttypes>
|
|
30
|
+
#include <cstddef>
|
|
31
|
+
|
|
32
|
+
namespace draco {
|
|
33
|
+
|
|
34
|
+
class DracoTimer {
|
|
35
|
+
public:
|
|
36
|
+
DracoTimer() {}
|
|
37
|
+
~DracoTimer() {}
|
|
38
|
+
void Start();
|
|
39
|
+
void Stop();
|
|
40
|
+
int64_t GetInMs();
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
DracoTimeVal tv_start_;
|
|
44
|
+
DracoTimeVal tv_end_;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
typedef DracoTimer CycleTimer;
|
|
48
|
+
|
|
49
|
+
} // namespace draco
|
|
50
|
+
|
|
51
|
+
#endif // DRACO_CORE_CYCLE_TIMER_H_
|
|
@@ -0,0 +1,82 @@
|
|
|
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_CORE_DATA_BUFFER_H_
|
|
16
|
+
#define DRACO_CORE_DATA_BUFFER_H_
|
|
17
|
+
|
|
18
|
+
#include <cstring>
|
|
19
|
+
#include <ostream>
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
#include "draco/core/draco_types.h"
|
|
23
|
+
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
// Buffer descriptor servers as a unique identifier of a buffer.
|
|
27
|
+
struct DataBufferDescriptor {
|
|
28
|
+
DataBufferDescriptor() : buffer_id(0), buffer_update_count(0) {}
|
|
29
|
+
// Id of the data buffer.
|
|
30
|
+
int64_t buffer_id;
|
|
31
|
+
// The number of times the buffer content was updated.
|
|
32
|
+
int64_t buffer_update_count;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Class used for storing raw buffer data.
|
|
36
|
+
class DataBuffer {
|
|
37
|
+
public:
|
|
38
|
+
DataBuffer();
|
|
39
|
+
bool Update(const void *data, int64_t size);
|
|
40
|
+
bool Update(const void *data, int64_t size, int64_t offset);
|
|
41
|
+
|
|
42
|
+
// Reallocate the buffer storage to a new size keeping the data unchanged.
|
|
43
|
+
void Resize(int64_t new_size);
|
|
44
|
+
void WriteDataToStream(std::ostream &stream);
|
|
45
|
+
// Reads data from the buffer. Potentially unsafe, called needs to ensure
|
|
46
|
+
// the accessed memory is valid.
|
|
47
|
+
void Read(int64_t byte_pos, void *out_data, size_t data_size) const {
|
|
48
|
+
memcpy(out_data, data() + byte_pos, data_size);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Writes data to the buffer. Unsafe, caller must ensure the accessed memory
|
|
52
|
+
// is valid.
|
|
53
|
+
void Write(int64_t byte_pos, const void *in_data, size_t data_size) {
|
|
54
|
+
memcpy(const_cast<uint8_t *>(data()) + byte_pos, in_data, data_size);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Copies data from another buffer to this buffer.
|
|
58
|
+
void Copy(int64_t dst_offset, const DataBuffer *src_buf, int64_t src_offset,
|
|
59
|
+
int64_t size) {
|
|
60
|
+
memcpy(const_cast<uint8_t *>(data()) + dst_offset,
|
|
61
|
+
src_buf->data() + src_offset, size);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void set_update_count(int64_t buffer_update_count) {
|
|
65
|
+
descriptor_.buffer_update_count = buffer_update_count;
|
|
66
|
+
}
|
|
67
|
+
int64_t update_count() const { return descriptor_.buffer_update_count; }
|
|
68
|
+
size_t data_size() const { return data_.size(); }
|
|
69
|
+
const uint8_t *data() const { return data_.data(); }
|
|
70
|
+
uint8_t *data() { return data_.data(); }
|
|
71
|
+
int64_t buffer_id() const { return descriptor_.buffer_id; }
|
|
72
|
+
void set_buffer_id(int64_t buffer_id) { descriptor_.buffer_id = buffer_id; }
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
std::vector<uint8_t> data_;
|
|
76
|
+
// Counter incremented by Update() calls.
|
|
77
|
+
DataBufferDescriptor descriptor_;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace draco
|
|
81
|
+
|
|
82
|
+
#endif // DRACO_CORE_DATA_BUFFER_H_
|
|
@@ -0,0 +1,216 @@
|
|
|
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_CORE_DECODER_BUFFER_H_
|
|
16
|
+
#define DRACO_CORE_DECODER_BUFFER_H_
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
|
|
20
|
+
#include <cstring>
|
|
21
|
+
#include <memory>
|
|
22
|
+
|
|
23
|
+
#include "draco/core/macros.h"
|
|
24
|
+
#include "draco/draco_features.h"
|
|
25
|
+
|
|
26
|
+
namespace draco {
|
|
27
|
+
|
|
28
|
+
// Class is a wrapper around input data used by MeshDecoder. It provides a
|
|
29
|
+
// basic interface for decoding either typed or variable-bit sized data.
|
|
30
|
+
class DecoderBuffer {
|
|
31
|
+
public:
|
|
32
|
+
DecoderBuffer();
|
|
33
|
+
DecoderBuffer(const DecoderBuffer &buf) = default;
|
|
34
|
+
|
|
35
|
+
DecoderBuffer &operator=(const DecoderBuffer &buf) = default;
|
|
36
|
+
|
|
37
|
+
// Sets the buffer's internal data. Note that no copy of the input data is
|
|
38
|
+
// made so the data owner needs to keep the data valid and unchanged for
|
|
39
|
+
// runtime of the decoder.
|
|
40
|
+
void Init(const char *data, size_t data_size);
|
|
41
|
+
|
|
42
|
+
// Sets the buffer's internal data. |version| is the Draco bitstream version.
|
|
43
|
+
void Init(const char *data, size_t data_size, uint16_t version);
|
|
44
|
+
|
|
45
|
+
// Starts decoding a bit sequence.
|
|
46
|
+
// decode_size must be true if the size of the encoded bit data was included,
|
|
47
|
+
// during encoding. The size is then returned to out_size.
|
|
48
|
+
// Returns false on error.
|
|
49
|
+
bool StartBitDecoding(bool decode_size, uint64_t *out_size);
|
|
50
|
+
|
|
51
|
+
// Ends the decoding of the bit sequence and return to the default
|
|
52
|
+
// byte-aligned decoding.
|
|
53
|
+
void EndBitDecoding();
|
|
54
|
+
|
|
55
|
+
// Decodes up to 32 bits into out_val. Can be called only in between
|
|
56
|
+
// StartBitDecoding and EndBitDecoding. Otherwise returns false.
|
|
57
|
+
bool DecodeLeastSignificantBits32(uint32_t nbits, uint32_t *out_value) {
|
|
58
|
+
if (!bit_decoder_active()) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return bit_decoder_.GetBits(nbits, out_value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Decodes an arbitrary data type.
|
|
65
|
+
// Can be used only when we are not decoding a bit-sequence.
|
|
66
|
+
// Returns false on error.
|
|
67
|
+
template <typename T>
|
|
68
|
+
bool Decode(T *out_val) {
|
|
69
|
+
if (!Peek(out_val)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
pos_ += sizeof(T);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
bool Decode(void *out_data, size_t size_to_decode) {
|
|
77
|
+
if (data_size_ < static_cast<int64_t>(pos_ + size_to_decode)) {
|
|
78
|
+
return false; // Buffer overflow.
|
|
79
|
+
}
|
|
80
|
+
memcpy(out_data, (data_ + pos_), size_to_decode);
|
|
81
|
+
pos_ += size_to_decode;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Decodes an arbitrary data, but does not advance the reading position.
|
|
86
|
+
template <typename T>
|
|
87
|
+
bool Peek(T *out_val) {
|
|
88
|
+
const size_t size_to_decode = sizeof(T);
|
|
89
|
+
if (data_size_ < static_cast<int64_t>(pos_ + size_to_decode)) {
|
|
90
|
+
return false; // Buffer overflow.
|
|
91
|
+
}
|
|
92
|
+
memcpy(out_val, (data_ + pos_), size_to_decode);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
bool Peek(void *out_data, size_t size_to_peek) {
|
|
97
|
+
if (data_size_ < static_cast<int64_t>(pos_ + size_to_peek)) {
|
|
98
|
+
return false; // Buffer overflow.
|
|
99
|
+
}
|
|
100
|
+
memcpy(out_data, (data_ + pos_), size_to_peek);
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Discards #bytes from the input buffer.
|
|
105
|
+
void Advance(int64_t bytes) { pos_ += bytes; }
|
|
106
|
+
|
|
107
|
+
// Moves the parsing position to a specific offset from the beginning of the
|
|
108
|
+
// input data.
|
|
109
|
+
void StartDecodingFrom(int64_t offset) { pos_ = offset; }
|
|
110
|
+
|
|
111
|
+
void set_bitstream_version(uint16_t version) { bitstream_version_ = version; }
|
|
112
|
+
|
|
113
|
+
// Returns the data array at the current decoder position.
|
|
114
|
+
const char *data_head() const { return data_ + pos_; }
|
|
115
|
+
int64_t remaining_size() const { return data_size_ - pos_; }
|
|
116
|
+
int64_t decoded_size() const { return pos_; }
|
|
117
|
+
bool bit_decoder_active() const { return bit_mode_; }
|
|
118
|
+
|
|
119
|
+
// Returns the bitstream associated with the data. Returns 0 if unknown.
|
|
120
|
+
uint16_t bitstream_version() const { return bitstream_version_; }
|
|
121
|
+
|
|
122
|
+
private:
|
|
123
|
+
// Internal helper class to decode bits from a bit buffer.
|
|
124
|
+
class BitDecoder {
|
|
125
|
+
public:
|
|
126
|
+
BitDecoder();
|
|
127
|
+
~BitDecoder();
|
|
128
|
+
|
|
129
|
+
// Sets the bit buffer to |b|. |s| is the size of |b| in bytes.
|
|
130
|
+
inline void reset(const void *b, size_t s) {
|
|
131
|
+
bit_offset_ = 0;
|
|
132
|
+
bit_buffer_ = static_cast<const uint8_t *>(b);
|
|
133
|
+
bit_buffer_end_ = bit_buffer_ + s;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Returns number of bits decoded so far.
|
|
137
|
+
inline uint64_t BitsDecoded() const {
|
|
138
|
+
return static_cast<uint64_t>(bit_offset_);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Return number of bits available for decoding
|
|
142
|
+
inline uint64_t AvailBits() const {
|
|
143
|
+
return ((bit_buffer_end_ - bit_buffer_) * 8) - bit_offset_;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
inline uint32_t EnsureBits(int k) {
|
|
147
|
+
DRACO_DCHECK_LE(k, 24);
|
|
148
|
+
DRACO_DCHECK_LE(static_cast<uint64_t>(k), AvailBits());
|
|
149
|
+
|
|
150
|
+
uint32_t buf = 0;
|
|
151
|
+
for (int i = 0; i < k; ++i) {
|
|
152
|
+
buf |= PeekBit(i) << i;
|
|
153
|
+
}
|
|
154
|
+
return buf; // Okay to return extra bits
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
inline void ConsumeBits(int k) { bit_offset_ += k; }
|
|
158
|
+
|
|
159
|
+
// Returns |nbits| bits in |x|.
|
|
160
|
+
inline bool GetBits(uint32_t nbits, uint32_t *x) {
|
|
161
|
+
if (nbits > 32) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
uint32_t value = 0;
|
|
165
|
+
for (uint32_t bit = 0; bit < nbits; ++bit) {
|
|
166
|
+
value |= GetBit() << bit;
|
|
167
|
+
}
|
|
168
|
+
*x = value;
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private:
|
|
173
|
+
// TODO(fgalligan): Add support for error reporting on range check.
|
|
174
|
+
// Returns one bit from the bit buffer.
|
|
175
|
+
inline int GetBit() {
|
|
176
|
+
const size_t off = bit_offset_;
|
|
177
|
+
const size_t byte_offset = off >> 3;
|
|
178
|
+
const int bit_shift = static_cast<int>(off & 0x7);
|
|
179
|
+
if (bit_buffer_ + byte_offset < bit_buffer_end_) {
|
|
180
|
+
const int bit = (bit_buffer_[byte_offset] >> bit_shift) & 1;
|
|
181
|
+
bit_offset_ = off + 1;
|
|
182
|
+
return bit;
|
|
183
|
+
}
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
inline int PeekBit(int offset) {
|
|
188
|
+
const size_t off = bit_offset_ + offset;
|
|
189
|
+
const size_t byte_offset = off >> 3;
|
|
190
|
+
const int bit_shift = static_cast<int>(off & 0x7);
|
|
191
|
+
if (bit_buffer_ + byte_offset < bit_buffer_end_) {
|
|
192
|
+
const int bit = (bit_buffer_[byte_offset] >> bit_shift) & 1;
|
|
193
|
+
return bit;
|
|
194
|
+
}
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const uint8_t *bit_buffer_;
|
|
199
|
+
const uint8_t *bit_buffer_end_;
|
|
200
|
+
size_t bit_offset_;
|
|
201
|
+
};
|
|
202
|
+
friend class BufferBitCodingTest;
|
|
203
|
+
|
|
204
|
+
const char *data_;
|
|
205
|
+
int64_t data_size_;
|
|
206
|
+
|
|
207
|
+
// Current parsing position of the decoder.
|
|
208
|
+
int64_t pos_;
|
|
209
|
+
BitDecoder bit_decoder_;
|
|
210
|
+
bool bit_mode_;
|
|
211
|
+
uint16_t bitstream_version_;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
} // namespace draco
|
|
215
|
+
|
|
216
|
+
#endif // DRACO_CORE_DECODER_BUFFER_H_
|
|
@@ -0,0 +1,42 @@
|
|
|
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_CORE_DIVIDE_H_
|
|
16
|
+
#define DRACO_CORE_DIVIDE_H_
|
|
17
|
+
// An implementation of the divide by multiply algorithm
|
|
18
|
+
// https://gmplib.org/~tege/divcnst-pldi94.pdf
|
|
19
|
+
// This file is based off libvpx's divide.h.
|
|
20
|
+
|
|
21
|
+
#include <stdint.h>
|
|
22
|
+
|
|
23
|
+
#include <climits>
|
|
24
|
+
|
|
25
|
+
namespace draco {
|
|
26
|
+
|
|
27
|
+
struct fastdiv_elem {
|
|
28
|
+
unsigned mult;
|
|
29
|
+
unsigned shift;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
extern const struct fastdiv_elem vp10_fastdiv_tab[256];
|
|
33
|
+
|
|
34
|
+
static inline unsigned fastdiv(unsigned x, int y) {
|
|
35
|
+
unsigned t =
|
|
36
|
+
((uint64_t)x * vp10_fastdiv_tab[y].mult) >> (sizeof(x) * CHAR_BIT);
|
|
37
|
+
return (t + x) >> vp10_fastdiv_tab[y].shift;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
} // namespace draco
|
|
41
|
+
|
|
42
|
+
#endif // DRACO_CORE_DIVIDE_H_
|