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,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
|
+
// Functions for creating prediction schemes for encoders using the provided
|
|
16
|
+
// prediction method id.
|
|
17
|
+
|
|
18
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_FACTORY_H_
|
|
19
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_FACTORY_H_
|
|
20
|
+
|
|
21
|
+
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h"
|
|
22
|
+
#ifdef DRACO_NORMAL_ENCODING_SUPPORTED
|
|
23
|
+
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h"
|
|
24
|
+
#endif
|
|
25
|
+
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h"
|
|
26
|
+
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h"
|
|
27
|
+
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h"
|
|
28
|
+
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h"
|
|
29
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h"
|
|
30
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h"
|
|
31
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h"
|
|
32
|
+
#include "draco/compression/mesh/mesh_encoder.h"
|
|
33
|
+
|
|
34
|
+
namespace draco {
|
|
35
|
+
|
|
36
|
+
// Selects a prediction method based on the input geometry type and based on the
|
|
37
|
+
// encoder options.
|
|
38
|
+
PredictionSchemeMethod SelectPredictionMethod(int att_id,
|
|
39
|
+
const PointCloudEncoder *encoder);
|
|
40
|
+
|
|
41
|
+
PredictionSchemeMethod SelectPredictionMethod(int att_id,
|
|
42
|
+
const EncoderOptions &options,
|
|
43
|
+
const PointCloudEncoder *encoder);
|
|
44
|
+
|
|
45
|
+
// Factory class for creating mesh prediction schemes.
|
|
46
|
+
template <typename DataTypeT>
|
|
47
|
+
struct MeshPredictionSchemeEncoderFactory {
|
|
48
|
+
template <class TransformT, class MeshDataT>
|
|
49
|
+
std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>> operator()(
|
|
50
|
+
PredictionSchemeMethod method, const PointAttribute *attribute,
|
|
51
|
+
const TransformT &transform, const MeshDataT &mesh_data,
|
|
52
|
+
uint16_t bitstream_version) {
|
|
53
|
+
if (method == MESH_PREDICTION_PARALLELOGRAM) {
|
|
54
|
+
return std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>(
|
|
55
|
+
new MeshPredictionSchemeParallelogramEncoder<DataTypeT, TransformT,
|
|
56
|
+
MeshDataT>(
|
|
57
|
+
attribute, transform, mesh_data));
|
|
58
|
+
} else if (method == MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM) {
|
|
59
|
+
return std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>(
|
|
60
|
+
new MeshPredictionSchemeConstrainedMultiParallelogramEncoder<
|
|
61
|
+
DataTypeT, TransformT, MeshDataT>(attribute, transform,
|
|
62
|
+
mesh_data));
|
|
63
|
+
} else if (method == MESH_PREDICTION_TEX_COORDS_PORTABLE) {
|
|
64
|
+
return std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>(
|
|
65
|
+
new MeshPredictionSchemeTexCoordsPortableEncoder<
|
|
66
|
+
DataTypeT, TransformT, MeshDataT>(attribute, transform,
|
|
67
|
+
mesh_data));
|
|
68
|
+
}
|
|
69
|
+
#ifdef DRACO_NORMAL_ENCODING_SUPPORTED
|
|
70
|
+
else if (method == MESH_PREDICTION_GEOMETRIC_NORMAL) {
|
|
71
|
+
return std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>(
|
|
72
|
+
new MeshPredictionSchemeGeometricNormalEncoder<DataTypeT, TransformT,
|
|
73
|
+
MeshDataT>(
|
|
74
|
+
attribute, transform, mesh_data));
|
|
75
|
+
}
|
|
76
|
+
#endif
|
|
77
|
+
return nullptr;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Creates a prediction scheme for a given encoder and given prediction method.
|
|
82
|
+
// The prediction schemes are automatically initialized with encoder specific
|
|
83
|
+
// data if needed.
|
|
84
|
+
template <typename DataTypeT, class TransformT>
|
|
85
|
+
std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>
|
|
86
|
+
CreatePredictionSchemeForEncoder(PredictionSchemeMethod method, int att_id,
|
|
87
|
+
const PointCloudEncoder *encoder,
|
|
88
|
+
const TransformT &transform) {
|
|
89
|
+
const PointAttribute *const att = encoder->point_cloud()->attribute(att_id);
|
|
90
|
+
if (method == PREDICTION_UNDEFINED) {
|
|
91
|
+
method = SelectPredictionMethod(att_id, encoder);
|
|
92
|
+
}
|
|
93
|
+
if (method == PREDICTION_NONE) {
|
|
94
|
+
return nullptr; // No prediction is used.
|
|
95
|
+
}
|
|
96
|
+
if (encoder->GetGeometryType() == TRIANGULAR_MESH) {
|
|
97
|
+
// Cast the encoder to mesh encoder. This is not necessarily safe if there
|
|
98
|
+
// is some other encoder decides to use TRIANGULAR_MESH as the return type,
|
|
99
|
+
// but unfortunately there is not nice work around for this without using
|
|
100
|
+
// RTTI (double dispatch and similar concepts will not work because of the
|
|
101
|
+
// template nature of the prediction schemes).
|
|
102
|
+
const MeshEncoder *const mesh_encoder =
|
|
103
|
+
static_cast<const MeshEncoder *>(encoder);
|
|
104
|
+
const uint16_t bitstream_version = kDracoMeshBitstreamVersion;
|
|
105
|
+
auto ret = CreateMeshPredictionScheme<
|
|
106
|
+
MeshEncoder, PredictionSchemeEncoder<DataTypeT, TransformT>,
|
|
107
|
+
MeshPredictionSchemeEncoderFactory<DataTypeT>>(
|
|
108
|
+
mesh_encoder, method, att_id, transform, bitstream_version);
|
|
109
|
+
if (ret) {
|
|
110
|
+
return ret;
|
|
111
|
+
}
|
|
112
|
+
// Otherwise try to create another prediction scheme.
|
|
113
|
+
}
|
|
114
|
+
// Create delta encoder.
|
|
115
|
+
return std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>(
|
|
116
|
+
new PredictionSchemeDeltaEncoder<DataTypeT, TransformT>(att, transform));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Create a prediction scheme using a default transform constructor.
|
|
120
|
+
template <typename DataTypeT, class TransformT>
|
|
121
|
+
std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>
|
|
122
|
+
CreatePredictionSchemeForEncoder(PredictionSchemeMethod method, int att_id,
|
|
123
|
+
const PointCloudEncoder *encoder) {
|
|
124
|
+
return CreatePredictionSchemeForEncoder<DataTypeT, TransformT>(
|
|
125
|
+
method, att_id, encoder, TransformT());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Returns the preferred prediction scheme based on the encoder options.
|
|
129
|
+
PredictionSchemeMethod GetPredictionMethodFromOptions(
|
|
130
|
+
int att_id, const EncoderOptions &options);
|
|
131
|
+
|
|
132
|
+
} // namespace draco
|
|
133
|
+
|
|
134
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_FACTORY_H_
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_INTERFACE_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_INTERFACE_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h"
|
|
19
|
+
#include "draco/core/encoder_buffer.h"
|
|
20
|
+
|
|
21
|
+
// Prediction schemes can be used during encoding and decoding of attributes
|
|
22
|
+
// to predict attribute values based on the previously encoded/decoded data.
|
|
23
|
+
// See prediction_scheme.h for more details.
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
// Abstract interface for all prediction schemes used during attribute encoding.
|
|
27
|
+
class PredictionSchemeEncoderInterface : public PredictionSchemeInterface {
|
|
28
|
+
public:
|
|
29
|
+
// Method that can be used to encode any prediction scheme specific data
|
|
30
|
+
// into the output buffer.
|
|
31
|
+
virtual bool EncodePredictionData(EncoderBuffer *buffer) = 0;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// A specialized version of the prediction scheme interface for specific
|
|
35
|
+
// input and output data types.
|
|
36
|
+
// |entry_to_point_id_map| is the mapping between value entries to point ids
|
|
37
|
+
// of the associated point cloud, where one entry is defined as |num_components|
|
|
38
|
+
// values of the |in_data|.
|
|
39
|
+
// DataTypeT is the data type of input and predicted values.
|
|
40
|
+
// CorrTypeT is the data type used for storing corrected values.
|
|
41
|
+
template <typename DataTypeT, typename CorrTypeT = DataTypeT>
|
|
42
|
+
class PredictionSchemeTypedEncoderInterface
|
|
43
|
+
: public PredictionSchemeEncoderInterface {
|
|
44
|
+
public:
|
|
45
|
+
// Applies the prediction scheme when encoding the attribute.
|
|
46
|
+
// |in_data| contains value entries to be encoded.
|
|
47
|
+
// |out_corr| is an output array containing the to be encoded corrections.
|
|
48
|
+
virtual bool ComputeCorrectionValues(
|
|
49
|
+
const DataTypeT *in_data, CorrTypeT *out_corr, int size,
|
|
50
|
+
int num_components, const PointIndex *entry_to_point_id_map) = 0;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace draco
|
|
54
|
+
|
|
55
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_INTERFACE_H_
|
include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_TRANSFORM_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_TRANSFORM_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/config/compression_shared.h"
|
|
19
|
+
#include "draco/core/encoder_buffer.h"
|
|
20
|
+
|
|
21
|
+
namespace draco {
|
|
22
|
+
|
|
23
|
+
// PredictionSchemeEncodingTransform is used to transform predicted values into
|
|
24
|
+
// correction values.
|
|
25
|
+
// CorrTypeT is the data type used for storing corrected values. It allows
|
|
26
|
+
// transforms to store corrections into a different type or format compared to
|
|
27
|
+
// the predicted data.
|
|
28
|
+
template <typename DataTypeT, typename CorrTypeT>
|
|
29
|
+
class PredictionSchemeEncodingTransform {
|
|
30
|
+
public:
|
|
31
|
+
typedef CorrTypeT CorrType;
|
|
32
|
+
PredictionSchemeEncodingTransform() : num_components_(0) {}
|
|
33
|
+
|
|
34
|
+
PredictionSchemeTransformType GetType() const {
|
|
35
|
+
return PREDICTION_TRANSFORM_DELTA;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Performs any custom initialization of the transform for the encoder.
|
|
39
|
+
// |size| = total number of values in |orig_data| (i.e., number of entries *
|
|
40
|
+
// number of components).
|
|
41
|
+
void Init(const DataTypeT * /* orig_data */, int /* size */,
|
|
42
|
+
int num_components) {
|
|
43
|
+
num_components_ = num_components;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Computes the corrections based on the input original values and the
|
|
47
|
+
// predicted values. The correction is always computed for all components
|
|
48
|
+
// of the input element. |val_id| is the id of the input value
|
|
49
|
+
// (i.e., element_id * num_components). The default implementation is equal to
|
|
50
|
+
// std::minus.
|
|
51
|
+
inline void ComputeCorrection(const DataTypeT *original_vals,
|
|
52
|
+
const DataTypeT *predicted_vals,
|
|
53
|
+
CorrTypeT *out_corr_vals) {
|
|
54
|
+
static_assert(std::is_same<DataTypeT, CorrTypeT>::value,
|
|
55
|
+
"For the default prediction transform, correction and input "
|
|
56
|
+
"data must be of the same type.");
|
|
57
|
+
for (int i = 0; i < num_components_; ++i) {
|
|
58
|
+
out_corr_vals[i] = original_vals[i] - predicted_vals[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Encode any transform specific data.
|
|
63
|
+
bool EncodeTransformData(EncoderBuffer * /* buffer */) { return true; }
|
|
64
|
+
|
|
65
|
+
// Should return true if all corrected values are guaranteed to be positive.
|
|
66
|
+
bool AreCorrectionsPositive() const { return false; }
|
|
67
|
+
|
|
68
|
+
protected:
|
|
69
|
+
int num_components() const { return num_components_; }
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
int num_components_;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace draco
|
|
76
|
+
|
|
77
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_TRANSFORM_H_
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
// Functions for creating prediction schemes from a provided prediction method
|
|
16
|
+
// name. The functions in this file can create only basic prediction schemes
|
|
17
|
+
// that don't require any encoder or decoder specific data. To create more
|
|
18
|
+
// sophisticated prediction schemes, use functions from either
|
|
19
|
+
// prediction_scheme_encoder_factory.h or,
|
|
20
|
+
// prediction_scheme_decoder_factory.h.
|
|
21
|
+
|
|
22
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_FACTORY_H_
|
|
23
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_FACTORY_H_
|
|
24
|
+
|
|
25
|
+
#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h"
|
|
26
|
+
#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h"
|
|
27
|
+
#include "draco/compression/config/compression_shared.h"
|
|
28
|
+
#include "draco/mesh/mesh_attribute_corner_table.h"
|
|
29
|
+
|
|
30
|
+
namespace draco {
|
|
31
|
+
|
|
32
|
+
template <class EncodingDataSourceT, class PredictionSchemeT,
|
|
33
|
+
class MeshPredictionSchemeFactoryT>
|
|
34
|
+
std::unique_ptr<PredictionSchemeT> CreateMeshPredictionScheme(
|
|
35
|
+
const EncodingDataSourceT *source, PredictionSchemeMethod method,
|
|
36
|
+
int att_id, const typename PredictionSchemeT::Transform &transform,
|
|
37
|
+
uint16_t bitstream_version) {
|
|
38
|
+
const PointAttribute *const att = source->point_cloud()->attribute(att_id);
|
|
39
|
+
if (source->GetGeometryType() == TRIANGULAR_MESH &&
|
|
40
|
+
(method == MESH_PREDICTION_PARALLELOGRAM ||
|
|
41
|
+
method == MESH_PREDICTION_MULTI_PARALLELOGRAM ||
|
|
42
|
+
method == MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM ||
|
|
43
|
+
method == MESH_PREDICTION_TEX_COORDS_PORTABLE ||
|
|
44
|
+
method == MESH_PREDICTION_GEOMETRIC_NORMAL ||
|
|
45
|
+
method == MESH_PREDICTION_TEX_COORDS_DEPRECATED)) {
|
|
46
|
+
const CornerTable *const ct = source->GetCornerTable();
|
|
47
|
+
const MeshAttributeIndicesEncodingData *const encoding_data =
|
|
48
|
+
source->GetAttributeEncodingData(att_id);
|
|
49
|
+
if (ct == nullptr || encoding_data == nullptr) {
|
|
50
|
+
// No connectivity data found.
|
|
51
|
+
return nullptr;
|
|
52
|
+
}
|
|
53
|
+
// Connectivity data exists.
|
|
54
|
+
const MeshAttributeCornerTable *const att_ct =
|
|
55
|
+
source->GetAttributeCornerTable(att_id);
|
|
56
|
+
if (att_ct != nullptr) {
|
|
57
|
+
typedef MeshPredictionSchemeData<MeshAttributeCornerTable> MeshData;
|
|
58
|
+
MeshData md;
|
|
59
|
+
md.Set(source->mesh(), att_ct,
|
|
60
|
+
&encoding_data->encoded_attribute_value_index_to_corner_map,
|
|
61
|
+
&encoding_data->vertex_to_encoded_attribute_value_index_map);
|
|
62
|
+
MeshPredictionSchemeFactoryT factory;
|
|
63
|
+
auto ret = factory(method, att, transform, md, bitstream_version);
|
|
64
|
+
if (ret) {
|
|
65
|
+
return ret;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
typedef MeshPredictionSchemeData<CornerTable> MeshData;
|
|
69
|
+
MeshData md;
|
|
70
|
+
md.Set(source->mesh(), ct,
|
|
71
|
+
&encoding_data->encoded_attribute_value_index_to_corner_map,
|
|
72
|
+
&encoding_data->vertex_to_encoded_attribute_value_index_map);
|
|
73
|
+
MeshPredictionSchemeFactoryT factory;
|
|
74
|
+
auto ret = factory(method, att, transform, md, bitstream_version);
|
|
75
|
+
if (ret) {
|
|
76
|
+
return ret;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return nullptr;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
} // namespace draco
|
|
84
|
+
|
|
85
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_FACTORY_H_
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_INTERFACE_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_INTERFACE_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/attributes/point_attribute.h"
|
|
19
|
+
#include "draco/compression/config/compression_shared.h"
|
|
20
|
+
|
|
21
|
+
// Prediction schemes can be used during encoding and decoding of attributes
|
|
22
|
+
// to predict attribute values based on the previously encoded/decoded data.
|
|
23
|
+
// See prediction_scheme.h for more details.
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
// Abstract interface for all prediction schemes used during attribute encoding.
|
|
27
|
+
class PredictionSchemeInterface {
|
|
28
|
+
public:
|
|
29
|
+
virtual ~PredictionSchemeInterface() = default;
|
|
30
|
+
virtual PredictionSchemeMethod GetPredictionMethod() const = 0;
|
|
31
|
+
|
|
32
|
+
// Returns the encoded attribute.
|
|
33
|
+
virtual const PointAttribute *GetAttribute() const = 0;
|
|
34
|
+
|
|
35
|
+
// Returns true when the prediction scheme is initialized with all data it
|
|
36
|
+
// needs.
|
|
37
|
+
virtual bool IsInitialized() const = 0;
|
|
38
|
+
|
|
39
|
+
// Returns the number of parent attributes that are needed for the prediction.
|
|
40
|
+
virtual int GetNumParentAttributes() const = 0;
|
|
41
|
+
|
|
42
|
+
// Returns the type of each of the parent attribute.
|
|
43
|
+
virtual GeometryAttribute::Type GetParentAttributeType(int i) const = 0;
|
|
44
|
+
|
|
45
|
+
// Sets the required parent attribute.
|
|
46
|
+
// Returns false if the attribute doesn't meet the requirements of the
|
|
47
|
+
// prediction scheme.
|
|
48
|
+
virtual bool SetParentAttribute(const PointAttribute *att) = 0;
|
|
49
|
+
|
|
50
|
+
// Method should return true if the prediction scheme guarantees that all
|
|
51
|
+
// correction values are always positive (or at least non-negative).
|
|
52
|
+
virtual bool AreCorrectionsPositive() = 0;
|
|
53
|
+
|
|
54
|
+
// Returns the transform type used by the prediction scheme.
|
|
55
|
+
virtual PredictionSchemeTransformType GetTransformType() const = 0;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace draco
|
|
59
|
+
|
|
60
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_INTERFACE_H_
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_DECODING_TRANSFORM_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_DECODING_TRANSFORM_H_
|
|
17
|
+
|
|
18
|
+
#include <cmath>
|
|
19
|
+
|
|
20
|
+
#include "draco/compression/attributes/normal_compression_utils.h"
|
|
21
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h"
|
|
22
|
+
#include "draco/core/decoder_buffer.h"
|
|
23
|
+
#include "draco/core/macros.h"
|
|
24
|
+
#include "draco/core/math_utils.h"
|
|
25
|
+
#include "draco/core/vector_d.h"
|
|
26
|
+
|
|
27
|
+
namespace draco {
|
|
28
|
+
|
|
29
|
+
// Class for converting correction values transformed by the canonicalized
|
|
30
|
+
// normal octahedron transform back to the original values. See the
|
|
31
|
+
// corresponding encoder for more details.
|
|
32
|
+
template <typename DataTypeT>
|
|
33
|
+
class PredictionSchemeNormalOctahedronCanonicalizedDecodingTransform
|
|
34
|
+
: public PredictionSchemeNormalOctahedronCanonicalizedTransformBase<
|
|
35
|
+
DataTypeT> {
|
|
36
|
+
public:
|
|
37
|
+
typedef VectorD<DataTypeT, 2> Point2;
|
|
38
|
+
typedef DataTypeT CorrType;
|
|
39
|
+
typedef DataTypeT DataType;
|
|
40
|
+
|
|
41
|
+
PredictionSchemeNormalOctahedronCanonicalizedDecodingTransform() {}
|
|
42
|
+
|
|
43
|
+
// Dummy to fulfill concept.
|
|
44
|
+
void Init(int num_components) {}
|
|
45
|
+
|
|
46
|
+
bool DecodeTransformData(DecoderBuffer *buffer) {
|
|
47
|
+
DataTypeT max_quantized_value, center_value;
|
|
48
|
+
if (!buffer->Decode(&max_quantized_value)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (!buffer->Decode(¢er_value)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
(void)center_value;
|
|
55
|
+
if (!this->set_max_quantized_value(max_quantized_value)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
// Account for reading wrong values, e.g., due to fuzzing.
|
|
59
|
+
if (this->quantization_bits() < 2) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (this->quantization_bits() > 30) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
inline void ComputeOriginalValue(const DataType *pred_vals,
|
|
69
|
+
const CorrType *corr_vals,
|
|
70
|
+
DataType *out_orig_vals) const {
|
|
71
|
+
DRACO_DCHECK_LE(pred_vals[0], 2 * this->center_value());
|
|
72
|
+
DRACO_DCHECK_LE(pred_vals[1], 2 * this->center_value());
|
|
73
|
+
DRACO_DCHECK_LE(corr_vals[0], 2 * this->center_value());
|
|
74
|
+
DRACO_DCHECK_LE(corr_vals[1], 2 * this->center_value());
|
|
75
|
+
|
|
76
|
+
DRACO_DCHECK_LE(0, pred_vals[0]);
|
|
77
|
+
DRACO_DCHECK_LE(0, pred_vals[1]);
|
|
78
|
+
DRACO_DCHECK_LE(0, corr_vals[0]);
|
|
79
|
+
DRACO_DCHECK_LE(0, corr_vals[1]);
|
|
80
|
+
|
|
81
|
+
const Point2 pred = Point2(pred_vals[0], pred_vals[1]);
|
|
82
|
+
const Point2 corr = Point2(corr_vals[0], corr_vals[1]);
|
|
83
|
+
const Point2 orig = ComputeOriginalValue(pred, corr);
|
|
84
|
+
|
|
85
|
+
out_orig_vals[0] = orig[0];
|
|
86
|
+
out_orig_vals[1] = orig[1];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private:
|
|
90
|
+
Point2 ComputeOriginalValue(Point2 pred, Point2 corr) const {
|
|
91
|
+
const Point2 t(this->center_value(), this->center_value());
|
|
92
|
+
pred = pred - t;
|
|
93
|
+
const bool pred_is_in_diamond = this->IsInDiamond(pred[0], pred[1]);
|
|
94
|
+
if (!pred_is_in_diamond) {
|
|
95
|
+
this->InvertDiamond(&pred[0], &pred[1]);
|
|
96
|
+
}
|
|
97
|
+
const bool pred_is_in_bottom_left = this->IsInBottomLeft(pred);
|
|
98
|
+
const int32_t rotation_count = this->GetRotationCount(pred);
|
|
99
|
+
if (!pred_is_in_bottom_left) {
|
|
100
|
+
pred = this->RotatePoint(pred, rotation_count);
|
|
101
|
+
}
|
|
102
|
+
Point2 orig(this->ModMax(AddAsUnsigned(pred[0], corr[0])),
|
|
103
|
+
this->ModMax(AddAsUnsigned(pred[1], corr[1])));
|
|
104
|
+
if (!pred_is_in_bottom_left) {
|
|
105
|
+
const int32_t reverse_rotation_count = (4 - rotation_count) % 4;
|
|
106
|
+
orig = this->RotatePoint(orig, reverse_rotation_count);
|
|
107
|
+
}
|
|
108
|
+
if (!pred_is_in_diamond) {
|
|
109
|
+
this->InvertDiamond(&orig[0], &orig[1]);
|
|
110
|
+
}
|
|
111
|
+
orig = orig + t;
|
|
112
|
+
return orig;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
} // namespace draco
|
|
117
|
+
|
|
118
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_DECODING_TRANSFORM_H_
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_ENCODING_TRANSFORM_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_ENCODING_TRANSFORM_H_
|
|
17
|
+
|
|
18
|
+
#include <cmath>
|
|
19
|
+
|
|
20
|
+
#include "draco/compression/attributes/normal_compression_utils.h"
|
|
21
|
+
#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h"
|
|
22
|
+
#include "draco/core/encoder_buffer.h"
|
|
23
|
+
#include "draco/core/macros.h"
|
|
24
|
+
#include "draco/core/vector_d.h"
|
|
25
|
+
|
|
26
|
+
namespace draco {
|
|
27
|
+
|
|
28
|
+
// The transform works on octahedral coordinates for normals. The square is
|
|
29
|
+
// subdivided into four inner triangles (diamond) and four outer triangles. The
|
|
30
|
+
// inner triangles are associated with the upper part of the octahedron and the
|
|
31
|
+
// outer triangles are associated with the lower part.
|
|
32
|
+
// Given a prediction value P and the actual value Q that should be encoded,
|
|
33
|
+
// this transform first checks if P is outside the diamond. If so, the outer
|
|
34
|
+
// triangles are flipped towards the inside and vice versa. Then it checks if p
|
|
35
|
+
// is in the bottom left quadrant. If it is not, it rotates p and q accordingly.
|
|
36
|
+
// The actual correction value is then based on the mapped and rotated P and Q
|
|
37
|
+
// values. The inversion tends to result in shorter correction vectors and the
|
|
38
|
+
// rotation makes it so that all long correction values are positive, reducing
|
|
39
|
+
// the possible value range of the correction values and increasing the
|
|
40
|
+
// occurrences of positive large correction values, which helps the entropy
|
|
41
|
+
// encoder. This is possible since P is also known by the decoder, see also
|
|
42
|
+
// ComputeCorrection and ComputeOriginalValue functions.
|
|
43
|
+
// Note that the tile is not periodic, which implies that the outer edges can
|
|
44
|
+
// not be identified, which requires us to use an odd number of values on each
|
|
45
|
+
// axis.
|
|
46
|
+
// DataTypeT is expected to be some integral type.
|
|
47
|
+
//
|
|
48
|
+
template <typename DataTypeT>
|
|
49
|
+
class PredictionSchemeNormalOctahedronCanonicalizedEncodingTransform
|
|
50
|
+
: public PredictionSchemeNormalOctahedronCanonicalizedTransformBase<
|
|
51
|
+
DataTypeT> {
|
|
52
|
+
public:
|
|
53
|
+
typedef PredictionSchemeNormalOctahedronCanonicalizedTransformBase<DataTypeT>
|
|
54
|
+
Base;
|
|
55
|
+
typedef VectorD<DataTypeT, 2> Point2;
|
|
56
|
+
typedef DataTypeT CorrType;
|
|
57
|
+
typedef DataTypeT DataType;
|
|
58
|
+
|
|
59
|
+
// We expect the mod value to be of the form 2^b-1.
|
|
60
|
+
explicit PredictionSchemeNormalOctahedronCanonicalizedEncodingTransform(
|
|
61
|
+
DataType max_quantized_value)
|
|
62
|
+
: Base(max_quantized_value) {}
|
|
63
|
+
|
|
64
|
+
// Dummy function to fulfill concept.
|
|
65
|
+
void Init(const DataTypeT *orig_data, int size, int num_components) {}
|
|
66
|
+
|
|
67
|
+
bool EncodeTransformData(EncoderBuffer *buffer) {
|
|
68
|
+
buffer->Encode(this->max_quantized_value());
|
|
69
|
+
buffer->Encode(this->center_value());
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
inline void ComputeCorrection(const DataType *orig_vals,
|
|
74
|
+
const DataType *pred_vals,
|
|
75
|
+
CorrType *out_corr_vals) const {
|
|
76
|
+
DRACO_DCHECK_LE(pred_vals[0], this->center_value() * 2);
|
|
77
|
+
DRACO_DCHECK_LE(pred_vals[1], this->center_value() * 2);
|
|
78
|
+
DRACO_DCHECK_LE(orig_vals[0], this->center_value() * 2);
|
|
79
|
+
DRACO_DCHECK_LE(orig_vals[1], this->center_value() * 2);
|
|
80
|
+
DRACO_DCHECK_LE(0, pred_vals[0]);
|
|
81
|
+
DRACO_DCHECK_LE(0, pred_vals[1]);
|
|
82
|
+
DRACO_DCHECK_LE(0, orig_vals[0]);
|
|
83
|
+
DRACO_DCHECK_LE(0, orig_vals[1]);
|
|
84
|
+
|
|
85
|
+
const Point2 orig = Point2(orig_vals[0], orig_vals[1]);
|
|
86
|
+
const Point2 pred = Point2(pred_vals[0], pred_vals[1]);
|
|
87
|
+
const Point2 corr = ComputeCorrection(orig, pred);
|
|
88
|
+
|
|
89
|
+
out_corr_vals[0] = corr[0];
|
|
90
|
+
out_corr_vals[1] = corr[1];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private:
|
|
94
|
+
Point2 ComputeCorrection(Point2 orig, Point2 pred) const {
|
|
95
|
+
const Point2 t(this->center_value(), this->center_value());
|
|
96
|
+
orig = orig - t;
|
|
97
|
+
pred = pred - t;
|
|
98
|
+
if (!this->IsInDiamond(pred[0], pred[1])) {
|
|
99
|
+
this->InvertDiamond(&orig[0], &orig[1]);
|
|
100
|
+
this->InvertDiamond(&pred[0], &pred[1]);
|
|
101
|
+
}
|
|
102
|
+
if (!this->IsInBottomLeft(pred)) {
|
|
103
|
+
const int32_t rotation_count = this->GetRotationCount(pred);
|
|
104
|
+
orig = this->RotatePoint(orig, rotation_count);
|
|
105
|
+
pred = this->RotatePoint(pred, rotation_count);
|
|
106
|
+
}
|
|
107
|
+
Point2 corr = orig - pred;
|
|
108
|
+
corr[0] = this->MakePositive(corr[0]);
|
|
109
|
+
corr[1] = this->MakePositive(corr[1]);
|
|
110
|
+
return corr;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
} // namespace draco
|
|
115
|
+
|
|
116
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_ENCODING_TRANSFORM_H_
|