Gagravarr / VorbisJava

A library for working with Ogg Vorbis files
Apache License 2.0
126 stars 26 forks source link

OggPacketWriter allows no correct GP setting on continuation pages #15

Closed andrm closed 8 years ago

andrm commented 9 years ago

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).

Gagravarr commented 9 years ago

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 9 years ago

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

Gagravarr commented 9 years ago

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?