annotate src/libvorbis-1.3.3/doc/vorbisfile/crosslap.html @ 169:223a55898ab9 tip default

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