Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/expert_encode.cc
- This file was moved from extern/draco/dracoenc/src/draco/compression/expert_encode.cc.
| Show All 24 Lines | |||||
| ExpertEncoder::ExpertEncoder(const PointCloud &point_cloud) | ExpertEncoder::ExpertEncoder(const PointCloud &point_cloud) | ||||
| : point_cloud_(&point_cloud), mesh_(nullptr) {} | : point_cloud_(&point_cloud), mesh_(nullptr) {} | ||||
| ExpertEncoder::ExpertEncoder(const Mesh &mesh) | ExpertEncoder::ExpertEncoder(const Mesh &mesh) | ||||
| : point_cloud_(&mesh), mesh_(&mesh) {} | : point_cloud_(&mesh), mesh_(&mesh) {} | ||||
| Status ExpertEncoder::EncodeToBuffer(EncoderBuffer *out_buffer) { | Status ExpertEncoder::EncodeToBuffer(EncoderBuffer *out_buffer) { | ||||
| if (point_cloud_ == nullptr) | if (point_cloud_ == nullptr) { | ||||
| return Status(Status::DRACO_ERROR, "Invalid input geometry."); | return Status(Status::DRACO_ERROR, "Invalid input geometry."); | ||||
| } | |||||
| if (mesh_ == nullptr) { | if (mesh_ == nullptr) { | ||||
| return EncodePointCloudToBuffer(*point_cloud_, out_buffer); | return EncodePointCloudToBuffer(*point_cloud_, out_buffer); | ||||
| } | } | ||||
| return EncodeMeshToBuffer(*mesh_, out_buffer); | return EncodeMeshToBuffer(*mesh_, out_buffer); | ||||
| } | } | ||||
| Status ExpertEncoder::EncodePointCloudToBuffer(const PointCloud &pc, | Status ExpertEncoder::EncodePointCloudToBuffer(const PointCloud &pc, | ||||
| EncoderBuffer *out_buffer) { | EncoderBuffer *out_buffer) { | ||||
| Show All 14 Lines | if (encoding_method == POINT_CLOUD_SEQUENTIAL_ENCODING) { | ||||
| // are satisfied for all attributes: | // are satisfied for all attributes: | ||||
| // -data type is float32 and quantization is enabled, OR | // -data type is float32 and quantization is enabled, OR | ||||
| // -data type is uint32, uint16, uint8 or int32, int16, int8 | // -data type is uint32, uint16, uint8 or int32, int16, int8 | ||||
| for (int i = 0; i < pc.num_attributes(); ++i) { | for (int i = 0; i < pc.num_attributes(); ++i) { | ||||
| const PointAttribute *const att = pc.attribute(i); | const PointAttribute *const att = pc.attribute(i); | ||||
| if (kd_tree_possible && att->data_type() != DT_FLOAT32 && | if (kd_tree_possible && att->data_type() != DT_FLOAT32 && | ||||
| att->data_type() != DT_UINT32 && att->data_type() != DT_UINT16 && | att->data_type() != DT_UINT32 && att->data_type() != DT_UINT16 && | ||||
| att->data_type() != DT_UINT8 && att->data_type() != DT_INT32 && | att->data_type() != DT_UINT8 && att->data_type() != DT_INT32 && | ||||
| att->data_type() != DT_INT16 && att->data_type() != DT_INT8) | att->data_type() != DT_INT16 && att->data_type() != DT_INT8) { | ||||
| kd_tree_possible = false; | kd_tree_possible = false; | ||||
| } | |||||
| if (kd_tree_possible && att->data_type() == DT_FLOAT32 && | if (kd_tree_possible && att->data_type() == DT_FLOAT32 && | ||||
| options().GetAttributeInt(0, "quantization_bits", -1) <= 0) | options().GetAttributeInt(0, "quantization_bits", -1) <= 0) { | ||||
| kd_tree_possible = false; // Quantization not enabled. | kd_tree_possible = false; // Quantization not enabled. | ||||
| if (!kd_tree_possible) | } | ||||
| if (!kd_tree_possible) { | |||||
| break; | break; | ||||
| } | } | ||||
| } | |||||
| if (kd_tree_possible) { | if (kd_tree_possible) { | ||||
| // Create kD-tree encoder (all checks passed). | // Create kD-tree encoder (all checks passed). | ||||
| encoder.reset(new PointCloudKdTreeEncoder()); | encoder.reset(new PointCloudKdTreeEncoder()); | ||||
| } else if (encoding_method == POINT_CLOUD_KD_TREE_ENCODING) { | } else if (encoding_method == POINT_CLOUD_KD_TREE_ENCODING) { | ||||
| // Encoding method was explicitly specified but we cannot use it for | // Encoding method was explicitly specified but we cannot use it for | ||||
| // the given input (some of the checks above failed). | // the given input (some of the checks above failed). | ||||
| return Status(Status::DRACO_ERROR, "Invalid encoding method."); | return Status(Status::DRACO_ERROR, "Invalid encoding method."); | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| Status ExpertEncoder::SetAttributePredictionScheme( | Status ExpertEncoder::SetAttributePredictionScheme( | ||||
| int32_t attribute_id, int prediction_scheme_method) { | int32_t attribute_id, int prediction_scheme_method) { | ||||
| auto att = point_cloud_->attribute(attribute_id); | auto att = point_cloud_->attribute(attribute_id); | ||||
| auto att_type = att->attribute_type(); | auto att_type = att->attribute_type(); | ||||
| const Status status = | const Status status = | ||||
| CheckPredictionScheme(att_type, prediction_scheme_method); | CheckPredictionScheme(att_type, prediction_scheme_method); | ||||
| if (!status.ok()) | if (!status.ok()) { | ||||
| return status; | return status; | ||||
| } | |||||
| options().SetAttributeInt(attribute_id, "prediction_scheme", | options().SetAttributeInt(attribute_id, "prediction_scheme", | ||||
| prediction_scheme_method); | prediction_scheme_method); | ||||
| return status; | return status; | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||