GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
point_cloud_decoder.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_POINT_CLOUD_POINT_CLOUD_DECODER_H_
16#define DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_DECODER_H_
17
21#include "draco/core/status.h"
23
24namespace draco {
25
26// Abstract base class for all point cloud and mesh decoders. It provides a
27// basic functionality that is shared between different decoders.
29 public:
31 virtual ~PointCloudDecoder() = default;
32
34
35 // Decodes a Draco header int other provided |out_header|.
36 // Returns false on error.
38
39 // The main entry point for point cloud decoding.
41 PointCloud *out_point_cloud);
42
44 int att_decoder_id, std::unique_ptr<AttributesDecoderInterface> decoder) {
45 if (att_decoder_id < 0) {
46 return false;
47 }
48 if (att_decoder_id >= static_cast<int>(attributes_decoders_.size())) {
49 attributes_decoders_.resize(att_decoder_id + 1);
50 }
51 attributes_decoders_[att_decoder_id] = std::move(decoder);
52 return true;
53 }
54
55 // Returns an attribute containing decoded data in their portable form that
56 // is guaranteed to be the same for both encoder and decoder. I.e., it returns
57 // an attribute before it was transformed back into its final form which may
58 // be slightly different (non-portable) across platforms. For example, for
59 // attributes encoded with quantization, this method returns an attribute
60 // that contains the quantized values (before the dequantization step).
61 const PointAttribute *GetPortableAttribute(int32_t point_attribute_id);
62
63 uint16_t bitstream_version() const {
64 return DRACO_BITSTREAM_VERSION(version_major_, version_minor_);
65 }
66
68 return attributes_decoders_[dec_id].get();
69 }
70 int32_t num_attributes_decoders() const {
71 return static_cast<int32_t>(attributes_decoders_.size());
72 }
73
74 // Get a mutable pointer to the decoded point cloud. This is intended to be
75 // used mostly by other decoder subsystems.
76 PointCloud *point_cloud() { return point_cloud_; }
77 const PointCloud *point_cloud() const { return point_cloud_; }
78
79 DecoderBuffer *buffer() { return buffer_; }
80 const DecoderOptions *options() const { return options_; }
81
82 protected:
83 // Can be implemented by derived classes to perform any custom initialization
84 // of the decoder. Called in the Decode() method.
85 virtual bool InitializeDecoder() { return true; }
86
87 // Creates an attribute decoder.
88 virtual bool CreateAttributesDecoder(int32_t att_decoder_id) = 0;
89 virtual bool DecodeGeometryData() { return true; }
90 virtual bool DecodePointAttributes();
91
92 virtual bool DecodeAllAttributes();
93 virtual bool OnAttributesDecoded() { return true; }
94
96
97 private:
98 // Point cloud that is being filled in by the decoder.
99 PointCloud *point_cloud_;
100
101 std::vector<std::unique_ptr<AttributesDecoderInterface>> attributes_decoders_;
102
103 // Map between attribute id and decoder id.
104 std::vector<int32_t> attribute_to_decoder_map_;
105
106 // Input buffer holding the encoded data.
107 DecoderBuffer *buffer_;
108
109 // Bit-stream version of the encoder that encoded the input data.
110 uint8_t version_major_;
111 uint8_t version_minor_;
112
113 const DecoderOptions *options_;
114};
115
116} // namespace draco
117
118#endif // DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_DECODER_H_
Definition attributes_decoder_interface.h:31
Definition decoder_buffer.h:30
Definition point_attribute.h:33
const PointCloud * point_cloud() const
Definition point_cloud_decoder.h:77
PointCloudDecoder()
Definition point_cloud_decoder.cc:23
PointCloud * point_cloud()
Definition point_cloud_decoder.h:76
const AttributesDecoderInterface * attributes_decoder(int dec_id)
Definition point_cloud_decoder.h:67
virtual bool DecodePointAttributes()
Definition point_cloud_decoder.cc:130
static Status DecodeHeader(DecoderBuffer *buffer, DracoHeader *out_header)
Definition point_cloud_decoder.cc:30
virtual bool DecodeGeometryData()
Definition point_cloud_decoder.h:89
Status Decode(const DecoderOptions &options, DecoderBuffer *in_buffer, PointCloud *out_point_cloud)
Definition point_cloud_decoder.cc:68
virtual bool OnAttributesDecoded()
Definition point_cloud_decoder.h:93
DecoderBuffer * buffer()
Definition point_cloud_decoder.h:79
virtual bool DecodeAllAttributes()
Definition point_cloud_decoder.cc:181
virtual bool InitializeDecoder()
Definition point_cloud_decoder.h:85
bool SetAttributesDecoder(int att_decoder_id, std::unique_ptr< AttributesDecoderInterface > decoder)
Definition point_cloud_decoder.h:43
int32_t num_attributes_decoders() const
Definition point_cloud_decoder.h:70
virtual EncodedGeometryType GetGeometryType() const
Definition point_cloud_decoder.h:33
virtual bool CreateAttributesDecoder(int32_t att_decoder_id)=0
virtual ~PointCloudDecoder()=default
uint16_t bitstream_version() const
Definition point_cloud_decoder.h:63
const PointAttribute * GetPortableAttribute(int32_t point_attribute_id)
Definition point_cloud_decoder.cc:190
Status DecodeMetadata()
Definition point_cloud_decoder.cc:57
const DecoderOptions * options() const
Definition point_cloud_decoder.h:80
Definition point_cloud.h:29
Definition status.h:25
#define DRACO_BITSTREAM_VERSION(MAJOR, MINOR)
Definition macros.h:114
< 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
EncodedGeometryType
Definition compression_shared.h:41
@ POINT_CLOUD
Definition compression_shared.h:43
DracoOptions< GeometryAttribute::Type > DecoderOptions
Definition decoder_options.h:30
Definition compression_shared.h:129