Jean-Marc, What exactly does the speex code do to calculate the granulepos? With vorbis it's the 'count of decodable samples including this packet'. So if you had a packet that allowed you to decode 1024 samples since the beginning of playback, the granulepos is 1024, not for example 1023 which would be the *index* of the last sample assuming C-style array indicies starting at 0. Put another way, if you had a speex stream that encoded only one sample in one packet in one page, what would be the granulepos of that page? I'm trying to figure out (with Thomas and Conrad) what all the codec implementations actually do so we can nail down the spec and/or best practices a little better. -r
Hi Ralph, What speexenc does (Speex itself does not know about Ogg) is that it gives packet N the granulepos "N*frame_size - lookahead". In the case of narrowband, the first frame would have granulepos "1*160 - 80", so 80. I can't say about your example because Speex cannot encode a frame of one sample, which is a good thing becuse otherwise, the granulepos would be -79. BTW, the reason for the "- lookahead" is that it allows gapless playback (because the first samples in the first frame are zeros). Hope that clarifies things (and doesn't break too much stuff). Jean-Marc Selon Ralph Giles <giles@xiph.org>:> Jean-Marc, > > What exactly does the speex code do to calculate the granulepos? With > vorbis it's the 'count of decodable samples including this packet'. So > if you had a packet that allowed you to decode 1024 samples since the > beginning of playback, the granulepos is 1024, not for example 1023 > which would be the *index* of the last sample assuming C-style array > indicies starting at 0. > > Put another way, if you had a speex stream that encoded only one sample > in one packet in one page, what would be the granulepos of that page? > > I'm trying to figure out (with Thomas and Conrad) what all the codec > implementations actually do so we can nail down the spec and/or best > practices a little better. > > -r > _______________________________________________ > Speex-dev mailing list > Speex-dev@xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev > >
On Sun, Jun 19, 2005 at 08:07:50PM -0400, Jean-Marc Valin wrote:> Hi Ralph, > > What speexenc does (Speex itself does not know about Ogg) is that it gives > packet N the granulepos "N*frame_size - lookahead". In the case of narrowband, > the first frame would have granulepos "1*160 - 80", so 80. I can't say about > your example because Speex cannot encode a frame of one sample, which is a good > thing becuse otherwise, the granulepos would be -79. BTW, the reason for the "- > lookahead" is that it allows gapless playback (because the first samples in the > first frame are zeros). Hope that clarifies things (and doesn't break too much > stuff).so is the following correct, for the example you gave (narrowband): 1) decoding the first packet produces 80 samples, and it has a granulepos of 80. 2) decoding any subsequent packet produces 160 samples, and has a granuelpos "N*160 - 80" ? Conrad.