GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
prediction_scheme_delta_encoder.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_PREDICTION_SCHEME_DELTA_ENCODER_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_ENCODER_H_
17
19
20namespace draco {
21
22// Basic prediction scheme based on computing backward differences between
23// stored attribute values (also known as delta-coding). Usually works better
24// than the reference point prediction scheme, because nearby values are often
25// encoded next to each other.
26template <typename DataTypeT, class TransformT>
28 : public PredictionSchemeEncoder<DataTypeT, TransformT> {
29 public:
30 using CorrType =
32 // Initialized the prediction scheme.
36 const TransformT &transform)
37 : PredictionSchemeEncoder<DataTypeT, TransformT>(attribute, transform) {}
38
40 const DataTypeT *in_data, CorrType *out_corr, int size,
41 int num_components, const PointIndex *entry_to_point_id_map) override;
45 bool IsInitialized() const override { return true; }
46};
47
48template <typename DataTypeT, class TransformT>
49bool PredictionSchemeDeltaEncoder<
50 DataTypeT, TransformT>::ComputeCorrectionValues(const DataTypeT *in_data,
51 CorrType *out_corr,
52 int size,
53 int num_components,
54 const PointIndex *) {
55 this->transform().Init(in_data, size, num_components);
56 // Encode data from the back using D(i) = D(i) - D(i - 1).
57 for (int i = size - num_components; i > 0; i -= num_components) {
58 this->transform().ComputeCorrection(
59 in_data + i, in_data + i - num_components, out_corr + i);
60 }
61 // Encode correction for the first element.
62 std::unique_ptr<DataTypeT[]> zero_vals(new DataTypeT[num_components]());
63 this->transform().ComputeCorrection(in_data, zero_vals.get(), out_corr);
64 return true;
65}
66
67} // namespace draco
68
69#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_ENCODER_H_
Definition point_attribute.h:33
PredictionSchemeDeltaEncoder(const PointAttribute *attribute, const TransformT &transform)
Definition prediction_scheme_delta_encoder.h:35
bool IsInitialized() const override
Definition prediction_scheme_delta_encoder.h:45
PredictionSchemeDeltaEncoder(const PointAttribute *attribute)
Definition prediction_scheme_delta_encoder.h:33
PredictionSchemeMethod GetPredictionMethod() const override
Definition prediction_scheme_delta_encoder.h:42
typename PredictionSchemeEncoder< DataTypeT, TransformT >::CorrType CorrType
Definition prediction_scheme_delta_encoder.h:30
bool ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, int size, int num_components, const PointIndex *entry_to_point_id_map) override
Definition prediction_scheme_delta_encoder.h:50
const PointAttribute * attribute() const
Definition prediction_scheme_encoder.h:79
Transform::CorrType CorrType
Definition prediction_scheme_encoder.h:41
PredictionSchemeEncoder(const PointAttribute *attribute)
Definition prediction_scheme_encoder.h:42
const Transform & transform() const
Definition prediction_scheme_encoder.h:80
n< br > font size
Definition meshpage.php:3536
Definition attribute_octahedron_transform.cc:21
PredictionSchemeMethod
Definition compression_shared.h:80
@ PREDICTION_DIFFERENCE
Definition compression_shared.h:85
Definition GameApi_pl.cc:29382