Differential D9642 Diff 31697 extern/draco/draco/src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h.
| Show All 9 Lines | |||||
| // distributed under the License is distributed on an "AS IS" BASIS, | // distributed under the License is distributed on an "AS IS" BASIS, | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| // See the License for the specific language governing permissions and | // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | // limitations under the License. | ||||
| // | // | ||||
| #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_ | #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_ | ||||
| #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_ | #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_ | ||||
| #include <limits> | |||||
| #include <vector> | #include <vector> | ||||
| #include "draco/compression/config/compression_shared.h" | #include "draco/compression/config/compression_shared.h" | ||||
| #include "draco/core/macros.h" | #include "draco/core/macros.h" | ||||
| namespace draco { | namespace draco { | ||||
| // PredictionSchemeWrapTransform uses the min and max bounds of the original | // PredictionSchemeWrapTransform uses the min and max bounds of the original | ||||
| Show All 30 Lines | void Init(int num_components) { | ||||
| clamped_value_.resize(num_components); | clamped_value_.resize(num_components); | ||||
| } | } | ||||
| bool AreCorrectionsPositive() const { return false; } | bool AreCorrectionsPositive() const { return false; } | ||||
| inline const DataTypeT *ClampPredictedValue( | inline const DataTypeT *ClampPredictedValue( | ||||
| const DataTypeT *predicted_val) const { | const DataTypeT *predicted_val) const { | ||||
| for (int i = 0; i < this->num_components(); ++i) { | for (int i = 0; i < this->num_components(); ++i) { | ||||
| if (predicted_val[i] > max_value_) | if (predicted_val[i] > max_value_) { | ||||
| clamped_value_[i] = max_value_; | clamped_value_[i] = max_value_; | ||||
| else if (predicted_val[i] < min_value_) | } else if (predicted_val[i] < min_value_) { | ||||
| clamped_value_[i] = min_value_; | clamped_value_[i] = min_value_; | ||||
| else | } else { | ||||
| clamped_value_[i] = predicted_val[i]; | clamped_value_[i] = predicted_val[i]; | ||||
| } | } | ||||
| } | |||||
| return &clamped_value_[0]; | return &clamped_value_[0]; | ||||
| } | } | ||||
| // TODO(hemmer): Consider refactoring to avoid this dummy. | // TODO(hemmer): Consider refactoring to avoid this dummy. | ||||
| int quantization_bits() const { | int quantization_bits() const { | ||||
| DRACO_DCHECK(false); | DRACO_DCHECK(false); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| protected: | protected: | ||||
| bool InitCorrectionBounds() { | bool InitCorrectionBounds() { | ||||
| const int64_t dif = | const int64_t dif = | ||||
| static_cast<int64_t>(max_value_) - static_cast<int64_t>(min_value_); | static_cast<int64_t>(max_value_) - static_cast<int64_t>(min_value_); | ||||
| if (dif < 0 || dif >= std::numeric_limits<DataTypeT>::max()) | if (dif < 0 || dif >= std::numeric_limits<DataTypeT>::max()) { | ||||
| return false; | return false; | ||||
| } | |||||
| max_dif_ = 1 + static_cast<DataTypeT>(dif); | max_dif_ = 1 + static_cast<DataTypeT>(dif); | ||||
| max_correction_ = max_dif_ / 2; | max_correction_ = max_dif_ / 2; | ||||
| min_correction_ = -max_correction_; | min_correction_ = -max_correction_; | ||||
| if ((max_dif_ & 1) == 0) | if ((max_dif_ & 1) == 0) { | ||||
| max_correction_ -= 1; | max_correction_ -= 1; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| inline int num_components() const { return num_components_; } | inline int num_components() const { return num_components_; } | ||||
| inline DataTypeT min_value() const { return min_value_; } | inline DataTypeT min_value() const { return min_value_; } | ||||
| inline void set_min_value(const DataTypeT &v) { min_value_ = v; } | inline void set_min_value(const DataTypeT &v) { min_value_ = v; } | ||||
| inline DataTypeT max_value() const { return max_value_; } | inline DataTypeT max_value() const { return max_value_; } | ||||
| inline void set_max_value(const DataTypeT &v) { max_value_ = v; } | inline void set_max_value(const DataTypeT &v) { max_value_ = v; } | ||||
| Show All 18 Lines | |||||