ov_read.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <html>
  2. <head>
  3. <title>Vorbisfile - function - ov_read</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.3.2 - 20101101</p></td>
  11. </tr>
  12. </table>
  13. <h1>ov_read()</h1>
  14. <p><i>declared in "vorbis/vorbisfile.h";</i></p>
  15. <p>
  16. This is the main function used to decode a Vorbis file within a
  17. loop. It returns up to the specified number of bytes of decoded PCM audio
  18. in the requested endianness, signedness, and word size. If the audio is
  19. multichannel, the channels are interleaved in the output buffer.
  20. If the passed in buffer is large, <tt>ov_read()</tt> will not fill
  21. it; the passed in buffer size is treated as a <em>limit</em> and
  22. not a request.
  23. <p>The output channels are in stream order and not remapped. Vorbis I
  24. defines channel order as follows:
  25. <ul>
  26. <li>one channel - the stream is monophonic
  27. <li>two channels - the stream is stereo. channel order: left, right
  28. <li>three channels - the stream is a 1d-surround encoding. channel order: left,
  29. center, right
  30. <li>four channels - the stream is quadraphonic surround. channel order: front left,
  31. front right, rear left, rear right
  32. <li>five channels - the stream is five-channel surround. channel order: front left,
  33. center, front right, rear left, rear right
  34. <li>six channels - the stream is 5.1 surround. channel order: front left, center,
  35. front right, rear left, rear right, LFE
  36. <li>seven channels - the stream is 6.1 surround. channel order: front left, center,
  37. front right, side left, side right, rear center, LFE
  38. <li>eight channels - the stream is 7.1 surround. channel order: front left, center,
  39. front right, side left, side right, rear left, rear right,
  40. LFE
  41. <li>greater than eight channels - channel use and order is undefined
  42. </ul>
  43. <p>Note that up to this point, the Vorbisfile API could more or less hide the
  44. multiple logical bitstream nature of chaining from the toplevel
  45. application if the toplevel application didn't particularly care.
  46. However, when reading audio back, the application must be aware
  47. that multiple bitstream sections do not necessarily use the same
  48. number of channels or sampling rate. <p> <tt>ov_read()</tt> passes
  49. back the index of the sequential logical bitstream currently being
  50. decoded (in <tt>*bitstream</tt>) along with the PCM data in order
  51. that the toplevel application can handle channel and/or sample
  52. rate changes. This number will be incremented at chaining
  53. boundaries even for non-seekable streams. For seekable streams, it
  54. represents the actual chaining index within the physical bitstream.
  55. <p>
  56. <br><br>
  57. <table border=0 color=black cellspacing=0 cellpadding=7>
  58. <tr bgcolor=#cccccc>
  59. <td>
  60. <pre><b>
  61. long ov_read(<a href="OggVorbis_File.html">OggVorbis_File</a> *vf, char *buffer, int length, int bigendianp, int word, int sgned, int *bitstream);
  62. </b></pre>
  63. </td>
  64. </tr>
  65. </table>
  66. <h3>Parameters</h3>
  67. <dl>
  68. <dt><i>vf</i></dt>
  69. <dd>A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile
  70. functions.</dd>
  71. <dt><i>buffer</i></dt>
  72. <dd>A pointer to an output buffer. The decoded output is inserted into this buffer.</dd>
  73. <dt><i>length</i></dt>
  74. <dd>Number of bytes to be read into the buffer. Should be the same size as the buffer. A typical value is 4096.</dd>
  75. <dt><i>bigendianp</i></dt>
  76. <dd>Specifies big or little endian byte packing. 0 for little endian, 1 for b
  77. ig endian. Typical value is 0.</dd>
  78. <dt><i>word</i></dt>
  79. <dd>Specifies word size. Possible arguments are 1 for 8-bit samples, or 2 or
  80. 16-bit samples. Typical value is 2.</dd>
  81. <dt><i>sgned</i></dt>
  82. <dd>Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1.</dd>
  83. <dt><i>bitstream</i></dt>
  84. <dd>A pointer to the number of the current logical bitstream.</dd>
  85. </dl>
  86. <h3>Return Values</h3>
  87. <blockquote>
  88. <dl>
  89. <dt>OV_HOLE</dt>
  90. <dd>indicates there was an interruption in the data.
  91. <br>(one of: garbage between pages, loss of sync followed by
  92. recapture, or a corrupt page)</dd>
  93. <dt>OV_EBADLINK</dt>
  94. <dd>indicates that an invalid stream section was supplied to
  95. libvorbisfile, or the requested link is corrupt.</dd>
  96. <dt>OV_EINVAL</dt>
  97. <dd>indicates the initial file headers couldn't be read or
  98. are corrupt, or that the initial open call for <i>vf</i>
  99. failed.</dd>
  100. <dt>0</dt>
  101. <dd>indicates EOF</dd>
  102. <dt><i>n</i></dt>
  103. <dd>indicates actual number of bytes read. <tt>ov_read()</tt> will
  104. decode at most one vorbis packet per invocation, so the value
  105. returned will generally be less than <tt>length</tt>.
  106. </dl>
  107. </blockquote>
  108. <h3>Notes</h3>
  109. <p><b>Typical usage:</b>
  110. <blockquote>
  111. <tt>bytes_read = ov_read(&amp;vf,
  112. buffer, 4096,0,2,1,&amp;current_section)</tt>
  113. </blockquote>
  114. This reads up to 4096 bytes into a buffer, with signed 16-bit
  115. little-endian samples.
  116. </p>
  117. <br><br>
  118. <hr noshade>
  119. <table border=0 width=100%>
  120. <tr valign=top>
  121. <td><p class=tiny>copyright &copy; 2000-2010 Xiph.Org</p></td>
  122. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
  123. </tr><tr>
  124. <td><p class=tiny>Vorbisfile documentation</p></td>
  125. <td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
  126. </tr>
  127. </table>
  128. </body>
  129. </html>