Differential D9642 Diff 31697 extern/draco/draco/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/mesh/mesh_edgebreaker_traversal_valence_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_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_ | #ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_ | ||||
| #define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_ | #define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_ | ||||
| #include "draco/draco_features.h" | |||||
| #include "draco/compression/entropy/symbol_decoding.h" | #include "draco/compression/entropy/symbol_decoding.h" | ||||
| #include "draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h" | #include "draco/compression/mesh/mesh_edgebreaker_traversal_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 traversal encoded with MeshEdgebreakerTraversalValenceEncoder. | // Decoder for traversal encoded with MeshEdgebreakerTraversalValenceEncoder. | ||||
| // The decoder maintains valences of the decoded portion of the traversed mesh | // The decoder maintains valences of the decoded portion of the traversed mesh | ||||
| // and it uses them to select entropy context used for decoding of the actual | // and it uses them to select entropy context used for decoding of the actual | ||||
| // symbols. | // symbols. | ||||
| class MeshEdgebreakerTraversalValenceDecoder | class MeshEdgebreakerTraversalValenceDecoder | ||||
| Show All 10 Lines | void Init(MeshEdgebreakerDecoderImplInterface *decoder) { | ||||
| MeshEdgebreakerTraversalDecoder::Init(decoder); | MeshEdgebreakerTraversalDecoder::Init(decoder); | ||||
| corner_table_ = decoder->GetCornerTable(); | corner_table_ = decoder->GetCornerTable(); | ||||
| } | } | ||||
| void SetNumEncodedVertices(int num_vertices) { num_vertices_ = num_vertices; } | void SetNumEncodedVertices(int num_vertices) { num_vertices_ = num_vertices; } | ||||
| bool Start(DecoderBuffer *out_buffer) { | bool Start(DecoderBuffer *out_buffer) { | ||||
| #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | ||||
| if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { | if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { | ||||
| if (!MeshEdgebreakerTraversalDecoder::DecodeTraversalSymbols()) | if (!MeshEdgebreakerTraversalDecoder::DecodeTraversalSymbols()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| #endif | #endif | ||||
| if (!MeshEdgebreakerTraversalDecoder::DecodeStartFaces()) | if (!MeshEdgebreakerTraversalDecoder::DecodeStartFaces()) { | ||||
| return false; | return false; | ||||
| if (!MeshEdgebreakerTraversalDecoder::DecodeAttributeSeams()) | } | ||||
| if (!MeshEdgebreakerTraversalDecoder::DecodeAttributeSeams()) { | |||||
| return false; | return false; | ||||
| } | |||||
| *out_buffer = *buffer(); | *out_buffer = *buffer(); | ||||
| #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | ||||
| if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { | if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { | ||||
| uint32_t num_split_symbols; | uint32_t num_split_symbols; | ||||
| if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 0)) { | if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 0)) { | ||||
| if (!out_buffer->Decode(&num_split_symbols)) | if (!out_buffer->Decode(&num_split_symbols)) { | ||||
| return false; | return false; | ||||
| } | |||||
| } else { | } else { | ||||
| if (!DecodeVarint(&num_split_symbols, out_buffer)) | if (!DecodeVarint(&num_split_symbols, out_buffer)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (num_split_symbols >= static_cast<uint32_t>(num_vertices_)) | } | ||||
| if (num_split_symbols >= static_cast<uint32_t>(num_vertices_)) { | |||||
| return false; | return false; | ||||
| } | |||||
| int8_t mode; | int8_t mode; | ||||
| if (!out_buffer->Decode(&mode)) | if (!out_buffer->Decode(&mode)) { | ||||
| return false; | return false; | ||||
| } | |||||
| if (mode == EDGEBREAKER_VALENCE_MODE_2_7) { | if (mode == EDGEBREAKER_VALENCE_MODE_2_7) { | ||||
| min_valence_ = 2; | min_valence_ = 2; | ||||
| max_valence_ = 7; | max_valence_ = 7; | ||||
| } else { | } else { | ||||
| // Unsupported mode. | // Unsupported mode. | ||||
| return false; | return false; | ||||
| } | } | ||||
| } else | } else | ||||
| #endif | #endif | ||||
| { | { | ||||
| min_valence_ = 2; | min_valence_ = 2; | ||||
| max_valence_ = 7; | max_valence_ = 7; | ||||
| } | } | ||||
| if (num_vertices_ < 0) | if (num_vertices_ < 0) { | ||||
| return false; | return false; | ||||
| } | |||||
| // Set the valences of all initial vertices to 0. | // Set the valences of all initial vertices to 0. | ||||
| vertex_valences_.resize(num_vertices_, 0); | vertex_valences_.resize(num_vertices_, 0); | ||||
| const int num_unique_valences = max_valence_ - min_valence_ + 1; | const int num_unique_valences = max_valence_ - min_valence_ + 1; | ||||
| // Decode all symbols for all contexts. | // Decode all symbols for all contexts. | ||||
| context_symbols_.resize(num_unique_valences); | context_symbols_.resize(num_unique_valences); | ||||
| context_counters_.resize(context_symbols_.size()); | context_counters_.resize(context_symbols_.size()); | ||||
| Show All 9 Lines | #endif | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| inline uint32_t DecodeSymbol() { | inline uint32_t DecodeSymbol() { | ||||
| // First check if we have a valid context. | // First check if we have a valid context. | ||||
| if (active_context_ != -1) { | if (active_context_ != -1) { | ||||
| const int context_counter = --context_counters_[active_context_]; | const int context_counter = --context_counters_[active_context_]; | ||||
| if (context_counter < 0) | if (context_counter < 0) { | ||||
| return TOPOLOGY_INVALID; | return TOPOLOGY_INVALID; | ||||
| } | |||||
| const int symbol_id = context_symbols_[active_context_][context_counter]; | const int symbol_id = context_symbols_[active_context_][context_counter]; | ||||
| last_symbol_ = edge_breaker_symbol_to_topology_id[symbol_id]; | last_symbol_ = edge_breaker_symbol_to_topology_id[symbol_id]; | ||||
| } else { | } else { | ||||
| #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | ||||
| if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { | if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { | ||||
| // We don't have a predicted symbol or the symbol was mis-predicted. | // We don't have a predicted symbol or the symbol was mis-predicted. | ||||
| // Decode it directly. | // Decode it directly. | ||||
| last_symbol_ = MeshEdgebreakerTraversalDecoder::DecodeSymbol(); | last_symbol_ = MeshEdgebreakerTraversalDecoder::DecodeSymbol(); | ||||
| ▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines | |||||