Differential D9642 Diff 31697 extern/draco/draco/src/draco/compression/attributes/sequential_attribute_decoder.cc
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/sequential_attribute_decoder.cc
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/sequential_attribute_decoder.cc.
| Show All 30 Lines | bool SequentialAttributeDecoder::InitializeStandalone( | ||||
| PointAttribute *attribute) { | PointAttribute *attribute) { | ||||
| attribute_ = attribute; | attribute_ = attribute; | ||||
| attribute_id_ = -1; | attribute_id_ = -1; | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool SequentialAttributeDecoder::DecodePortableAttribute( | bool SequentialAttributeDecoder::DecodePortableAttribute( | ||||
| const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | ||||
| if (attribute_->num_components() <= 0 || !attribute_->Reset(point_ids.size())) | if (attribute_->num_components() <= 0 || | ||||
| !attribute_->Reset(point_ids.size())) { | |||||
| return false; | return false; | ||||
| if (!DecodeValues(point_ids, in_buffer)) | } | ||||
| if (!DecodeValues(point_ids, in_buffer)) { | |||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool SequentialAttributeDecoder::DecodeDataNeededByPortableTransform( | bool SequentialAttributeDecoder::DecodeDataNeededByPortableTransform( | ||||
| const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | ||||
| // Default implementation does not apply any transform. | // Default implementation does not apply any transform. | ||||
| return true; | return true; | ||||
| } | } | ||||
| Show All 18 Lines | const PointAttribute *SequentialAttributeDecoder::GetPortableAttribute() { | ||||
| return portable_attribute_.get(); | return portable_attribute_.get(); | ||||
| } | } | ||||
| bool SequentialAttributeDecoder::InitPredictionScheme( | bool SequentialAttributeDecoder::InitPredictionScheme( | ||||
| PredictionSchemeInterface *ps) { | PredictionSchemeInterface *ps) { | ||||
| for (int i = 0; i < ps->GetNumParentAttributes(); ++i) { | for (int i = 0; i < ps->GetNumParentAttributes(); ++i) { | ||||
| const int att_id = decoder_->point_cloud()->GetNamedAttributeId( | const int att_id = decoder_->point_cloud()->GetNamedAttributeId( | ||||
| ps->GetParentAttributeType(i)); | ps->GetParentAttributeType(i)); | ||||
| if (att_id == -1) | if (att_id == -1) { | ||||
| return false; // Requested attribute does not exist. | return false; // Requested attribute does not exist. | ||||
| } | |||||
| #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)) { | ||||
| if (!ps->SetParentAttribute(decoder_->point_cloud()->attribute(att_id))) { | if (!ps->SetParentAttribute(decoder_->point_cloud()->attribute(att_id))) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } else | } else | ||||
| #endif | #endif | ||||
| { | { | ||||
| Show All 10 Lines | bool SequentialAttributeDecoder::DecodeValues( | ||||
| const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | const std::vector<PointIndex> &point_ids, DecoderBuffer *in_buffer) { | ||||
| const int32_t num_values = static_cast<uint32_t>(point_ids.size()); | const int32_t num_values = static_cast<uint32_t>(point_ids.size()); | ||||
| const int entry_size = static_cast<int>(attribute_->byte_stride()); | const int entry_size = static_cast<int>(attribute_->byte_stride()); | ||||
| std::unique_ptr<uint8_t[]> value_data_ptr(new uint8_t[entry_size]); | std::unique_ptr<uint8_t[]> value_data_ptr(new uint8_t[entry_size]); | ||||
| uint8_t *const value_data = value_data_ptr.get(); | uint8_t *const value_data = value_data_ptr.get(); | ||||
| int out_byte_pos = 0; | int out_byte_pos = 0; | ||||
| // Decode raw attribute values in their original format. | // Decode raw attribute values in their original format. | ||||
| for (int i = 0; i < num_values; ++i) { | for (int i = 0; i < num_values; ++i) { | ||||
| if (!in_buffer->Decode(value_data, entry_size)) | if (!in_buffer->Decode(value_data, entry_size)) { | ||||
| return false; | return false; | ||||
| } | |||||
| attribute_->buffer()->Write(out_byte_pos, value_data, entry_size); | attribute_->buffer()->Write(out_byte_pos, value_data, entry_size); | ||||
| out_byte_pos += entry_size; | out_byte_pos += entry_size; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||