On Tuesday 28 October 2003 18:49, Joshua Haberman wrote:> Hello again. If you recall, I am the guy working on enabling Audacity
> to losslessly rearrange Ogg Vorbis files for my senior thesis. I have
> more or less completed the required modifications to Audacity to support
> this. You can read more about the work this entailed by reading my
> journal:
>
> http://www.reverberate.org/computers/thesis/journal
>
> Now my attention moves to the Ogg Vorbis code necessary to do all this
> splicing. From reading the Ogg documentation and the vcut source I have
> a good understanding of the Ogg format and how I will go about
> rearranging Vorbis packets. However I have a few questions I would like
> to clarify:
>
> 1. how exactly will the overlap/add nature of Vorbis packets affect me
> as I attempt to rearrange them? Is it correct to say that for any
> Vorbis packet I take from an existing stream (other than the first
> packet) I must also take the packet preceding it?
Yes. The reason that the first packet is an exception here is that it produces
no output audio (because the overlap is _always_ required).
>
> 2. When I am grabbing an extra preceding packet as described above,
> should I set the granulepos of this preceding packet to 0 so that this
> packet itself does not produce any sample data? Will that confuse the
> decoder if this is in the middle of a stream?
You must always have monotonically increasing granulepos values (with the
exception of -1 indicating no packet ending on that page). So no, you
shouldn't just set a granulepos to zero, except at start-of-stream.
>
> 3. I notice that you can get decoders to discard some of the samples
> from the end of a packet by subtracting from the granulepos the number
> of samples you want discarded. A similar way to do this for discarding
> samples from the beginning of a packet (used by vcut) is to set the
> granulepos to -x, where x is the number of samples you want discarded
> from the beginning. But will this work in the middle of a stream, where
> the granulepos should reflect the total sample offset of the stream?
No, a negative granulepos (other than -1) is undefined. libvorbis treats all
negative granulepos values as equivalent to -1, though, I think.
This only works at the beginning and end of stream, never in the middle. See
the spec for exact details on how to do this, but in summary: you give a
'short' (less than it would naturally be, greater than zero) granulepos
for
the final page.
>
> 4. Is it just a special case that it is not possible to discard one
> sample from the beginning of a block using this method, since -1 implies
> that no packets finish in this block?
No, see above.
Mike
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to
'vorbis-dev-request@xiph.org'
containing only the word 'unsubscribe' in the body. No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.