Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for parsing the VLA header extension. #412

Merged
merged 4 commits into from
Dec 6, 2023

Conversation

pthatcher
Copy link
Collaborator

No description provided.

Copy link
Owner

@algesten algesten left a comment

Choose a reason for hiding this comment

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

Thanks!

Looks a bit expensive with the allocations (Vec, VecDequeue). I guess the header is not sent very often? Either way doesn't matter since we add it stand alone – can always optimize later.

@xnorpx
Copy link
Collaborator

xnorpx commented Dec 6, 2023

@algesten would you consider SmallVec? https://docs.rs/smallvec/latest/smallvec/

@algesten
Copy link
Owner

algesten commented Dec 6, 2023

Is there a theoretical max?

In the VP9-parser we just merged, we had fixed layer counts and thus could use arrays: https://github.com/algesten/str0m/pull/407/files#diff-b1299bad20a1ca94d8534b9fe54f6a3005f5e374c91b7f10c098836077733e74R271

@pthatcher
Copy link
Collaborator Author

pthatcher commented Dec 6, 2023

I don't think it's sent often enough to worry about perf at this point. I'd like to err on the side of correct and readable.

About theoretical maxes: they aren't realistic. You could theoretically have 5 simulcast streams and 4 spatial layers each, which is 20 spatial layers. But realistically you'd have 1 simulcast stream with 3 spatial layers or 3 simulcast streams with 1 spatial layer each, which is 3 spatial layers. If you went with u64s for each temporal layer, then that would be 40 bytes per spatial layer, or 800 bytes total. You could cut that in half by limiting bitrates to reasonable values, so 400 bytes. Plus the optional resolution and framerate, which are bytes, which would be another 60 bytes (860 or 460 total, depending if you use u64 or u32 for bitrates). Maybe that's not too big, but it feels somewhat large.

I still feel like this isn't something to worry about unless it shows up on a perf profile with real traffic, which I doubt it every will be.

@pthatcher
Copy link
Collaborator Author

I got rid of one VecDeque by using an Iterator. The other two could be theoretically be replaced with an array that has a maximum size. Those only exist in the parse function and would affect the size of the value returned.

@algesten
Copy link
Owner

algesten commented Dec 6, 2023

Sounds good! Let cargo fmt and merge!

@pthatcher
Copy link
Collaborator Author

pthatcher commented Dec 6, 2023

OK, I did cargo fmt and I added some comments about max sizes for a future developer that wants to use arrays instead of Vec/VecDeque.

@algesten algesten merged commit 8aa1aa1 into algesten:main Dec 6, 2023
22 checks passed
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.

None yet

3 participants