Differential D9642 Diff 31697 extern/draco/draco/src/draco/compression/attributes/sequential_normal_attribute_decoder.cc
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/sequential_normal_attribute_decoder.cc
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/sequential_normal_attribute_decoder.cc.
| // Copyright 2016 The Draco Authors. | // Copyright 2016 The Draco Authors. | ||||
| // | // | ||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | // Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| // you may not use this file except in compliance with the License. | // you may not use this file except in compliance with the License. | ||||
| // You may obtain a copy of the License at | // You may obtain a copy of the License at | ||||
| // | // | ||||
| // http://www.apache.org/licenses/LICENSE-2.0 | // http://www.apache.org/licenses/LICENSE-2.0 | ||||
| // | // | ||||
| // Unless required by applicable law or agreed to in writing, software | // Unless required by applicable law or agreed to in writing, software | ||||
| // 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. | ||||
| // | // | ||||
| #include "draco/compression/attributes/sequential_normal_attribute_decoder.h" | #include "draco/compression/attributes/sequential_normal_attribute_decoder.h" | ||||
| #include "draco/attributes/attribute_octahedron_transform.h" | #include "draco/attributes/attribute_octahedron_transform.h" | ||||
| #include "draco/compression/attributes/normal_compression_utils.h" | #include "draco/compression/attributes/normal_compression_utils.h" | ||||
| namespace draco { | namespace draco { | ||||
| SequentialNormalAttributeDecoder::SequentialNormalAttributeDecoder() | SequentialNormalAttributeDecoder::SequentialNormalAttributeDecoder() | ||||
| : quantization_bits_(-1) {} | : quantization_bits_(-1) {} | ||||
| bool SequentialNormalAttributeDecoder::Init(PointCloudDecoder *decoder, | bool SequentialNormalAttributeDecoder::Init(PointCloudDecoder *decoder, | ||||
| int attribute_id) { | int attribute_id) { | ||||
| if (!SequentialIntegerAttributeDecoder::Init(decoder, attribute_id)) | if (!SequentialIntegerAttributeDecoder::Init(decoder, attribute_id)) | ||||
| return false; | return false; | ||||
| // Currently, this encoder works only for 3-component normal vectors. | // Currently, this encoder works only for 3-component normal vectors. | ||||
| if (attribute()->num_components() != 3) | if (attribute()->num_components() != 3) { | ||||
| return false; | return false; | ||||
| } | |||||
| // Also the data type must be DT_FLOAT32. | // Also the data type must be DT_FLOAT32. | ||||
| if (attribute()->data_type() != DT_FLOAT32) | if (attribute()->data_type() != DT_FLOAT32) { | ||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool SequentialNormalAttributeDecoder::DecodeIntegerValues( | bool SequentialNormalAttributeDecoder::DecodeIntegerValues( | ||||
| const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | ||||
| #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | ||||
| if (decoder()->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 0)) { | if (decoder()->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 0)) { | ||||
| uint8_t quantization_bits; | uint8_t quantization_bits; | ||||
| if (!in_buffer->Decode(&quantization_bits)) | if (!in_buffer->Decode(&quantization_bits)) { | ||||
| return false; | return false; | ||||
| } | |||||
| quantization_bits_ = quantization_bits; | quantization_bits_ = quantization_bits; | ||||
| } | } | ||||
| #endif | #endif | ||||
| return SequentialIntegerAttributeDecoder::DecodeIntegerValues(point_ids, | return SequentialIntegerAttributeDecoder::DecodeIntegerValues(point_ids, | ||||
| in_buffer); | in_buffer); | ||||
| } | } | ||||
| bool SequentialNormalAttributeDecoder::DecodeDataNeededByPortableTransform( | bool SequentialNormalAttributeDecoder::DecodeDataNeededByPortableTransform( | ||||
| const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | ||||
| if (decoder()->bitstream_version() >= DRACO_BITSTREAM_VERSION(2, 0)) { | if (decoder()->bitstream_version() >= DRACO_BITSTREAM_VERSION(2, 0)) { | ||||
| // For newer file version, decode attribute transform data here. | // For newer file version, decode attribute transform data here. | ||||
| uint8_t quantization_bits; | uint8_t quantization_bits; | ||||
| if (!in_buffer->Decode(&quantization_bits)) | if (!in_buffer->Decode(&quantization_bits)) { | ||||
| return false; | return false; | ||||
| } | |||||
| quantization_bits_ = quantization_bits; | quantization_bits_ = quantization_bits; | ||||
| } | } | ||||
| // Store the decoded transform data in portable attribute. | // Store the decoded transform data in portable attribute. | ||||
| AttributeOctahedronTransform octahedral_transform; | AttributeOctahedronTransform octahedral_transform; | ||||
| octahedral_transform.SetParameters(quantization_bits_); | octahedral_transform.SetParameters(quantization_bits_); | ||||
| return octahedral_transform.TransferToAttribute(portable_attribute()); | return octahedral_transform.TransferToAttribute(portable_attribute()); | ||||
| } | } | ||||
| Show All 24 Lines | |||||