Differential D9642 Diff 31697 extern/draco/draco/src/draco/compression/attributes/sequential_attribute_decoders_controller.cc
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/sequential_attribute_decoders_controller.cc
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/sequential_attribute_decoders_controller.cc.
| Show All 21 Lines | |||||
| namespace draco { | namespace draco { | ||||
| SequentialAttributeDecodersController::SequentialAttributeDecodersController( | SequentialAttributeDecodersController::SequentialAttributeDecodersController( | ||||
| std::unique_ptr<PointsSequencer> sequencer) | std::unique_ptr<PointsSequencer> sequencer) | ||||
| : sequencer_(std::move(sequencer)) {} | : sequencer_(std::move(sequencer)) {} | ||||
| bool SequentialAttributeDecodersController::DecodeAttributesDecoderData( | bool SequentialAttributeDecodersController::DecodeAttributesDecoderData( | ||||
| DecoderBuffer *buffer) { | DecoderBuffer *buffer) { | ||||
| if (!AttributesDecoder::DecodeAttributesDecoderData(buffer)) | if (!AttributesDecoder::DecodeAttributesDecoderData(buffer)) { | ||||
| return false; | return false; | ||||
| } | |||||
| // Decode unique ids of all sequential encoders and create them. | // Decode unique ids of all sequential encoders and create them. | ||||
| const int32_t num_attributes = GetNumAttributes(); | const int32_t num_attributes = GetNumAttributes(); | ||||
| sequential_decoders_.resize(num_attributes); | sequential_decoders_.resize(num_attributes); | ||||
| for (int i = 0; i < num_attributes; ++i) { | for (int i = 0; i < num_attributes; ++i) { | ||||
| uint8_t decoder_type; | uint8_t decoder_type; | ||||
| if (!buffer->Decode(&decoder_type)) | if (!buffer->Decode(&decoder_type)) { | ||||
| return false; | return false; | ||||
| } | |||||
| // Create the decoder from the id. | // Create the decoder from the id. | ||||
| sequential_decoders_[i] = CreateSequentialDecoder(decoder_type); | sequential_decoders_[i] = CreateSequentialDecoder(decoder_type); | ||||
| if (!sequential_decoders_[i]) | if (!sequential_decoders_[i]) { | ||||
| return false; | return false; | ||||
| if (!sequential_decoders_[i]->Init(GetDecoder(), GetAttributeId(i))) | } | ||||
| if (!sequential_decoders_[i]->Init(GetDecoder(), GetAttributeId(i))) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool SequentialAttributeDecodersController::DecodeAttributes( | bool SequentialAttributeDecodersController::DecodeAttributes( | ||||
| DecoderBuffer *buffer) { | DecoderBuffer *buffer) { | ||||
| if (!sequencer_ || !sequencer_->GenerateSequence(&point_ids_)) | if (!sequencer_ || !sequencer_->GenerateSequence(&point_ids_)) { | ||||
| return false; | return false; | ||||
| } | |||||
| // Initialize point to attribute value mapping for all decoded attributes. | // Initialize point to attribute value mapping for all decoded attributes. | ||||
| const int32_t num_attributes = GetNumAttributes(); | const int32_t num_attributes = GetNumAttributes(); | ||||
| for (int i = 0; i < num_attributes; ++i) { | for (int i = 0; i < num_attributes; ++i) { | ||||
| PointAttribute *const pa = | PointAttribute *const pa = | ||||
| GetDecoder()->point_cloud()->attribute(GetAttributeId(i)); | GetDecoder()->point_cloud()->attribute(GetAttributeId(i)); | ||||
| if (!sequencer_->UpdatePointToAttributeIndexMapping(pa)) | if (!sequencer_->UpdatePointToAttributeIndexMapping(pa)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| return AttributesDecoder::DecodeAttributes(buffer); | return AttributesDecoder::DecodeAttributes(buffer); | ||||
| } | } | ||||
| bool SequentialAttributeDecodersController::DecodePortableAttributes( | bool SequentialAttributeDecodersController::DecodePortableAttributes( | ||||
| DecoderBuffer *in_buffer) { | DecoderBuffer *in_buffer) { | ||||
| const int32_t num_attributes = GetNumAttributes(); | const int32_t num_attributes = GetNumAttributes(); | ||||
| for (int i = 0; i < num_attributes; ++i) { | for (int i = 0; i < num_attributes; ++i) { | ||||
| if (!sequential_decoders_[i]->DecodePortableAttribute(point_ids_, | if (!sequential_decoders_[i]->DecodePortableAttribute(point_ids_, | ||||
| in_buffer)) | in_buffer)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool SequentialAttributeDecodersController:: | bool SequentialAttributeDecodersController:: | ||||
| DecodeDataNeededByPortableTransforms(DecoderBuffer *in_buffer) { | DecodeDataNeededByPortableTransforms(DecoderBuffer *in_buffer) { | ||||
| const int32_t num_attributes = GetNumAttributes(); | const int32_t num_attributes = GetNumAttributes(); | ||||
| for (int i = 0; i < num_attributes; ++i) { | for (int i = 0; i < num_attributes; ++i) { | ||||
| if (!sequential_decoders_[i]->DecodeDataNeededByPortableTransform( | if (!sequential_decoders_[i]->DecodeDataNeededByPortableTransform( | ||||
| point_ids_, in_buffer)) | point_ids_, in_buffer)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool SequentialAttributeDecodersController:: | bool SequentialAttributeDecodersController:: | ||||
| TransformAttributesToOriginalFormat() { | TransformAttributesToOriginalFormat() { | ||||
| const int32_t num_attributes = GetNumAttributes(); | const int32_t num_attributes = GetNumAttributes(); | ||||
| for (int i = 0; i < num_attributes; ++i) { | for (int i = 0; i < num_attributes; ++i) { | ||||
| // Check whether the attribute transform should be skipped. | // Check whether the attribute transform should be skipped. | ||||
| Show All 10 Lines | if (GetDecoder()->options()) { | ||||
| // TODO(ostava): We can potentially avoid this copy by introducing a new | // TODO(ostava): We can potentially avoid this copy by introducing a new | ||||
| // mechanism that would allow to use the final attributes as portable | // mechanism that would allow to use the final attributes as portable | ||||
| // attributes for predictors that may need them. | // attributes for predictors that may need them. | ||||
| sequential_decoders_[i]->attribute()->CopyFrom(*portable_attribute); | sequential_decoders_[i]->attribute()->CopyFrom(*portable_attribute); | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| if (!sequential_decoders_[i]->TransformAttributeToOriginalFormat( | if (!sequential_decoders_[i]->TransformAttributeToOriginalFormat( | ||||
| point_ids_)) | point_ids_)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| std::unique_ptr<SequentialAttributeDecoder> | std::unique_ptr<SequentialAttributeDecoder> | ||||
| SequentialAttributeDecodersController::CreateSequentialDecoder( | SequentialAttributeDecodersController::CreateSequentialDecoder( | ||||
| uint8_t decoder_type) { | uint8_t decoder_type) { | ||||
| switch (decoder_type) { | switch (decoder_type) { | ||||
| case SEQUENTIAL_ATTRIBUTE_ENCODER_GENERIC: | case SEQUENTIAL_ATTRIBUTE_ENCODER_GENERIC: | ||||
| Show All 21 Lines | |||||