annotate src/libvorbis-1.3.3/doc/vorbisfile/crosslap.html @ 83:ae30d91d2ffe

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