Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/libvorbis-1.2.0/doc/vorbisfile/crosslap.html @ 16

Last change on this file since 16 was 16, checked in by landauf, 16 years ago

added libvorbis

File size: 5.2 KB
Line 
1<html>
2
3<head>
4<title>Vorbisfile - Sample Crosslapping</title>
5<link rel=stylesheet href="style.css" type="text/css">
6</head>
7
8<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
9<table border=0 width=100%>
10<tr>
11<td><p class=tiny>Vorbisfile documentation</p></td>
12<td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
13</tr>
14</table>
15
16<h1>What is Crosslapping?</h1>
17
18<p>Crosslapping blends two samples together using a window function,
19such that any sudden discontinuities between the samples that may
20cause clicks or thumps are eliminated or blended away.  The technique
21is nearly identical to how Vorbis internally splices together frames
22of audio data during normal decode.  API functions are provided to <a
23href="ov_crosslap.html">crosslap transitions between seperate
24streams</a>, or to crosslap when <a href="seeking.html">seeking within
25a single stream</a>.
26
27<h1>Why Crosslap?</h1>
28<h2>The source of boundary clicks</h2>
29
30<p>Vorbis is a lossy compression format such that any compressed
31signal is at best a close approximation of the original.  The
32approximation may be very good (ie, indistingushable to the human
33ear), but it is an approximation nonetheless.  Even if a sample or set
34of samples is contructed carefully such that transitions from one to
35another match perfectly in the original, the compression process
36introduces minute amplitude and phase errors.  It's an unavoidable
37result of such high compression rates.
38
39<p>If an application transitions instantly from one sample to another,
40any tiny discrepancy introduced in the lossy compression process
41becomes audible as a stairstep discontinuity.  Even if the discrepancy
42in a normal lapped frame is only .1dB (usually far below the
43threshhold of perception), that's a sudden cliff of 380 steps in a 16
44bit sample (when there's a boundary with no lapping).
45
46<h2>I thought Vorbis was gapless</h2>
47
48<p>It is.  Vorbis introduces no extra samples at the beginning or end
49of a stream, nor does it remove any samples.  Gapless encoding
50eliminates 99% of the click, pop or outright blown speaker that would
51occur if boundaries had gaps or made no effort to align
52transitions. However, gapless encoding is not enough to entirely
53eliminate stairstep discontinuities all the time for exactly the
54reasons described above.
55
56<p>Frame lapping, like Vorbis performs internally during continuous
57playback, is necessary to eliminate that last epsilon of trouble.
58
59<h1>Easiest Crosslap</h1>
60
61The easiest way to perform crosslapping in Vorbis is to use the
62lapping functions with no other extra effort.  These functions behave
63identically to when lapping isn't used except to provide
64at-least-very-good lapping results.  Crosslapping will not introduce
65any samples into or remove any samples from the decoded audio; the
66only difference is that the transition is lapped.  Lapping occurs from
67the current PCM position (either in the old stream, or at the position
68prior to calling a lapping seek) forward into the next
69half-short-block of audio data to be read from the new stream or
70position.
71
72<p>Ideally, vorbisfile internally reads an extra frame of audio from
73the old stream/position to perform lapping into the new
74stream/position.  However, automagic crosslapping works properly even
75if the old stream/position is at EOF. In this case, the synthetic
76post-extrapolation generated by the encoder to pad out the last block
77with appropriate data (and avoid encoding a stairstep, which is
78inefficient) is used for crosslapping purposes.  Although this is
79synthetic data, the result is still usually completely unnoticable
80even in careful listening (and always preferable to a click or pop).
81
82<p>Vorbisfile will lap between streams of differing numbers of
83channels. Any extra channels from the old stream are ignored; playback
84of these channels simply ends. Extra channels in the new stream are
85lapped from silence.  Vorbisfile will also lap between streams links
86of differing sample rates.  In this case, the sample rates are ignored
87(no implicit resampling is done to match playback). It is up to the
88application developer to decide if this behavior makes any sense in a
89given context; in practical use, these default behaviors perform
90sensibly.
91
92<h1>Best Crosslap</h1>
93
94<p>To acheive the best possible crosslapping results, avoid the case
95where synthetic extrapolation data is used for crosslapping.  That is,
96design loops and samples such that a little bit of data is left over
97in sample A when seeking to sample B.  Normally, the end of sample A
98and the beginning of B would overlap exactly; this allows
99crosslapping to perform exactly as it would within vorbis when
100stitching audio frames together into continuous decoded audio.
101
102<p>The optimal amount of overlap is half a short-block, and this
103varies by compression mode.  Each encoder will vary in exact block
104size selection; for vorbis 1.0, for -q0 through -q10 and 44kHz or
105greater, a half-short block is 64 samples.
106
107<br><br>
108<hr noshade>
109<table border=0 width=100%>
110<tr valign=top>
111<td><p class=tiny>copyright &copy; 2007 Xiph.org</p></td>
112<td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
113</tr><tr>
114<td><p class=tiny>Vorbisfile documentation</p></td>
115<td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
116</tr>
117</table>
118
119</body>
120
121</html>
Note: See TracBrowser for help on using the repository browser.