Differential D9642 Diff 31337 extern/draco/draco/src/draco/compression/attributes/attributes_encoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/attributes_encoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/attributes_encoder.h.
| Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public: | ||||
| virtual bool EncodeAttributesEncoderData(EncoderBuffer *out_buffer); | virtual bool EncodeAttributesEncoderData(EncoderBuffer *out_buffer); | ||||
| // Returns a unique identifier of the given encoder type, that is used during | // Returns a unique identifier of the given encoder type, that is used during | ||||
| // decoding to construct the corresponding attribute decoder. | // decoding to construct the corresponding attribute decoder. | ||||
| virtual uint8_t GetUniqueId() const = 0; | virtual uint8_t GetUniqueId() const = 0; | ||||
| // Encode attribute data to the target buffer. | // Encode attribute data to the target buffer. | ||||
| virtual bool EncodeAttributes(EncoderBuffer *out_buffer) { | virtual bool EncodeAttributes(EncoderBuffer *out_buffer) { | ||||
| if (!TransformAttributesToPortableFormat()) | if (!TransformAttributesToPortableFormat()) { | ||||
| return false; | return false; | ||||
| if (!EncodePortableAttributes(out_buffer)) | } | ||||
| if (!EncodePortableAttributes(out_buffer)) { | |||||
| return false; | return false; | ||||
| } | |||||
| // Encode data needed by portable transforms after the attribute is encoded. | // Encode data needed by portable transforms after the attribute is encoded. | ||||
| // This corresponds to the order in which the data is going to be decoded by | // This corresponds to the order in which the data is going to be decoded by | ||||
| // the decoder. | // the decoder. | ||||
| if (!EncodeDataNeededByPortableTransforms(out_buffer)) | if (!EncodeDataNeededByPortableTransforms(out_buffer)) { | ||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| // Returns the number of attributes that need to be encoded before the | // Returns the number of attributes that need to be encoded before the | ||||
| // specified attribute is encoded. | // specified attribute is encoded. | ||||
| // Note that the attribute is specified by its point attribute id. | // Note that the attribute is specified by its point attribute id. | ||||
| virtual int NumParentAttributes(int32_t /* point_attribute_id */) const { | virtual int NumParentAttributes(int32_t /* point_attribute_id */) const { | ||||
| return 0; | return 0; | ||||
| Show All 14 Lines | public: | ||||
| // encoded losslessly and it can be safely used for predictors. | // encoded losslessly and it can be safely used for predictors. | ||||
| virtual const PointAttribute *GetPortableAttribute( | virtual const PointAttribute *GetPortableAttribute( | ||||
| int32_t /* point_attribute_id */) { | int32_t /* point_attribute_id */) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| void AddAttributeId(int32_t id) { | void AddAttributeId(int32_t id) { | ||||
| point_attribute_ids_.push_back(id); | point_attribute_ids_.push_back(id); | ||||
| if (id >= static_cast<int32_t>(point_attribute_to_local_id_map_.size())) | if (id >= static_cast<int32_t>(point_attribute_to_local_id_map_.size())) { | ||||
| point_attribute_to_local_id_map_.resize(id + 1, -1); | point_attribute_to_local_id_map_.resize(id + 1, -1); | ||||
| } | |||||
| point_attribute_to_local_id_map_[id] = | point_attribute_to_local_id_map_[id] = | ||||
| static_cast<int32_t>(point_attribute_ids_.size()) - 1; | static_cast<int32_t>(point_attribute_ids_.size()) - 1; | ||||
| } | } | ||||
| // Sets new attribute point ids (replacing the existing ones). | // Sets new attribute point ids (replacing the existing ones). | ||||
| void SetAttributeIds(const std::vector<int32_t> &point_attribute_ids) { | void SetAttributeIds(const std::vector<int32_t> &point_attribute_ids) { | ||||
| point_attribute_ids_.clear(); | point_attribute_ids_.clear(); | ||||
| point_attribute_to_local_id_map_.clear(); | point_attribute_to_local_id_map_.clear(); | ||||
| Show All 22 Lines | protected: | ||||
| // attribute (e.g. data needed for dequantization of quantized values). | // attribute (e.g. data needed for dequantization of quantized values). | ||||
| virtual bool EncodeDataNeededByPortableTransforms(EncoderBuffer *out_buffer) { | virtual bool EncodeDataNeededByPortableTransforms(EncoderBuffer *out_buffer) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { | int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { | ||||
| const int id_map_size = | const int id_map_size = | ||||
| static_cast<int>(point_attribute_to_local_id_map_.size()); | static_cast<int>(point_attribute_to_local_id_map_.size()); | ||||
| if (point_attribute_id >= id_map_size) | if (point_attribute_id >= id_map_size) { | ||||
| return -1; | return -1; | ||||
| } | |||||
| return point_attribute_to_local_id_map_[point_attribute_id]; | return point_attribute_to_local_id_map_[point_attribute_id]; | ||||
| } | } | ||||
| private: | private: | ||||
| // List of attribute ids that need to be encoded with this encoder. | // List of attribute ids that need to be encoded with this encoder. | ||||
| std::vector<int32_t> point_attribute_ids_; | std::vector<int32_t> point_attribute_ids_; | ||||
| // Map between point attribute id and the local id (i.e., the inverse of the | // Map between point attribute id and the local id (i.e., the inverse of the | ||||
| Show All 10 Lines | |||||