Gagravarr/VorbisJava

OggPacketWriter allows no correct GP setting on continuation pages

Closed this issue · 3 comments

andrm commented

When adding a packet to a OggPacketWriter instance, the current page checks whether the lacing value list is full (numLVs > 255) or if the packet is the last one on this page (numLVs == 255) and the packet can't be written fully on the page. OggPacketWriter then starts a new page and sets the continuation bit. No flush is called in this situation. This means the granulePosition of the old and the new page will be the same at the next flush, there is no control of setting the gp on these pages afterwards.
This is ok for large packets (>64kb), but not for other uses like transcoding and changing the latency (maximum ogg page sizes).

Do you have any thoughts on the best way to solve this? Perhaps following the same approach as in the C library, if that's possible?

andrm commented

My commit bb78fc8 in my pull request addresses this. The old page will have the old gp, the new one the supplied gp.

Thanks!

Slightly tweaked version of your commit, with unit tests and handling of packets that span 3+ pages, done as 6561136 and a8a3a07. Does that look right to you?