Differential D9642 Diff 31697 extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h.
| Show All 12 Lines | |||||
| // limitations under the License. | // limitations under the License. | ||||
| // | // | ||||
| #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | ||||
| #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_DECODER_H_ | #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_DECODER_H_ | ||||
| #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_DECODER_H_ | #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_DECODER_H_ | ||||
| #include <math.h> | #include <math.h> | ||||
| #include "draco/draco_features.h" | |||||
| #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" | #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" | ||||
| #include "draco/compression/bit_coders/rans_bit_decoder.h" | #include "draco/compression/bit_coders/rans_bit_decoder.h" | ||||
| #include "draco/core/varint_decoding.h" | #include "draco/core/varint_decoding.h" | ||||
| #include "draco/core/vector_d.h" | #include "draco/core/vector_d.h" | ||||
| #include "draco/draco_features.h" | |||||
| #include "draco/mesh/corner_table.h" | #include "draco/mesh/corner_table.h" | ||||
| namespace draco { | namespace draco { | ||||
| // Decoder for predictions of UV coordinates encoded by our specialized texture | // Decoder for predictions of UV coordinates encoded by our specialized texture | ||||
| // coordinate predictor. See the corresponding encoder for more details. Note | // coordinate predictor. See the corresponding encoder for more details. Note | ||||
| // that this predictor is not portable and should not be used anymore. See | // that this predictor is not portable and should not be used anymore. See | ||||
| // MeshPredictionSchemeTexCoordsPortableEncoder/Decoder for a portable version | // MeshPredictionSchemeTexCoordsPortableEncoder/Decoder for a portable version | ||||
| Show All 20 Lines | public: | ||||
| bool DecodePredictionData(DecoderBuffer *buffer) override; | bool DecodePredictionData(DecoderBuffer *buffer) override; | ||||
| PredictionSchemeMethod GetPredictionMethod() const override { | PredictionSchemeMethod GetPredictionMethod() const override { | ||||
| return MESH_PREDICTION_TEX_COORDS_DEPRECATED; | return MESH_PREDICTION_TEX_COORDS_DEPRECATED; | ||||
| } | } | ||||
| bool IsInitialized() const override { | bool IsInitialized() const override { | ||||
| if (pos_attribute_ == nullptr) | if (pos_attribute_ == nullptr) { | ||||
| return false; | return false; | ||||
| if (!this->mesh_data().IsInitialized()) | } | ||||
| if (!this->mesh_data().IsInitialized()) { | |||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| int GetNumParentAttributes() const override { return 1; } | int GetNumParentAttributes() const override { return 1; } | ||||
| GeometryAttribute::Type GetParentAttributeType(int i) const override { | GeometryAttribute::Type GetParentAttributeType(int i) const override { | ||||
| DRACO_DCHECK_EQ(i, 0); | DRACO_DCHECK_EQ(i, 0); | ||||
| (void)i; | (void)i; | ||||
| return GeometryAttribute::POSITION; | return GeometryAttribute::POSITION; | ||||
| } | } | ||||
| bool SetParentAttribute(const PointAttribute *att) override { | bool SetParentAttribute(const PointAttribute *att) override { | ||||
| if (att == nullptr) | if (att == nullptr) { | ||||
| return false; | return false; | ||||
| if (att->attribute_type() != GeometryAttribute::POSITION) | } | ||||
| if (att->attribute_type() != GeometryAttribute::POSITION) { | |||||
| return false; // Invalid attribute type. | return false; // Invalid attribute type. | ||||
| if (att->num_components() != 3) | } | ||||
| if (att->num_components() != 3) { | |||||
| return false; // Currently works only for 3 component positions. | return false; // Currently works only for 3 component positions. | ||||
| } | |||||
| pos_attribute_ = att; | pos_attribute_ = att; | ||||
| return true; | return true; | ||||
| } | } | ||||
| protected: | protected: | ||||
| Vector3f GetPositionForEntryId(int entry_id) const { | Vector3f GetPositionForEntryId(int entry_id) const { | ||||
| const PointIndex point_id = entry_to_point_id_map_[entry_id]; | const PointIndex point_id = entry_to_point_id_map_[entry_id]; | ||||
| Vector3f pos; | Vector3f pos; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| template <typename DataTypeT, class TransformT, class MeshDataT> | template <typename DataTypeT, class TransformT, class MeshDataT> | ||||
| bool MeshPredictionSchemeTexCoordsDecoder<DataTypeT, TransformT, MeshDataT>:: | bool MeshPredictionSchemeTexCoordsDecoder<DataTypeT, TransformT, MeshDataT>:: | ||||
| DecodePredictionData(DecoderBuffer *buffer) { | DecodePredictionData(DecoderBuffer *buffer) { | ||||
| // Decode the delta coded orientations. | // Decode the delta coded orientations. | ||||
| uint32_t num_orientations = 0; | uint32_t num_orientations = 0; | ||||
| if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { | if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { | ||||
| if (!buffer->Decode(&num_orientations)) | if (!buffer->Decode(&num_orientations)) { | ||||
| return false; | return false; | ||||
| } | |||||
| } else { | } else { | ||||
| if (!DecodeVarint(&num_orientations, buffer)) | if (!DecodeVarint(&num_orientations, buffer)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (num_orientations == 0) | } | ||||
| if (num_orientations == 0) { | |||||
| return false; | return false; | ||||
| } | |||||
| orientations_.resize(num_orientations); | orientations_.resize(num_orientations); | ||||
| bool last_orientation = true; | bool last_orientation = true; | ||||
| RAnsBitDecoder decoder; | RAnsBitDecoder decoder; | ||||
| if (!decoder.StartDecoding(buffer)) | if (!decoder.StartDecoding(buffer)) { | ||||
| return false; | return false; | ||||
| } | |||||
| for (uint32_t i = 0; i < num_orientations; ++i) { | for (uint32_t i = 0; i < num_orientations; ++i) { | ||||
| if (!decoder.DecodeNextBit()) | if (!decoder.DecodeNextBit()) { | ||||
| last_orientation = !last_orientation; | last_orientation = !last_orientation; | ||||
| } | |||||
| orientations_[i] = last_orientation; | orientations_[i] = last_orientation; | ||||
| } | } | ||||
| decoder.EndDecoding(); | decoder.EndDecoding(); | ||||
| return MeshPredictionSchemeDecoder<DataTypeT, TransformT, | return MeshPredictionSchemeDecoder<DataTypeT, TransformT, | ||||
| MeshDataT>::DecodePredictionData(buffer); | MeshDataT>::DecodePredictionData(buffer); | ||||
| } | } | ||||
| template <typename DataTypeT, class TransformT, class MeshDataT> | template <typename DataTypeT, class TransformT, class MeshDataT> | ||||
| ▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines | |||||