Differential D9642 Diff 31357 extern/draco/draco/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h.
| Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | bool DynamicIntegerPointsKdTreeDecoder<compression_level_t>::DecodePoints( | ||||
| return DecodePoints(buffer, local); | return DecodePoints(buffer, local); | ||||
| } | } | ||||
| #endif // DRACO_OLD_GCC | #endif // DRACO_OLD_GCC | ||||
| template <int compression_level_t> | template <int compression_level_t> | ||||
| template <class OutputIteratorT> | template <class OutputIteratorT> | ||||
| bool DynamicIntegerPointsKdTreeDecoder<compression_level_t>::DecodePoints( | bool DynamicIntegerPointsKdTreeDecoder<compression_level_t>::DecodePoints( | ||||
| DecoderBuffer *buffer, OutputIteratorT &oit) { | DecoderBuffer *buffer, OutputIteratorT &oit) { | ||||
| buffer->Decode(&bit_length_); | if (!buffer->Decode(&bit_length_)) { | ||||
| if (bit_length_ > 32) | |||||
| return false; | return false; | ||||
| buffer->Decode(&num_points_); | } | ||||
| if (num_points_ == 0) | if (bit_length_ > 32) { | ||||
| return false; | |||||
| } | |||||
| if (!buffer->Decode(&num_points_)) { | |||||
| return false; | |||||
| } | |||||
| if (num_points_ == 0) { | |||||
| return true; | return true; | ||||
| } | |||||
| num_decoded_points_ = 0; | num_decoded_points_ = 0; | ||||
| 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; | ||||
| } | |||||
| if (!DecodeInternal(num_points_, oit)) | if (!DecodeInternal(num_points_, oit)) { | ||||
| return false; | return false; | ||||
| } | |||||
| 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 <int compression_level_t> | template <int compression_level_t> | ||||
| uint32_t DynamicIntegerPointsKdTreeDecoder<compression_level_t>::GetAxis( | uint32_t DynamicIntegerPointsKdTreeDecoder<compression_level_t>::GetAxis( | ||||
| uint32_t num_remaining_points, const VectorUint32 &levels, | uint32_t num_remaining_points, const VectorUint32 &levels, | ||||
| uint32_t last_axis) { | uint32_t last_axis) { | ||||
| if (!Policy::select_axis) | if (!Policy::select_axis) { | ||||
| return DRACO_INCREMENT_MOD(last_axis, dimension_); | return DRACO_INCREMENT_MOD(last_axis, dimension_); | ||||
| } | |||||
| 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 < dimension_; ++axis) { | for (uint32_t axis = 1; axis < dimension_; ++axis) { | ||||
| if (levels[best_axis] > levels[axis]) { | if (levels[best_axis] > levels[axis]) { | ||||
| best_axis = axis; | best_axis = axis; | ||||
| } | } | ||||
| } | } | ||||
| Show All 21 Lines | while (!status_stack.empty()) { | ||||
| status_stack.pop(); | status_stack.pop(); | ||||
| const uint32_t num_remaining_points = status.num_remaining_points; | const uint32_t num_remaining_points = status.num_remaining_points; | ||||
| const uint32_t last_axis = status.last_axis; | const uint32_t last_axis = status.last_axis; | ||||
| const uint32_t stack_pos = status.stack_pos; | const uint32_t stack_pos = status.stack_pos; | ||||
| const VectorUint32 &old_base = base_stack_[stack_pos]; | const VectorUint32 &old_base = base_stack_[stack_pos]; | ||||
| const VectorUint32 &levels = levels_stack_[stack_pos]; | const VectorUint32 &levels = levels_stack_[stack_pos]; | ||||
| if (num_remaining_points > num_points) | if (num_remaining_points > num_points) { | ||||
| return false; | return false; | ||||
| } | |||||
| const uint32_t axis = GetAxis(num_remaining_points, levels, last_axis); | const uint32_t axis = GetAxis(num_remaining_points, levels, last_axis); | ||||
| if (axis >= dimension_) | if (axis >= dimension_) { | ||||
| return false; | return false; | ||||
| } | |||||
| const uint32_t level = levels[axis]; | const uint32_t level = levels[axis]; | ||||
| // All axes have been fully subdivided, just output points. | // All axes have been fully subdivided, just output points. | ||||
| if ((bit_length_ - level) == 0) { | if ((bit_length_ - level) == 0) { | ||||
| for (uint32_t i = 0; i < num_remaining_points; i++) { | for (uint32_t i = 0; i < num_remaining_points; i++) { | ||||
| *oit = old_base; | *oit = old_base; | ||||
| ++oit; | ++oit; | ||||
| Show All 10 Lines | if (num_remaining_points <= 2) { | ||||
| axes_[0] = axis; | axes_[0] = axis; | ||||
| for (uint32_t i = 1; i < dimension_; i++) { | for (uint32_t i = 1; i < dimension_; i++) { | ||||
| axes_[i] = DRACO_INCREMENT_MOD(axes_[i - 1], dimension_); | axes_[i] = DRACO_INCREMENT_MOD(axes_[i - 1], dimension_); | ||||
| } | } | ||||
| for (uint32_t i = 0; i < num_remaining_points; ++i) { | for (uint32_t i = 0; i < num_remaining_points; ++i) { | ||||
| for (uint32_t j = 0; j < dimension_; j++) { | for (uint32_t j = 0; j < dimension_; j++) { | ||||
| p_[axes_[j]] = 0; | p_[axes_[j]] = 0; | ||||
| const uint32_t num_remaining_bits = bit_length_ - levels[axes_[j]]; | const uint32_t num_remaining_bits = bit_length_ - levels[axes_[j]]; | ||||
| if (num_remaining_bits) | if (num_remaining_bits) { | ||||
| remaining_bits_decoder_.DecodeLeastSignificantBits32( | remaining_bits_decoder_.DecodeLeastSignificantBits32( | ||||
| num_remaining_bits, &p_[axes_[j]]); | num_remaining_bits, &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_; | ||||
| ++oit; | ++oit; | ||||
| ++num_decoded_points_; | ++num_decoded_points_; | ||||
| } | } | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (num_decoded_points_ > num_points_) | if (num_decoded_points_ > num_points_) { | ||||
| return false; | return false; | ||||
| } | |||||
| 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); | ||||
| base_stack_[stack_pos + 1] = old_base; // copy | base_stack_[stack_pos + 1] = old_base; // copy | ||||
| base_stack_[stack_pos + 1][axis] += modifier; // new base | base_stack_[stack_pos + 1][axis] += modifier; // new base | ||||
| 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_stack_[stack_pos][axis] += 1; | levels_stack_[stack_pos][axis] += 1; | ||||
| levels_stack_[stack_pos + 1] = levels_stack_[stack_pos]; // copy | levels_stack_[stack_pos + 1] = levels_stack_[stack_pos]; // copy | ||||
| if (first_half) | if (first_half) { | ||||
| status_stack.push(DecodingStatus(first_half, axis, stack_pos)); | status_stack.push(DecodingStatus(first_half, axis, stack_pos)); | ||||
| if (second_half) | } | ||||
| if (second_half) { | |||||
| status_stack.push(DecodingStatus(second_half, axis, stack_pos + 1)); | status_stack.push(DecodingStatus(second_half, axis, stack_pos + 1)); | ||||
| } | } | ||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| extern template class DynamicIntegerPointsKdTreeDecoder<0>; | extern template class DynamicIntegerPointsKdTreeDecoder<0>; | ||||
| extern template class DynamicIntegerPointsKdTreeDecoder<2>; | extern template class DynamicIntegerPointsKdTreeDecoder<2>; | ||||
| extern template class DynamicIntegerPointsKdTreeDecoder<4>; | extern template class DynamicIntegerPointsKdTreeDecoder<4>; | ||||
| extern template class DynamicIntegerPointsKdTreeDecoder<6>; | extern template class DynamicIntegerPointsKdTreeDecoder<6>; | ||||
| } // namespace draco | } // namespace draco | ||||
| #endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_H_ | #endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_H_ | ||||