Differential D9642 Diff 31697 extern/draco/draco/src/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.h.
| Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | private: | ||||
| HalfDecoder half_decoder_; | HalfDecoder half_decoder_; | ||||
| }; | }; | ||||
| // Decodes a point cloud from |buffer|. | // Decodes a point cloud from |buffer|. | ||||
| template <class PointDiT, int compression_level_t> | template <class PointDiT, int compression_level_t> | ||||
| template <class OutputIteratorT> | template <class OutputIteratorT> | ||||
| bool IntegerPointsKdTreeDecoder<PointDiT, compression_level_t>::DecodePoints( | bool IntegerPointsKdTreeDecoder<PointDiT, compression_level_t>::DecodePoints( | ||||
| DecoderBuffer *buffer, OutputIteratorT oit) { | DecoderBuffer *buffer, OutputIteratorT oit) { | ||||
| buffer->Decode(&bit_length_); | if (!buffer->Decode(&bit_length_)) { | ||||
| buffer->Decode(&num_points_); | return false; | ||||
| if (num_points_ == 0) | } | ||||
| if (!buffer->Decode(&num_points_)) { | |||||
| return false; | |||||
| } | |||||
| if (num_points_ == 0) { | |||||
| return true; | return true; | ||||
| } | |||||
| if (!numbers_decoder_.StartDecoding(buffer)) | if (!numbers_decoder_.StartDecoding(buffer)) { | ||||
| return false; | return false; | ||||
| if (!remaining_bits_decoder_.StartDecoding(buffer)) | } | ||||
| if (!remaining_bits_decoder_.StartDecoding(buffer)) { | |||||
| return false; | return false; | ||||
| if (!axis_decoder_.StartDecoding(buffer)) | } | ||||
| if (!axis_decoder_.StartDecoding(buffer)) { | |||||
| return false; | return false; | ||||
| if (!half_decoder_.StartDecoding(buffer)) | } | ||||
| if (!half_decoder_.StartDecoding(buffer)) { | |||||
| return false; | return false; | ||||
| } | |||||
| DecodeInternal(num_points_, PointTraits<PointDiT>::Origin(), | DecodeInternal(num_points_, PointTraits<PointDiT>::Origin(), | ||||
| PointTraits<PointDiT>::ZeroArray(), 0, oit); | PointTraits<PointDiT>::ZeroArray(), 0, oit); | ||||
| numbers_decoder_.EndDecoding(); | numbers_decoder_.EndDecoding(); | ||||
| remaining_bits_decoder_.EndDecoding(); | remaining_bits_decoder_.EndDecoding(); | ||||
| axis_decoder_.EndDecoding(); | axis_decoder_.EndDecoding(); | ||||
| half_decoder_.EndDecoding(); | half_decoder_.EndDecoding(); | ||||
| return true; | return true; | ||||
| } | } | ||||
| template <class PointDiT, int compression_level_t> | template <class PointDiT, int compression_level_t> | ||||
| uint32_t IntegerPointsKdTreeDecoder<PointDiT, compression_level_t>::GetAxis( | uint32_t IntegerPointsKdTreeDecoder<PointDiT, compression_level_t>::GetAxis( | ||||
| uint32_t num_remaining_points, const PointDiT & /* base */, | uint32_t num_remaining_points, const PointDiT & /* base */, | ||||
| std::array<uint32_t, D> levels, uint32_t last_axis) { | std::array<uint32_t, D> levels, uint32_t last_axis) { | ||||
| if (!Policy::select_axis) | if (!Policy::select_axis) { | ||||
| return DRACO_INCREMENT_MOD(last_axis, D); | return DRACO_INCREMENT_MOD(last_axis, D); | ||||
| } | |||||
| uint32_t best_axis = 0; | uint32_t best_axis = 0; | ||||
| if (num_remaining_points < 64) { | if (num_remaining_points < 64) { | ||||
| for (uint32_t axis = 1; axis < D; ++axis) { | for (uint32_t axis = 1; axis < D; ++axis) { | ||||
| if (levels[best_axis] > levels[axis]) { | if (levels[best_axis] > levels[axis]) { | ||||
| best_axis = axis; | best_axis = axis; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if (num_remaining_points <= 2) { | ||||
| for (int i = 0; i < D; i++) { | for (int i = 0; i < D; i++) { | ||||
| num_remaining_bits[i] = bit_length_ - levels[axes[i]]; | num_remaining_bits[i] = bit_length_ - levels[axes[i]]; | ||||
| } | } | ||||
| for (uint32_t i = 0; i < num_remaining_points; ++i) { | for (uint32_t i = 0; i < num_remaining_points; ++i) { | ||||
| // Get remaining bits, mind the carry if not starting at x. | // Get remaining bits, mind the carry if not starting at x. | ||||
| PointDiT p = PointTraits<PointDiT>::Origin(); | PointDiT p = PointTraits<PointDiT>::Origin(); | ||||
| for (int j = 0; j < static_cast<int>(D); j++) { | for (int j = 0; j < static_cast<int>(D); j++) { | ||||
| if (num_remaining_bits[j]) | if (num_remaining_bits[j]) { | ||||
| remaining_bits_decoder_.DecodeLeastSignificantBits32( | remaining_bits_decoder_.DecodeLeastSignificantBits32( | ||||
| num_remaining_bits[j], &p[axes[j]]); | num_remaining_bits[j], &p[axes[j]]); | ||||
| } | |||||
| p[axes[j]] = old_base[axes[j]] | p[axes[j]]; | p[axes[j]] = old_base[axes[j]] | p[axes[j]]; | ||||
| } | } | ||||
| *oit++ = p; | *oit++ = p; | ||||
| } | } | ||||
| continue; | continue; | ||||
| } | } | ||||
| const int num_remaining_bits = bit_length_ - level; | const int num_remaining_bits = bit_length_ - level; | ||||
| const uint32_t modifier = 1 << (num_remaining_bits - 1); | const uint32_t modifier = 1 << (num_remaining_bits - 1); | ||||
| PointDiT new_base(old_base); | PointDiT new_base(old_base); | ||||
| new_base[axis] += modifier; | new_base[axis] += modifier; | ||||
| const int incoming_bits = MostSignificantBit(num_remaining_points); | const int incoming_bits = MostSignificantBit(num_remaining_points); | ||||
| uint32_t number = 0; | uint32_t number = 0; | ||||
| DecodeNumber(incoming_bits, &number); | DecodeNumber(incoming_bits, &number); | ||||
| uint32_t first_half = num_remaining_points / 2 - number; | uint32_t first_half = num_remaining_points / 2 - number; | ||||
| uint32_t second_half = num_remaining_points - first_half; | uint32_t second_half = num_remaining_points - first_half; | ||||
| if (first_half != second_half) | if (first_half != second_half) { | ||||
| if (!half_decoder_.DecodeNextBit()) | if (!half_decoder_.DecodeNextBit()) { | ||||
| std::swap(first_half, second_half); | std::swap(first_half, second_half); | ||||
| } | |||||
| } | |||||
| levels[axis] += 1; | levels[axis] += 1; | ||||
| if (first_half) | if (first_half) { | ||||
| status_q.push(DecodingStatus(first_half, old_base, levels, axis)); | status_q.push(DecodingStatus(first_half, old_base, levels, axis)); | ||||
| if (second_half) | } | ||||
| if (second_half) { | |||||
| status_q.push(DecodingStatus(second_half, new_base, levels, axis)); | status_q.push(DecodingStatus(second_half, new_base, levels, axis)); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 0>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 0>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 1>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 1>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 2>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 2>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 3>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 3>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 4>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 4>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 5>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 5>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 6>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 6>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 7>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 7>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 8>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 8>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 9>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 9>; | ||||
| extern template class IntegerPointsKdTreeDecoder<Point3ui, 10>; | extern template class IntegerPointsKdTreeDecoder<Point3ui, 10>; | ||||
| } // namespace draco | } // namespace draco | ||||
| #endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_DECODER_H_ | #endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_DECODER_H_ | ||||