crosslap.html 5.2 KB

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