overview.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <html>
  2. <head>
  3. <title>libvorbis - API Overview</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>libvorbis documentation</p></td>
  10. <td align=right><p class=tiny>libvorbis version 1.3.2 - 20101101</p></td>
  11. </tr>
  12. </table>
  13. <h1>Libvorbis API Overview</h1>
  14. <p>Libvorbis is the reference implementation of the Vorbis codec. It is
  15. the lowest-level interface to the Vorbis encoder and decoder, working
  16. with packets directly.</p>
  17. <p>All libvorbis routines and structures are declared in "vorbis/codec.h".</p>
  18. <h2>Encoding workflow</h2>
  19. <ol>
  20. <li>Initialize a <a href="vorbis_info.html">vorbis_info</a> structure
  21. by calling <a href="vorbis_info_init.html">vorbis_info_init</a> and
  22. then functions from <a href="../vorbisenc/index.html">libvorbisenc</a>
  23. on it.</li>
  24. <li>Initialize a <a href="vorbis_dsp_state.html">vorbis_dsp_state</a>
  25. for encoding based on the parameters in the vorbis_info by using <a
  26. href="vorbis_analysis_init.html">vorbis_analysis_init</a>.</li>
  27. <li>Initialize a <a href="vorbis_comment.html">vorbis_comment</a>
  28. structure using <a href="vorbis_comment_init.html">vorbis_comment_init</a>,
  29. populate it with any comments you wish to store in the stream, and call
  30. <a href="vorbis_analysis_headerout.html">vorbis_analysis_headerout</a> to
  31. get the three Vorbis stream header packets. Output the packets.</li>
  32. <li>Initialize a <a href="vorbis_block.html">vorbis_block</a> structure
  33. using <a href="vorbis_block_init.html">vorbis_block_init</a>.</li>
  34. <li>While there is more audio to encode:<ol>
  35. <li>Submit a chunk of audio data using <a
  36. href="vorbis_analysis_buffer.html">vorbis_analysis_buffer</a> and <a
  37. href="vorbis_analysis_wrote.html">vorbis_analysis_wrote</a>.</li>
  38. <li>Obtain all available blocks using <a
  39. href="vorbis_analysis_blockout.html">vorbis_analysis_blockout</a>
  40. in a loop. For each block obtained:<ol>
  41. <li>Encode the block into a packet (or prepare it for bitrate management)
  42. using <a href="vorbis_analysis.html">vorbis_analysis</a>. (It's a good
  43. idea to always pass the blocks through the bitrate
  44. management mechanism; more information is on the <a
  45. href="vorbis_analysis.html">vorbis_analysis</a> page. It does not affect
  46. the resulting packets unless you are actually using a bitrate-managed
  47. mode.)</li>
  48. <li>If you are using bitrate management, submit the block using <a
  49. href="vorbis_bitrate_addblock.html">vorbis_bitrate_addblock</a> and obtain
  50. packets using <a
  51. href="vorbis_bitrate_flushpacket.html">vorbis_bitrate_flushpacket</a>.</li>
  52. <li>Output any obtained packets.</li>
  53. </ol></li>
  54. </ol></li>
  55. <li>Submit an empty buffer to indicate the end of input; this will result
  56. in an end-of-stream packet after all encoding steps are done to it.</li>
  57. <li>Destroy the structures using the appropriate vorbis_*_clear routines.</li>
  58. </ol>
  59. <h2>Decoding workflow</h2>
  60. <em>Note: if you do not need to do anything more involved than just
  61. decoding the audio from an Ogg Vorbis file, you can use the far simpler
  62. <a href="../vorbisfile/index.html">libvorbisfile</a> interface, which
  63. will take care of all of the demuxing and low-level decoding operations
  64. (and even the I/O, if you want) for you.</em>
  65. <ol>
  66. <li>When reading the header packets of an Ogg stream, you can use <a
  67. href="vorbis_synthesis_idheader.html">vorbis_synthesis_idheader</a> to
  68. check whether a stream might be Vorbis.</li>
  69. <li>Initialize a <a href="vorbis_info.html">vorbis_info</a> and a <a
  70. href="vorbis_comment.html">vorbis_comment</a> structure using the
  71. appropriate vorbis_*_init routines, then pass the first three packets
  72. from the stream (the Vorbis stream header packets) to <a
  73. href="vorbis_synthesis_headerin.html">vorbis_synthesis_headerin</a> in
  74. order. At this point, you can see the comments and basic parameters of
  75. the Vorbis stream.</li>
  76. <li>Initialize a <a href="vorbis_dsp_state.html">vorbis_dsp_state</a>
  77. for decoding based on the parameters in the vorbis_info by using <a
  78. href="vorbis_synthesis_init.html">vorbis_synthesis_init</a>.</li>
  79. <li>Initialize a <a href="vorbis_block.html">vorbis_block</a> structure
  80. using <a href="vorbis_block_init.html">vorbis_block_init</a>.</li>
  81. <li>While there are more packets to decode:<ol>
  82. <li>Decode the next packet into a block using <a
  83. href="vorbis_synthesis.html">vorbis_synthesis</a>.</li>
  84. <li>Submit the block to the reassembly layer using <a
  85. href="vorbis_synthesis_blockin.html">vorbis_synthesis_blockin</a>.</li>
  86. <li>Obtain some decoded audio using <a
  87. href="vorbis_synthesis_pcmout.html">vorbis_synthesis_pcmout</a> and <a
  88. href="vorbis_synthesis_read.html">vorbis_synthesis_read</a>. Any audio data
  89. returned but not marked as consumed using vorbis_synthesis_read carries
  90. over to the next call to vorbis_synthesis_pcmout.</li>
  91. </ol></li>
  92. <li>Destroy the structures using the appropriate vorbis_*_clear routines.</li>
  93. </ol>
  94. <h2>Metadata workflow</h2>
  95. <em>Note: if you do not need to do anything more involved than just
  96. reading the metadata from an Ogg Vorbis file, <a
  97. href="../vorbisfile/index.html">libvorbisfile</a> can do this for you.</em>
  98. <ol>
  99. <li>Follow the decoding workflow above until you have access to the comments
  100. and basic parameters of the Vorbis stream.</li>
  101. <li>If you want to alter the comments, copy the first packet to the output
  102. file, then create a packet for the modified comments using <a
  103. href="vorbis_commentheader_out.html">vorbis_commentheader_out</a> and output
  104. it, then copy the third packet and all subsequent packets into the output
  105. file.</li>
  106. </ol>
  107. <br><br>
  108. <hr noshade>
  109. <table border=0 width=100%>
  110. <tr valign=top>
  111. <td><p class=tiny>copyright &copy; 2010 Xiph.Org</p></td>
  112. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a></p></td>
  113. </tr><tr>
  114. <td><p class=tiny>libvorbis documentation</p></td>
  115. <td align=right><p class=tiny>libvorbis version 1.3.2 - 20101101</p></td>
  116. </tr>
  117. </table>
  118. </body>
  119. </html>