GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
prediction_scheme_encoder_factory.h
Go to the documentation of this file.
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
22#ifdef DRACO_NORMAL_ENCODING_SUPPORTED
24#endif
33
34namespace draco {
35
36// Selects a prediction method based on the input geometry type and based on the
37// encoder options.
39 const PointCloudEncoder *encoder);
40
43 const PointCloudEncoder *encoder);
44
45// Factory class for creating mesh prediction schemes.
46template <typename DataTypeT>
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));
59 return std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>(
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>>(
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.
84template <typename DataTypeT, class TransformT>
85std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>
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;
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>>(
117}
118
119// Create a prediction scheme using a default transform constructor.
120template <typename DataTypeT, class TransformT>
121std::unique_ptr<PredictionSchemeEncoder<DataTypeT, TransformT>>
123 const PointCloudEncoder *encoder) {
125 method, att_id, encoder, TransformT());
126}
127
128// Returns the preferred prediction scheme based on the encoder options.
130 int att_id, const EncoderOptions &options);
131
132} // namespace draco
133
134#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_FACTORY_H_
Definition mesh_encoder.h:27
Definition mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h:43
Definition mesh_prediction_scheme_geometric_normal_encoder.h:31
Definition mesh_prediction_scheme_parallelogram_encoder.h:39
Definition mesh_prediction_scheme_tex_coords_portable_encoder.h:32
Definition point_attribute.h:33
Definition point_cloud_encoder.h:29
virtual EncodedGeometryType GetGeometryType() const
Definition point_cloud_encoder.h:41
const PointCloud * point_cloud() const
Definition point_cloud_encoder.h:77
const PointAttribute * attribute(int32_t att_id) const
Definition point_cloud.h:68
Definition prediction_scheme_delta_encoder.h:28
Definition prediction_scheme_encoder.h:36
ret($return)
Definition mesh_login_result.php:5
< h2 > I want smooth transition from jpg png webp to the engine</h2 > There s few options
Definition meshpage.php:1181
Definition attribute_octahedron_transform.cc:21
PredictionSchemeMethod SelectPredictionMethod(int att_id, const PointCloudEncoder *encoder)
Definition prediction_scheme_encoder_factory.cc:21
PredictionSchemeMethod GetPredictionMethodFromOptions(int att_id, const EncoderOptions &options)
Definition prediction_scheme_encoder_factory.cc:109
@ TRIANGULAR_MESH
Definition compression_shared.h:44
std::unique_ptr< PredictionSchemeT > CreateMeshPredictionScheme(const EncodingDataSourceT *source, PredictionSchemeMethod method, int att_id, const typename PredictionSchemeT::Transform &transform, uint16_t bitstream_version)
Definition prediction_scheme_factory.h:34
EncoderOptionsBase< int32_t > EncoderOptions
Definition encoder_options.h:97
std::unique_ptr< PredictionSchemeEncoder< DataTypeT, TransformT > > CreatePredictionSchemeForEncoder(PredictionSchemeMethod method, int att_id, const PointCloudEncoder *encoder, const TransformT &transform)
Definition prediction_scheme_encoder_factory.h:86
PredictionSchemeMethod
Definition compression_shared.h:80
@ MESH_PREDICTION_PARALLELOGRAM
Definition compression_shared.h:86
@ PREDICTION_NONE
Definition compression_shared.h:82
@ PREDICTION_UNDEFINED
Definition compression_shared.h:84
@ MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM
Definition compression_shared.h:89
@ MESH_PREDICTION_GEOMETRIC_NORMAL
Definition compression_shared.h:91
@ MESH_PREDICTION_TEX_COORDS_PORTABLE
Definition compression_shared.h:90
Definition prediction_scheme_encoder_factory.h:47
std::unique_ptr< PredictionSchemeEncoder< DataTypeT, TransformT > > operator()(PredictionSchemeMethod method, const PointAttribute *attribute, const TransformT &transform, const MeshDataT &mesh_data, uint16_t bitstream_version)
Definition prediction_scheme_encoder_factory.h:49