[vorbis] Low bitrate encoding
Beni Cherniavsky
cben at crosswinds.net
Tue Jan 9 05:48:20 PST 2001
jaromil wrote:
>
> On Tue, Jan 09, 2001 at 01:31:39PM +0100, Olaf van der Spek wrote:
> > >
> > > that's not exact... more than averaging it's a stretching operation.
> > > assuming 16bit samples i would do it like that:
> >
> > This means you just discard half of the samples.
>
> yes
> there's some better way to do it, but it's cpu intensive and imho it's not
> worthwhile
>
> on my side, i take care of performance: muse is a live engine
>
I'm not a signal proc. exprert at all but I think that averaging will
still give higher quality than discarding half of the samples, without
serious performance difference. Discarding shold create strong
alising problems. Averaging is a downpass filter, surely not ideal
but it should help somewhat.
> > >
> > > /* downsampling >>1 */
> > >
> > > for(i=src_length>>2;i;--i) {
> > > dst[0] = src[0];
> > > dst[1] = src[1];
> > > src += 4;
> > > dst += 2;
> > > }
This seems strange: of evry 4 samples 0,1,2,3 it leaves 0,1 and
discards 2,3. Is this for interleaved stereo? If not does this
have some filtering effect that's better than leaving 0,2 and
discrading 1,3?
> >
> > What about this?
> > for(i=src_length>>1;i;--i) {
> > dst[0] = src[0] + src[1];
> > src += 2;
> > dst++;
> > }
>
This will overflow: the result range is twice the source range.
Dividing by 2 should be done after the addition, to save some
quality, but we can't do it unless we store the intermediate sum
in a longer type (shouldn't be a big problem - it's all in
registers anyway) but there is a way around: what we lose if we
divide by 2 before the addition is the case when both inputs have
1 in the lsb. Lets restore it:
for(i=src_length>>1;i;--i) {
dst[0] = (src[0] >> 1) + (src[1] >> 1) + (src[0] & src[1] & 1);
src += 2;
dst++;
}
This is equavalent to `dst[0] = ((long)src[0] + (long)src[1]) >> 1'.
You still get a half unit down DC bias because of the rounding
but this is hardly a problem (an almost unavoidable).
Actually you can rescue the extra bit lost in shifting (to have
the downsampled data have 1 bit higher dynamic range than the
original data) by putting it in by error diffussion. This would
come at the cost of some high-freq noise. In any case this is a
fight over quality of a worng signal - we only do averaging if go
for speed; filtering would use a long intermediate.
> uhm. i guess we should simply try those. i cannot atm, i'm not at home far
> from my machines. keep me informed about what you get if you try.
> i'll be testing this starting from next monday.
>
--
Beni Cherniavsky <cben at crosswinds.net>
(also scben at t2,cben at tx in Technion)
No, No! You're not thinking; you're just being logical.
- Niels Bohr
--- >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-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis
mailing list