Differential D9642 Diff 31360 extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h.
| Show All 12 Lines | |||||
| // limitations under the License. | // limitations under the License. | ||||
| // | // | ||||
| #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ | #ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ | ||||
| #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ | #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ | ||||
| #include <algorithm> | #include <algorithm> | ||||
| #include <cmath> | #include <cmath> | ||||
| #include "draco/draco_features.h" | |||||
| #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" | #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.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_parallelogram_shared.h" | #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.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/draco_features.h" | |||||
| namespace draco { | namespace draco { | ||||
| // Decoder for predictions encoded with the constrained multi-parallelogram | // Decoder for predictions encoded with the constrained multi-parallelogram | ||||
| // encoder. See the corresponding encoder for more details about the prediction | // encoder. See the corresponding encoder for more details about the prediction | ||||
| // method. | // method. | ||||
| template <typename DataTypeT, class TransformT, class MeshDataT> | template <typename DataTypeT, class TransformT, class MeshDataT> | ||||
| class MeshPredictionSchemeConstrainedMultiParallelogramDecoder | class MeshPredictionSchemeConstrainedMultiParallelogramDecoder | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | while (corner_id != kInvalidCornerIndex) { | ||||
| if (ComputeParallelogramPrediction( | if (ComputeParallelogramPrediction( | ||||
| p, corner_id, table, *vertex_to_data_map, out_data, | p, corner_id, table, *vertex_to_data_map, out_data, | ||||
| num_components, &(pred_vals[num_parallelograms][0]))) { | num_components, &(pred_vals[num_parallelograms][0]))) { | ||||
| // Parallelogram prediction applied and stored in | // Parallelogram prediction applied and stored in | ||||
| // |pred_vals[num_parallelograms]| | // |pred_vals[num_parallelograms]| | ||||
| ++num_parallelograms; | ++num_parallelograms; | ||||
| // Stop processing when we reach the maximum number of allowed | // Stop processing when we reach the maximum number of allowed | ||||
| // parallelograms. | // parallelograms. | ||||
| if (num_parallelograms == kMaxNumParallelograms) | if (num_parallelograms == kMaxNumParallelograms) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | |||||
| // Proceed to the next corner attached to the vertex. First swing left | // Proceed to the next corner attached to the vertex. First swing left | ||||
| // and if we reach a boundary, swing right from the start corner. | // and if we reach a boundary, swing right from the start corner. | ||||
| if (first_pass) { | if (first_pass) { | ||||
| corner_id = table->SwingLeft(corner_id); | corner_id = table->SwingLeft(corner_id); | ||||
| } else { | } else { | ||||
| corner_id = table->SwingRight(corner_id); | corner_id = table->SwingRight(corner_id); | ||||
| } | } | ||||
| Show All 12 Lines | for (int p = 1; p < corner_map_size; ++p) { | ||||
| if (num_parallelograms > 0) { | if (num_parallelograms > 0) { | ||||
| for (int i = 0; i < num_components; ++i) { | for (int i = 0; i < num_components; ++i) { | ||||
| multi_pred_vals[i] = 0; | multi_pred_vals[i] = 0; | ||||
| } | } | ||||
| // Check which parallelograms are actually used. | // Check which parallelograms are actually used. | ||||
| for (int i = 0; i < num_parallelograms; ++i) { | for (int i = 0; i < num_parallelograms; ++i) { | ||||
| const int context = num_parallelograms - 1; | const int context = num_parallelograms - 1; | ||||
| const int pos = is_crease_edge_pos[context]++; | const int pos = is_crease_edge_pos[context]++; | ||||
| if (is_crease_edge_[context].size() <= pos) | if (is_crease_edge_[context].size() <= pos) { | ||||
| return false; | return false; | ||||
| } | |||||
| const bool is_crease = is_crease_edge_[context][pos]; | const bool is_crease = is_crease_edge_[context][pos]; | ||||
| if (!is_crease) { | if (!is_crease) { | ||||
| ++num_used_parallelograms; | ++num_used_parallelograms; | ||||
| for (int j = 0; j < num_components; ++j) { | for (int j = 0; j < num_components; ++j) { | ||||
| multi_pred_vals[j] += pred_vals[i][j]; | multi_pred_vals[j] += pred_vals[i][j]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 34 Lines | if (mode != Mode::OPTIMAL_MULTI_PARALLELOGRAM) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| // Encode selected edges using separate rans bit coder for each context. | // Encode selected edges using separate rans bit coder for each context. | ||||
| for (int i = 0; i < kMaxNumParallelograms; ++i) { | for (int i = 0; i < kMaxNumParallelograms; ++i) { | ||||
| uint32_t num_flags; | uint32_t num_flags; | ||||
| DecodeVarint<uint32_t>(&num_flags, buffer); | if (!DecodeVarint<uint32_t>(&num_flags, buffer)) { | ||||
| return false; | |||||
| } | |||||
| if (num_flags > 0) { | if (num_flags > 0) { | ||||
| is_crease_edge_[i].resize(num_flags); | is_crease_edge_[i].resize(num_flags); | ||||
| RAnsBitDecoder decoder; | RAnsBitDecoder decoder; | ||||
| if (!decoder.StartDecoding(buffer)) | if (!decoder.StartDecoding(buffer)) { | ||||
| return false; | return false; | ||||
| } | |||||
| for (uint32_t j = 0; j < num_flags; ++j) { | for (uint32_t j = 0; j < num_flags; ++j) { | ||||
| is_crease_edge_[i][j] = decoder.DecodeNextBit(); | is_crease_edge_[i][j] = decoder.DecodeNextBit(); | ||||
| } | } | ||||
| decoder.EndDecoding(); | decoder.EndDecoding(); | ||||
| } | } | ||||
| } | } | ||||
| return MeshPredictionSchemeDecoder<DataTypeT, TransformT, | return MeshPredictionSchemeDecoder<DataTypeT, TransformT, | ||||
| MeshDataT>::DecodePredictionData(buffer); | MeshDataT>::DecodePredictionData(buffer); | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||
| #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ | #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ | ||||