Differential D9642 Diff 31360 extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h.
| Show All 9 Lines | |||||
| // distributed under the License is distributed on an "AS IS" BASIS, | // distributed under the License is distributed on an "AS IS" BASIS, | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| // See the License for the specific language governing permissions and | // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | // limitations under the License. | ||||
| // | // | ||||
| #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ | #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ | ||||
| #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ | #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_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/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" | #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" | ||||
| #include "draco/compression/bit_coders/rans_bit_decoder.h" | #include "draco/compression/bit_coders/rans_bit_decoder.h" | ||||
| #include "draco/draco_features.h" | |||||
| namespace draco { | namespace draco { | ||||
| // See MeshPredictionSchemeGeometricNormalEncoder for documentation. | // See MeshPredictionSchemeGeometricNormalEncoder for documentation. | ||||
| template <typename DataTypeT, class TransformT, class MeshDataT> | template <typename DataTypeT, class TransformT, class MeshDataT> | ||||
| class MeshPredictionSchemeGeometricNormalDecoder | class MeshPredictionSchemeGeometricNormalDecoder | ||||
| : public MeshPredictionSchemeDecoder<DataTypeT, TransformT, MeshDataT> { | : public MeshPredictionSchemeDecoder<DataTypeT, TransformT, MeshDataT> { | ||||
| public: | public: | ||||
| Show All 16 Lines | public: | ||||
| bool DecodePredictionData(DecoderBuffer *buffer) override; | bool DecodePredictionData(DecoderBuffer *buffer) override; | ||||
| PredictionSchemeMethod GetPredictionMethod() const override { | PredictionSchemeMethod GetPredictionMethod() const override { | ||||
| return MESH_PREDICTION_GEOMETRIC_NORMAL; | return MESH_PREDICTION_GEOMETRIC_NORMAL; | ||||
| } | } | ||||
| bool IsInitialized() const override { | bool IsInitialized() const override { | ||||
| if (!predictor_.IsInitialized()) | if (!predictor_.IsInitialized()) { | ||||
| return false; | return false; | ||||
| if (!this->mesh_data().IsInitialized()) | } | ||||
| if (!this->mesh_data().IsInitialized()) { | |||||
| return false; | return false; | ||||
| if (!octahedron_tool_box_.IsInitialized()) | } | ||||
| if (!octahedron_tool_box_.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->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. | ||||
| } | |||||
| predictor_.SetPositionAttribute(*att); | predictor_.SetPositionAttribute(*att); | ||||
| return true; | return true; | ||||
| } | } | ||||
| void SetQuantizationBits(int q) { | void SetQuantizationBits(int q) { | ||||
| octahedron_tool_box_.SetQuantizationBits(q); | octahedron_tool_box_.SetQuantizationBits(q); | ||||
| } | } | ||||
| private: | private: | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | bool MeshPredictionSchemeGeometricNormalDecoder< | ||||
| return true; | return true; | ||||
| } | } | ||||
| template <typename DataTypeT, class TransformT, class MeshDataT> | template <typename DataTypeT, class TransformT, class MeshDataT> | ||||
| bool MeshPredictionSchemeGeometricNormalDecoder< | bool MeshPredictionSchemeGeometricNormalDecoder< | ||||
| DataTypeT, TransformT, MeshDataT>::DecodePredictionData(DecoderBuffer | DataTypeT, TransformT, MeshDataT>::DecodePredictionData(DecoderBuffer | ||||
| *buffer) { | *buffer) { | ||||
| // Get data needed for transform | // Get data needed for transform | ||||
| if (!this->transform().DecodeTransformData(buffer)) | if (!this->transform().DecodeTransformData(buffer)) { | ||||
| return false; | return false; | ||||
| } | |||||
| #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | ||||
| if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { | if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { | ||||
| uint8_t prediction_mode; | uint8_t prediction_mode; | ||||
| buffer->Decode(&prediction_mode); | if (!buffer->Decode(&prediction_mode)) { | ||||
| return false; | |||||
| } | |||||
| if (!predictor_.SetNormalPredictionMode( | if (!predictor_.SetNormalPredictionMode( | ||||
| NormalPredictionMode(prediction_mode))) | NormalPredictionMode(prediction_mode))) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| #endif | #endif | ||||
| // Init normal flips. | // Init normal flips. | ||||
| if (!flip_normal_bit_decoder_.StartDecoding(buffer)) | if (!flip_normal_bit_decoder_.StartDecoding(buffer)) { | ||||
| return false; | return false; | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||
| #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ | #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ | ||||