From 4efc3d27cc301971e1683e1bf3328eae84e25702 Mon Sep 17 00:00:00 2001 From: Frank Galligan Date: Sat, 22 Jul 2017 22:35:54 -0700 Subject: [PATCH] Update bitstream spec This PR is associated with #134. --- docs/spec/attributes.decoder.md | 2 +- docs/spec/draco.decoder.md | 5 +- docs/spec/edgebreaker.decoder.md | 45 +++++++--------- docs/spec/edgebreaker.hole.and.topology.md | 12 ++--- docs/spec/edgebreaker.traversal.decoder.md | 8 +-- .../edgebreaker.traversal.valence.decoder.md | 16 +++--- docs/spec/index.md | 3 +- docs/spec/mesh.decoder.md | 9 ---- .../mesh.prediction.scheme.parallelogram.md | 6 +-- docs/spec/metadata.decoder.md | 52 +++++++++++++++++++ docs/spec/rans.bit.decoder.md | 4 +- docs/spec/rans.decoding.md | 6 +-- ...quential.quantization.attribute.decoder.md | 4 +- docs/spec/symbol.decoding.md | 21 ++------ docs/spec/variable.descriptions.md | 8 +++ 15 files changed, 118 insertions(+), 83 deletions(-) create mode 100644 docs/spec/metadata.decoder.md create mode 100644 docs/spec/variable.descriptions.md diff --git a/docs/spec/attributes.decoder.md b/docs/spec/attributes.decoder.md index 32eaa36..f88355a 100644 --- a/docs/spec/attributes.decoder.md +++ b/docs/spec/attributes.decoder.md @@ -5,7 +5,7 @@ ~~~~~ DecodeAttributesDecoderData(buffer) { - num_attributes I32 + num_attributes varUI32 point_attribute_ids_.resize(num_attributes); for (i = 0; i < num_attributes; ++i) { att_type UI8 diff --git a/docs/spec/draco.decoder.md b/docs/spec/draco.decoder.md index 7cb3cc5..c94112b 100644 --- a/docs/spec/draco.decoder.md +++ b/docs/spec/draco.decoder.md @@ -5,8 +5,11 @@ ~~~~~ Decode() { DecodeHeader() + if (flags & METADATA_FLAG_MASK) + DecodeGeometryMetadata(metadata) DecodeConnectivityData() - DecodeAttributeData()} + DecodeAttributeData() +} ~~~~~ {:.draco-syntax} diff --git a/docs/spec/edgebreaker.decoder.md b/docs/spec/edgebreaker.decoder.md index 11baa85..df34860 100644 --- a/docs/spec/edgebreaker.decoder.md +++ b/docs/spec/edgebreaker.decoder.md @@ -1,31 +1,22 @@ ## EdgeBreaker Decoder -### InitializeDecoder() +### DecodeConnectivityData() ~~~~~ -InitializeDecoder() { - edgebreaker_decoder_type UI8 -} -~~~~~ -{:.draco-syntax } - - -### DecodeConnectivity() - -~~~~~ -DecodeConnectivity() { - num_new_verts UI32 - num_encoded_vertices UI32 - num_faces UI32 +DecodeConnectivityData() { + edgebreaker_traversal_type UI8 + num_new_verts varUI32 + num_encoded_vertices varUI32 + num_faces varUI32 num_attribute_data I8 - num_encoded_symbols UI32 - num_encoded_split_symbols UI32 - encoded_connectivity_size UI32 + num_encoded_symbols varUI32 + num_encoded_split_symbols varUI32 + encoded_connectivity_size varUI32 // file pointer must be set to current position // + encoded_connectivity_size hole_and_split_bytes = DecodeHoleAndTopologySplitEvents() // file pointer must be set to old current position - EdgeBreakerTraversalValence_Start() + EdgeBreakerTraversalValence_Start(num_encoded_vertices) DecodeConnectivity(num_symbols) if (attribute_data_.size() > 0) { for (ci = 0; ci < corner_table_->num_corners(); ci += 3) { @@ -39,11 +30,12 @@ DecodeConnectivity() { } // Decode attribute connectivity. for (uint32_t i = 0; i < attribute_data_.size(); ++i) { - attribute_data_[i].connectivity_data.InitEmpty(corner_table_.get()); + attribute_data_[i].connectivity_data.InitEmpty(corner_table_); for (int32_t c : attribute_data_[i].attribute_seam_corners) { attribute_data_[i].connectivity_data.AddSeamEdge(c); } - attribute_data_[i].connectivity_data.RecomputeVertices(nullptr, nullptr); + attribute_data_[i].connectivity_data.RecomputeVertices(nullptr, + nullptr); } // Preallocate vertex to value mapping AssignPointsToCorners() @@ -83,7 +75,8 @@ AssignPointsToCorners() { act_c = corner_table_->SwingRight(c); seam_found = false; while (act_c != c) { - if (attribute_data_[i].connectivity_data.Vertex(act_c) != vert_id) { + if (attribute_data_[i].connectivity_data.Vertex(act_c) != + vert_id) { deduplication_first_corner = act_c; seam_found = true; break; @@ -150,12 +143,12 @@ DecodeConnectivity(num_symbols) { check_topology_split = true; } active_corner_stack.back() = corner; - traversal_decoder_.NewActiveCornerReached(corner); + traversal_decoder_.NewActiveCornerReached(corner); if (check_topology_split) { encoder_symbol_id = num_symbols - symbol_id - 1; while (true) { split = IsTopologySplit(encoder_symbol_id, &split_edge, - &encoder_split_symbol_id); + &encoder_split_symbol_id); if (!split) { break; } @@ -165,7 +158,8 @@ DecodeConnectivity(num_symbols) { } else { new_active_corner = corner_table_->Previous(act_top_corner); } - decoder_split_symbol_id = num_symbols - encoder_split_symbol_id - 1; + decoder_split_symbol_id = num_symbols - + encoder_split_symbol_id - 1; topology_split_active_corners[decoder_split_symbol_id] = new_active_corner; } @@ -186,7 +180,6 @@ DecodeConnectivity(num_symbols) { init_corners_.push_back(corner); } } - Return num_vertices; } ~~~~~ {:.draco-syntax } diff --git a/docs/spec/edgebreaker.hole.and.topology.md b/docs/spec/edgebreaker.hole.and.topology.md index 5e3ae03..5aa6b36 100644 --- a/docs/spec/edgebreaker.hole.and.topology.md +++ b/docs/spec/edgebreaker.hole.and.topology.md @@ -6,25 +6,25 @@ ~~~~~ DecodeHoleAndTopologySplitEvents() { - num_topologoy_splits UI32 + num_topologoy_splits varUI32 source_symbol_id = 0 for (i = 0; i < num_topologoy_splits; ++i) { - DecodeVarint(&delta) + delta varUI32 split_data[i].source_symbol_id = delta + source_symbol_id - DecodeVarint(&delta) + delta varUI32 split_data[i].split_symbol_id = source_symbol_id - delta } for (i = 0; i < num_topologoy_splits; ++i) { split_data[i].split_edge bits1 split_data[i].source_edge bits1 } - num_hole_events UI32 + num_hole_events varUI32 symbol_id = 0 for (i = 0; i < num_hole_events; ++i) { - DecodeVarint(&delta) + delta varUI32 hole_data[i].symbol_id = delta + symbol_id } - return bytes_decoded; + return bytes_decoded; } ~~~~~ {:.draco-syntax } diff --git a/docs/spec/edgebreaker.traversal.decoder.md b/docs/spec/edgebreaker.traversal.decoder.md index 87658b6..5871574 100644 --- a/docs/spec/edgebreaker.traversal.decoder.md +++ b/docs/spec/edgebreaker.traversal.decoder.md @@ -9,10 +9,10 @@ EdgebreakerTraversal_Start() { symbol_buffer_ size * UI8 size UI64 start_face_buffer_ size * UI8 - if (num_attribute_data_ > 0) { - attribute_connectivity_decoders_ = std::unique_ptr( - new BinaryDecoder[num_attribute_data_]); - for (i = 0; i < num_attribute_data_; ++i) { + if (num_attribute_data > 0) { + attribute_connectivity_decoders_ = + new BinaryDecoder[num_attribute_data] + for (i = 0; i < num_attribute_data; ++i) { attribute_connectivity_decoders_[i].StartDecoding() // RansBitDecoder_StartDecoding } diff --git a/docs/spec/edgebreaker.traversal.valence.decoder.md b/docs/spec/edgebreaker.traversal.valence.decoder.md index 444ed94..a4d0e6e 100644 --- a/docs/spec/edgebreaker.traversal.valence.decoder.md +++ b/docs/spec/edgebreaker.traversal.valence.decoder.md @@ -4,24 +4,22 @@ ### EdgeBreakerTraversalValence_Start() ~~~~~ -EdgeBreakerTraversalValence_Start(num_vertices, num_attribute_data) { - out_buffer = EdgebreakerTraversal_Start() - num_split_symbols I32 +EdgeBreakerTraversalValence_Start(traversal_num_vertices) { + EdgebreakerTraversal_Start() + num_split_symbols varUI32 mode == 0 I8 - num_vertices_ += num_split_symbols + traversal_num_vertices += num_split_symbols vertex_valences_ init to 0 - vertex_valences_.resize(num_vertices_, 0); min_valence_ = 2; max_valence_ = 7; num_unique_valences = 6 (max_valence_ - min_valence_ + 1) for (i = 0; i < num_unique_valences; ++i) { - DecodeVarint(&num_symbols, out_buffer) - If (num_symbols > 0) { - DecodeSymbols(num_symbols, out_buffer, &context_symbols_[i]) + num_symbols varUI32 + if (num_symbols > 0) { + DecodeSymbols(num_symbols, context_symbols_[i]) } context_counters_[i] = num_symbols } - return out_buffer; } ~~~~~ {:.draco-syntax } diff --git a/docs/spec/index.md b/docs/spec/index.md index 28c6157..1dff333 100644 --- a/docs/spec/index.md +++ b/docs/spec/index.md @@ -17,6 +17,7 @@ version_date: Released 2017-xx-xx {% include_relative 03.00.00.symbols.md %} {% include_relative 04.00.00.conventions.md %} {% include_relative draco.decoder.md %} +{% include_relative metadata.decoder.md %} {% include_relative mesh.decoder.md %} {% include_relative edgebreaker.decoder.md %} {% include_relative edgebreaker.hole.and.topology.md %} @@ -40,7 +41,7 @@ version_date: Released 2017-xx-xx {% include_relative rans.decoding.md %} {% include_relative rans.bit.decoder.md %} {% include_relative core.functions.md %} - +{% include_relative variable.descriptions.md %} {% comment %} {% include_relative 99.00.01.testing.md %} diff --git a/docs/spec/mesh.decoder.md b/docs/spec/mesh.decoder.md index 47d57bf..0f7ae9f 100644 --- a/docs/spec/mesh.decoder.md +++ b/docs/spec/mesh.decoder.md @@ -1,11 +1,2 @@ ## Mesh Decoder -### DecodeConnectivityData() - -~~~~~ -DecodeConnectivityData() - InitializeDecoder() - DecodeConnectivity() -} -~~~~~ -{:.draco-syntax } diff --git a/docs/spec/mesh.prediction.scheme.parallelogram.md b/docs/spec/mesh.prediction.scheme.parallelogram.md index bdf0783..a368d7f 100644 --- a/docs/spec/mesh.prediction.scheme.parallelogram.md +++ b/docs/spec/mesh.prediction.scheme.parallelogram.md @@ -7,7 +7,7 @@ Decode(...) { this->transform().InitializeDecoding(num_components); // restore the first value - this->transform().ComputeOriginalValue(pred_vals.get(), + this->transform().ComputeOriginalValue(pred_vals, in_corr, out_data, 0); // PredictionSchemeWrapTransform_ComputeOriginalValue() corner_map_size = this->mesh_data().data_to_corner_map()->size(); @@ -16,14 +16,14 @@ Decode(...) { dst_offset = p * num_components; b= ComputeParallelogramPrediction(p, corner_id, table, *vertex_to_data_map, out_data, - num_components, pred_vals.get()) + num_components, pred_vals) if (!b) { src_offset = (p - 1) * num_components; this->transform().ComputeOriginalValue(out_data + src_offset, in_corr, out_data + dst_offset, dst_offset); // PredictionSchemeWrapTransform_ComputeOriginalValue() } else { - this->transform().ComputeOriginalValue(pred_vals.get(), in_corr, + this->transform().ComputeOriginalValue(pred_vals, in_corr, out_data + dst_offset, dst_offset); // PredictionSchemeWrapTransform_ComputeOriginalValue() } diff --git a/docs/spec/metadata.decoder.md b/docs/spec/metadata.decoder.md new file mode 100644 index 0000000..a055258 --- /dev/null +++ b/docs/spec/metadata.decoder.md @@ -0,0 +1,52 @@ +## Metadata Decoder + +### DecodeGeometryMetadata() + +~~~~~ +DecodeGeometryMetadata(metadata) { + num_att_metadata varUI32 + for (i = 0; i < num_att_metadata; ++i) { + att_id varUI32 + att_metadata = new AttributeMetadata(att_id) + DecodeMetadata(att_metadata) + metadata.att_metadata.push_back(att_metadata) + } + DecodeMetadata(metadata) +} +~~~~~ +{:.draco-syntax} + + +### DecodeMetadata() + +~~~~~ +DecodeMetadata(metadata) { + num_entries varUI32 + for (i = 0; i < num_entries; ++i) { + DecodeEntry(metadata) + } + num_sub_metadata varUI32 + for (i = 0; i < num_sub_metadata; ++i) { + size UI8 + name size * UI8 + temp_metadata = new Metadata() + DecodeMetadata(temp_metadata) + metadata.sub_metadata[name] = temp_metadata + } +} +~~~~~ +{:.draco-syntax} + + +### DecodeEntry() + +~~~~~ +DecodeEntry(metadata) { + size UI8 + name size * UI8 + size varUI32 + value size * UI8 + metadata.entries.insert(name, value) +} +~~~~~ +{:.draco-syntax} diff --git a/docs/spec/rans.bit.decoder.md b/docs/spec/rans.bit.decoder.md index 595c21e..605297b 100644 --- a/docs/spec/rans.bit.decoder.md +++ b/docs/spec/rans.bit.decoder.md @@ -4,11 +4,11 @@ ### RansBitDecoder_StartDecoding() ~~~~~ -RansBitDecoder_StartDecoding(DecoderBuffer *source_buffer) { +RansBitDecoder_StartDecoding() { prob_zero_ UI8 size UI32 buffer_ size * UI8 - ans_read_init(&ans_decoder_, buffer_, size) + ans_read_init(ans_decoder_, buffer_, size) } ~~~~~ {:.draco-syntax } diff --git a/docs/spec/rans.decoding.md b/docs/spec/rans.decoding.md index c5cb358..11b62a8 100644 --- a/docs/spec/rans.decoding.md +++ b/docs/spec/rans.decoding.md @@ -4,8 +4,7 @@ ### ans_read_init() ~~~~~ -ans_read_init(struct AnsDecoder *const ans, const uint8_t *const buf, - int offset) { +ans_read_init(AnsDecoder ans, buf, int offset) { x = buf[offset - 1] >> 6 If (x == 0) { ans->buf_offset = offset - 1; @@ -17,8 +16,7 @@ ans_read_init(struct AnsDecoder *const ans, const uint8_t *const buf, ans->buf_offset = offset - 3; ans->state = mem_get_le24(buf + offset - 3) & 0x3FFFFF; } else if (x == 3) { - // x == 3 implies this byte is a superframe marker - return 1; + // ERROR } ans->state += l_base; } diff --git a/docs/spec/sequential.quantization.attribute.decoder.md b/docs/spec/sequential.quantization.attribute.decoder.md index 692cf9b..030733b 100644 --- a/docs/spec/sequential.quantization.attribute.decoder.md +++ b/docs/spec/sequential.quantization.attribute.decoder.md @@ -13,6 +13,7 @@ Initialize(...) { ~~~~~ DecodeIntegerValues(point_ids) { + // REMOVE < DRACO_BITSTREAM_VERSION(2, 0) // DecodeQuantizedDataInfo() num_components = attribute()->components_count(); for (i = 0; i < num_components; ++i) { @@ -20,6 +21,7 @@ DecodeIntegerValues(point_ids) { } max_value_dif_ F32 quantization_bits_ UI8 + // REMOVE < DRACO_BITSTREAM_VERSION(2, 0) SequentialIntegerAttributeDecoder::DecodeIntegerValues() } ~~~~~ @@ -41,7 +43,7 @@ DequantizeValues(num_values) { value = value + min_value_[c]; att_val[c] = value; } - attribute()->buffer()->Write(out_byte_pos, att_val.get(), entry_size); + attribute()->buffer()->Write(out_byte_pos, att_val, entry_size); out_byte_pos += entry_size; } } diff --git a/docs/spec/symbol.decoding.md b/docs/spec/symbol.decoding.md index 084187d..6f2c10c 100644 --- a/docs/spec/symbol.decoding.md +++ b/docs/spec/symbol.decoding.md @@ -4,12 +4,12 @@ ### DecodeSymbols() ~~~~~ -DecodeSymbols(num_symbols, out_buffer, out_values) { +DecodeSymbols(num_symbols, out_values) { scheme UI8 If (scheme == 0) { - DecodeTaggedSymbols<>(num_symbols, src_buffer, out_values) + DecodeTaggedSymbols(num_symbols, out_values) } else if (scheme == 1) { - DecodeRawSymbols<>(num_symbols, src_buffer, out_values) + DecodeRawSymbols(num_symbols, out_values) } } ~~~~~ @@ -29,19 +29,8 @@ DecodeTaggedSymbols() { ### DecodeRawSymbols() ~~~~~ -DecodeRawSymbols() { +DecodeRawSymbols(num_values, out_values) { max_bit_length UI8 - DecodeRawSymbolsInternal(max_bit_length, out_values) - return symbols -} -~~~~~ -{:.draco-syntax } - - -### DecodeRawSymbolsInternal() - -~~~~~ -DecodeRawSymbolsInternal(max_bit_length, out_values) { decoder = CreateRansSymbolDecoder(max_bit_length) decoder.StartDecoding() // RansSymbolDecoder_StartDecoding @@ -103,7 +92,7 @@ RansSymbolDecoder_StartDecoding() { ~~~~~ RansSymbolDecoder_DecodeSymbol() { - ans_.rans_read() + return ans_.rans_read() } ~~~~~ {:.draco-syntax } diff --git a/docs/spec/variable.descriptions.md b/docs/spec/variable.descriptions.md new file mode 100644 index 0000000..4ba3454 --- /dev/null +++ b/docs/spec/variable.descriptions.md @@ -0,0 +1,8 @@ +## Descriptions + +### Variabless + + * edgebreaker_traversal_type + * 0: MeshEdgeBreakerTraversalDecoder + * 1: MeshEdgeBreakerTraversalPredictiveDecoder + * 2: MeshEdgeBreakerTraversalValenceDecoder