GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
encode.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#ifndef DRACO_COMPRESSION_ENCODE_H_
16#define DRACO_COMPRESSION_ENCODE_H_
17
22#include "draco/core/status.h"
23#include "draco/mesh/mesh.h"
24
25namespace draco {
26
27// Basic helper class for encoding geometry using the Draco compression library.
28// The class provides various methods that can be used to control several common
29// options used during the encoding, such as the number of quantization bits for
30// a given attribute. All these options are defined per attribute type, i.e.,
31// if there are more attributes of the same type (such as multiple texture
32// coordinate attributes), the same options are going to be used for all of the
33// attributes of this type. If different attributes of the same type need to
34// use different options, use ExpertEncoder in expert_encode.h.
36 : public EncoderBase<EncoderOptionsBase<GeometryAttribute::Type>> {
37 public:
39
40 Encoder();
41 virtual ~Encoder() {}
42
43 // Encodes a point cloud to the provided buffer.
45 EncoderBuffer *out_buffer);
46
47 // Encodes a mesh to the provided buffer.
48 virtual Status EncodeMeshToBuffer(const Mesh &m, EncoderBuffer *out_buffer);
49
50 // Set encoder options used during the geometry encoding. Note that this call
51 // overwrites any modifications to the options done with the functions below,
52 // i.e., it resets the encoder.
54 void Reset();
55
56 // Sets the desired encoding and decoding speed for the given options.
57 //
58 // 0 = slowest speed, but the best compression.
59 // 10 = fastest, but the worst compression.
60 // -1 = undefined.
61 //
62 // Note that both speed options affect the encoder choice of used methods and
63 // algorithms. For example, a requirement for fast decoding may prevent the
64 // encoder from using the best compression methods even if the encoding speed
65 // is set to 0. In general, the faster of the two options limits the choice of
66 // features that can be used by the encoder. Additionally, setting
67 // |decoding_speed| to be faster than the |encoding_speed| may allow the
68 // encoder to choose the optimal method out of the available features for the
69 // given |decoding_speed|.
70 void SetSpeedOptions(int encoding_speed, int decoding_speed);
71
72 // Sets the quantization compression options for a named attribute. The
73 // attribute values will be quantized in a box defined by the maximum extent
74 // of the attribute values. I.e., the actual precision of this option depends
75 // on the scale of the attribute values.
77 int quantization_bits);
78
79 // Sets the explicit quantization compression for a named attribute. The
80 // attribute values will be quantized in a coordinate system defined by the
81 // provided origin and range (the input values should be within interval:
82 // <origin, origin + range>).
84 int quantization_bits, int num_dims,
85 const float *origin, float range);
86
87 // Sets the desired prediction method for a given attribute. By default,
88 // prediction scheme is selected automatically by the encoder using other
89 // provided options (such as speed) and input geometry type (mesh, point
90 // cloud). This function should be called only when a specific prediction is
91 // preferred (e.g., when it is known that the encoder would select a less
92 // optimal prediction for the given input data).
93 //
94 // |prediction_scheme_method| should be one of the entries defined in
95 // compression/config/compression_shared.h :
96 //
97 // PREDICTION_NONE - use no prediction.
98 // PREDICTION_DIFFERENCE - delta coding
99 // MESH_PREDICTION_PARALLELOGRAM - parallelogram prediction for meshes.
100 // MESH_PREDICTION_CONSTRAINED_PARALLELOGRAM
101 // - better and more costly version of the parallelogram prediction.
102 // MESH_PREDICTION_TEX_COORDS_PORTABLE
103 // - specialized predictor for tex coordinates.
104 // MESH_PREDICTION_GEOMETRIC_NORMAL
105 // - specialized predictor for normal coordinates.
106 //
107 // Note that in case the desired prediction cannot be used, the default
108 // prediction will be automatically used instead.
110 int prediction_scheme_method);
111
112 // Sets the desired encoding method for a given geometry. By default, encoding
113 // method is selected based on the properties of the input geometry and based
114 // on the other options selected in the used EncoderOptions (such as desired
115 // encoding and decoding speed). This function should be called only when a
116 // specific method is required.
117 //
118 // |encoding_method| can be one of the values defined in
119 // compression/config/compression_shared.h based on the type of the input
120 // geometry that is going to be encoded. For point clouds, allowed entries are
121 // POINT_CLOUD_SEQUENTIAL_ENCODING
122 // POINT_CLOUD_KD_TREE_ENCODING
123 //
124 // For meshes the input can be
125 // MESH_SEQUENTIAL_ENCODING
126 // MESH_EDGEBREAKER_ENCODING
127 //
128 // If the selected method cannot be used for the given input, the subsequent
129 // call of EncodePointCloudToBuffer or EncodeMeshToBuffer is going to fail.
130 void SetEncodingMethod(int encoding_method);
131
132 // Creates encoder options for the expert encoder used during the actual
133 // encoding.
135};
136
137} // namespace draco
138
139#endif // DRACO_COMPRESSION_ENCODE_H_
Definition encoder_buffer.h:29
Definition encoder_options.h:29
Status SetAttributePredictionScheme(GeometryAttribute::Type type, int prediction_scheme_method)
Definition encode.cc:85
Encoder()
Definition encode.cc:21
EncoderOptions CreateExpertEncoderOptions(const PointCloud &pc) const
Definition encode.cc:39
void SetEncodingMethod(int encoding_method)
Definition encode.cc:81
virtual Status EncodeMeshToBuffer(const Mesh &m, EncoderBuffer *out_buffer)
Definition encode.cc:30
void SetAttributeQuantization(GeometryAttribute::Type type, int quantization_bits)
Definition encode.cc:66
void Reset()
Definition encode.cc:60
virtual ~Encoder()
Definition encode.h:41
EncoderBase< EncoderOptionsBase< GeometryAttribute::Type > > Base
Definition encode.h:38
virtual Status EncodePointCloudToBuffer(const PointCloud &pc, EncoderBuffer *out_buffer)
Definition encode.cc:23
void SetAttributeExplicitQuantization(GeometryAttribute::Type type, int quantization_bits, int num_dims, const float *origin, float range)
Definition encode.cc:71
void SetSpeedOptions(int encoding_speed, int decoding_speed)
Definition encode.cc:62
Type
Definition geometry_attribute.h:46
Definition mesh.h:52
Definition point_cloud.h:29
Definition status.h:25
< 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
EncoderOptionsBase< int32_t > EncoderOptions
Definition encoder_options.h:97