Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add tag_tree.rs implementation#70

Merged
iszak merged 4 commits intoiszak:mainfrom
Lanzaa:tag_tree
Dec 17, 2025
Merged

Add tag_tree.rs implementation#70
iszak merged 4 commits intoiszak:mainfrom
Lanzaa:tag_tree

Conversation

@Lanzaa
Copy link
Collaborator

@Lanzaa Lanzaa commented Dec 10, 2025

Added a tag tree decoder implementation as described in B.10.2. This is another step towards decoding packets and tiles.

Copy link
Owner

@iszak iszak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request.

This implementation looks correct, although I had to read T.800 B.10.2 few times as it's terse and hard to follow, I'm not sure I could have implemented it with that example alone.

I think a few simpler test cases may help (e.g. 1 level, 2 level, 3 level) but I understand it's not easy to create. I also think an intermediate representation could help usability but likely at the cost of performance.

Have a think and let me know if you want to make these improvements, otherwise we can merge as is.

}

// TODO fix push_bit type signature for better return type
pub fn push_bit(&mut self, b: u8) -> Option<u8> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this signature could be better since we're not efficiently reading in the maximum amount of bits at a time. Is it possible to use a bit operator to read each bit in the u8?

Also I think we will need a encode method too to take a tag tree representation and write it to bits, so we may want an intermediate representation of the tag tree that's more user friendly and that will also allow us to query it to request the value at qi(m, n) which I don't think is currently implemented? This could also be used to better test the decoding as I don't think currently we validate/assert the node values at the lower levels

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of tag trees is pretty complex. There are several different things happening at once. I'm not sure what interface with the tag tree would be the most ergonomic. I'm planning to evolve things as the code surrounding tag tree use is written.

As far as encoding goes, the tag tree represents a 2d array of numbers. So an interface that takes a 2d array of numbers and spits out bits is probably what is needed for a first version.

* Add more testing for tag_tree
* Fix bug when filling out full tag_tree
* Change tag_tree interface to use bool
* Cleanup: cw->_cw
* Cleanup: println -> info
* Improve logging for tag_tree
* Include env-logger for test logging
@iszak iszak merged commit 21dc273 into iszak:main Dec 17, 2025
4 checks passed
@Lanzaa
Copy link
Collaborator Author

Lanzaa commented Dec 17, 2025

I think the code is ready now. Let me know if you want more changes.

I think a few simpler test cases may help

Added two new test cases. One of which helped me find a bug.

I also think an intermediate representation could help usability but likely at the cost of performance.

I'm not sure what you mean by this.

@Lanzaa Lanzaa deleted the tag_tree branch December 17, 2025 22:42
@iszak
Copy link
Owner

iszak commented Dec 17, 2025

Thanks for making the changes, I've merged it in. The intermediate implementation idea was a non-bit array representation of the tree e.g. with node structs but given there's a little more work to be done it can be looked at later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants