-
Notifications
You must be signed in to change notification settings - Fork 26
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
get_last_absgp returns None for the first stream #84
Comments
The code you link to is not the only place that updates the absolute granule position, it is also updated at page boundaries, which occur more often. https://github.com/RustAudio/lewton/blob/master/src/inside_ogg.rs#L198 Quoting the vorbis spec:
Actually you bring up a good point, I might need to change the code that updates cur_absgp unconditionally on a new stream and only update it if it's the last packet finished on the page. |
Thanks. I'll learn more about ogg and Vorbis formats and consider if I can contribute. |
I now understood the structure of ogg/Vorbis and clearly figured out the reason. The "absolute granule position" is virtually the last index of decoded sample, defined per page, so we cannot determine the position until we finish parsing the first page. However, I don't think it's a good idea to update Instead, I suggest that the decoder reads the entire packets in the first page where the first packet ends, and then calculate the appropriate
By the way IMHO the name |
I also realized that updating |
This would likely need some ability to "peek" future packets in the Ogg crate. We are only interested about packets finishing on the same page the packet finishes. So we don't need complicated fragmented packet logic, all such packets would be inside the same page. Once we have that peeking ability we can use
Good idea, should be done!
Yes, that's what I said in my comment above |
I think this can still be resolved without "peeking" feature. Instead, the decoder can store the packets it obtained and use it later. Possible drawback is that the packets are unnecessarily moved from the Ogg reader to Vorbis decoder (which I actually think is small enough). Which do you think is the better way?
Oh, excuse me. |
The following is a snippet that reads first 30 packets from an ogg file.
It is reasonable that
get_last_absgp
returns None before reading any packet, but the program above actually output 23 Nones, followed by 7 reasonable values. Reading the code, I realized thatcur_absgp
is never updated for the first stream, but updated for the second and subsequent streams. Is this an intended behaviour, or just a bug?The text was updated successfully, but these errors were encountered: