[Vorbis-dev] vcedit on non-vorbisI streams
Ian Malone
ibm21 at cam.ac.uk
Thu Nov 3 00:48:35 PST 2005
I've been looking at modifying vcedit so it will
work on Ogg streams containing primarily Vorbis
data (i.e. first page is the Vorbis header, most
pages are Vorbis and a few are something else
e.g. metadata or lyrics).
I've managed to get something that works by:
1. During the header opening in vcedit_open
push non-Vorbis pages onto a buffer added to
vcedit_state and write them out after the Vorbis
bos, but before the 2nd and 3rd headers. This
causes all bos to end up correctly at the start
of the stream. It does shuffle non-bos pages
before the end of the last Vorbis header about,
but in a sensible stream the relative order of
pages from different codecs at this point
shouldn't matter. (data is primarily Vorbis,
and we haven't started reading it yet here)
2. In vcedit_write it was necessary to change
_fetch_next_packet to compare serial numbers
before checking eos on a new page, and to check
bos on encountering a page not matching the
Vorbis serial number, returning success and
setting only extrapage if the different serial
number did not start a new stream. vcedit_write
was modified to check for extrapage without
eosin set, and to write the returned (non-Vorbis)
page if it found it.
There is a bug in this approach; if a non-Vorbis
page occurs after some Vorbis page A ending in an
incomplete packet, the non-Vorbis page will be
written before the rest of that packet is
retrieved from the next Vorbis page B to complete
page A. The non-Vorbis page will swap places with
page A. This is undesireable when vorbiscomment
could potentially be used many times on a given
stream.
Questions: Why does vcedit_write unpack the Vorbis
pages rather than just copying them through? The
Vorbis in Ogg spec says that header 3 should end
the page it finishes on, is the packet copying for
backwards compatibility?
Is this worth pursuing? I think I can fix the
wandering packets problem within the current packet
copying approach, but it requires introducing a
'page_waiting' variable into vcedit_write (and
buffering non-Vorbis pages again).
--
imalone
More information about the Vorbis-dev
mailing list