Coverage Report

Created: 2024-09-08 06:47

/src/draco/src/draco/compression/decode.h
Line
Count
Source (jump to first uncovered line)
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_DECODE_H_
16
#define DRACO_COMPRESSION_DECODE_H_
17
18
#include "draco/compression/config/compression_shared.h"
19
#include "draco/compression/config/decoder_options.h"
20
#include "draco/core/decoder_buffer.h"
21
#include "draco/core/status_or.h"
22
#include "draco/draco_features.h"
23
#include "draco/mesh/mesh.h"
24
25
namespace draco {
26
27
// Class responsible for decoding of meshes and point clouds that were
28
// compressed by a Draco encoder.
29
class Decoder {
30
 public:
31
  // Returns the geometry type encoded in the input |in_buffer|.
32
  // The return value is one of POINT_CLOUD, MESH or INVALID_GEOMETRY in case
33
  // the input data is invalid.
34
  // The decoded geometry type can be used to choose an appropriate decoding
35
  // function for a given geometry type (see below).
36
  static StatusOr<EncodedGeometryType> GetEncodedGeometryType(
37
      DecoderBuffer *in_buffer);
38
39
  // Decodes point cloud from the provided buffer. The buffer must be filled
40
  // with data that was encoded with either the EncodePointCloudToBuffer or
41
  // EncodeMeshToBuffer methods in encode.h. In case the input buffer contains
42
  // mesh, the returned instance can be down-casted to Mesh.
43
  StatusOr<std::unique_ptr<PointCloud>> DecodePointCloudFromBuffer(
44
      DecoderBuffer *in_buffer);
45
46
  // Decodes a triangular mesh from the provided buffer. The mesh must be filled
47
  // with data that was encoded using the EncodeMeshToBuffer method in encode.h.
48
  // The function will return nullptr in case the input is invalid or if it was
49
  // encoded with the EncodePointCloudToBuffer method.
50
  StatusOr<std::unique_ptr<Mesh>> DecodeMeshFromBuffer(
51
      DecoderBuffer *in_buffer);
52
53
  // Decodes the buffer into a provided geometry. If the geometry is
54
  // incompatible with the encoded data. For example, when |out_geometry| is
55
  // draco::Mesh while the data contains a point cloud, the function will return
56
  // an error status.
57
  Status DecodeBufferToGeometry(DecoderBuffer *in_buffer,
58
                                PointCloud *out_geometry);
59
  Status DecodeBufferToGeometry(DecoderBuffer *in_buffer, Mesh *out_geometry);
60
61
  // When set, the decoder is going to skip attribute transform for a given
62
  // attribute type. For example for quantized attributes, the decoder would
63
  // skip the dequantization step and the returned geometry would contain an
64
  // attribute with quantized values. The attribute would also contain an
65
  // instance of AttributeTransform class that is used to describe the skipped
66
  // transform, including all parameters that are needed to perform the
67
  // transform manually.
68
  void SetSkipAttributeTransform(GeometryAttribute::Type att_type);
69
70
  // Returns the options instance used by the decoder that can be used by users
71
  // to control the decoding process.
72
0
  DecoderOptions *options() { return &options_; }
73
74
 private:
75
  DecoderOptions options_;
76
};
77
78
}  // namespace draco
79
80
#endif  // DRACO_COMPRESSION_DECODE_H_