GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
mesh_prediction_scheme_parallelogram_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_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_DECODER_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_DECODER_H_
17
20
21namespace draco {
22
23// Decoder for attribute values encoded with the standard parallelogram
24// prediction. See the description of the corresponding encoder for more
25// details.
26template <typename DataTypeT, class TransformT, class MeshDataT>
28 : public MeshPredictionSchemeDecoder<DataTypeT, TransformT, MeshDataT> {
29 public:
30 using CorrType =
32 using CornerTable = typename MeshDataT::CornerTable;
35 : MeshPredictionSchemeDecoder<DataTypeT, TransformT, MeshDataT>(
36 attribute) {}
38 const TransformT &transform,
39 const MeshDataT &mesh_data)
40 : MeshPredictionSchemeDecoder<DataTypeT, TransformT, MeshDataT>(
42
43 bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data,
44 int size, int num_components,
45 const PointIndex *entry_to_point_id_map) override;
49
50 bool IsInitialized() const override {
51 return this->mesh_data().IsInitialized();
52 }
53};
54
55template <typename DataTypeT, class TransformT, class MeshDataT>
56bool MeshPredictionSchemeParallelogramDecoder<DataTypeT, TransformT,
57 MeshDataT>::
58 ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data,
59 int /* size */, int num_components,
60 const PointIndex * /* entry_to_point_id_map */) {
61 this->transform().Init(num_components);
62
63 const CornerTable *const table = this->mesh_data().corner_table();
64 const std::vector<int32_t> *const vertex_to_data_map =
65 this->mesh_data().vertex_to_data_map();
66
67 // For storage of prediction values (already initialized to zero).
68 std::unique_ptr<DataTypeT[]> pred_vals(new DataTypeT[num_components]());
69
70 // Restore the first value.
71 this->transform().ComputeOriginalValue(pred_vals.get(), in_corr, out_data);
72
73 const int corner_map_size =
74 static_cast<int>(this->mesh_data().data_to_corner_map()->size());
75 for (int p = 1; p < corner_map_size; ++p) {
76 const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p);
77 const int dst_offset = p * num_components;
78 if (!ComputeParallelogramPrediction(p, corner_id, table,
79 *vertex_to_data_map, out_data,
80 num_components, pred_vals.get())) {
81 // Parallelogram could not be computed, Possible because some of the
82 // vertices are not valid (not encoded yet).
83 // We use the last encoded point as a reference (delta coding).
84 const int src_offset = (p - 1) * num_components;
85 this->transform().ComputeOriginalValue(
86 out_data + src_offset, in_corr + dst_offset, out_data + dst_offset);
87 } else {
88 // Apply the parallelogram prediction.
89 this->transform().ComputeOriginalValue(
90 pred_vals.get(), in_corr + dst_offset, out_data + dst_offset);
91 }
92 }
93 return true;
94}
95
96} // namespace draco
97
98#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_DECODER_H_
const MeshData & mesh_data() const
Definition mesh_prediction_scheme_decoder.h:38
MeshPredictionSchemeDecoder(const PointAttribute *attribute, const TransformT &transform, const MeshDataT &mesh_data)
Definition mesh_prediction_scheme_decoder.h:31
bool IsInitialized() const override
Definition mesh_prediction_scheme_parallelogram_decoder.h:50
typename PredictionSchemeDecoder< DataTypeT, TransformT >::CorrType CorrType
Definition mesh_prediction_scheme_parallelogram_decoder.h:30
bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, int size, int num_components, const PointIndex *entry_to_point_id_map) override
Definition mesh_prediction_scheme_parallelogram_decoder.h:58
PredictionSchemeMethod GetPredictionMethod() const override
Definition mesh_prediction_scheme_parallelogram_decoder.h:46
MeshPredictionSchemeParallelogramDecoder(const PointAttribute *attribute, const TransformT &transform, const MeshDataT &mesh_data)
Definition mesh_prediction_scheme_parallelogram_decoder.h:37
typename MeshDataT::CornerTable CornerTable
Definition mesh_prediction_scheme_parallelogram_decoder.h:32
MeshPredictionSchemeParallelogramDecoder(const PointAttribute *attribute)
Definition mesh_prediction_scheme_parallelogram_decoder.h:33
Definition point_attribute.h:33
Transform::CorrType CorrType
Definition prediction_scheme_decoder.h:41
const Transform & transform() const
Definition prediction_scheme_decoder.h:80
const PointAttribute * attribute() const
Definition prediction_scheme_decoder.h:79
n< br > font size
Definition meshpage.php:3536
Definition attribute_octahedron_transform.cc:21
bool ComputeParallelogramPrediction(int data_entry_id, const CornerIndex ci, const CornerTableT *table, const std::vector< int32_t > &vertex_to_data_map, const DataTypeT *in_data, int num_components, DataTypeT *out_prediction)
Definition mesh_prediction_scheme_parallelogram_shared.h:45
CornerIndex CornerIndex
Definition mesh_edgebreaker_encoder_impl.cc:35
PredictionSchemeMethod
Definition compression_shared.h:80
@ MESH_PREDICTION_PARALLELOGRAM
Definition compression_shared.h:86
Definition GameApi_pl.cc:29382