05-comment.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?xml version="1.0" standalone="no"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
  4. <!ENTITY % isolat1 SYSTEM "http://www.oasis-open.org/docbook/xml/4.2/ent/iso-lat1.ent">
  5. %isolat1;
  6. ]>
  7. <section id="vorbis-spec-comment">
  8. <sectioninfo>
  9. <releaseinfo>
  10. $Id$
  11. </releaseinfo>
  12. </sectioninfo>
  13. <title>comment field and header specification</title>
  14. <section><title>Overview</title>
  15. <para>The Vorbis text comment header is the second (of three) header
  16. packets that begin a Vorbis bitstream. It is meant for short text
  17. comments, not arbitrary metadata; arbitrary metadata belongs in a
  18. separate logical bitstream (usually an XML stream type) that provides
  19. greater structure and machine parseability.</para>
  20. <para>The comment field is meant to be used much like someone jotting a
  21. quick note on the bottom of a CDR. It should be a little information to
  22. remember the disc by and explain it to others; a short, to-the-point
  23. text note that need not only be a couple words, but isn't going to be
  24. more than a short paragraph. The essentials, in other words, whatever
  25. they turn out to be, eg:
  26. <blockquote>
  27. <simpara>Honest Bob and the Factory-to-Dealer-Incentives, <citetitle>I'm Still
  28. Around</citetitle>, opening for Moxy Fr&uuml;vous, 1997.</simpara>
  29. </blockquote>
  30. </para>
  31. </section>
  32. <section><title>Comment encoding</title>
  33. <section><title>Structure</title>
  34. <para>
  35. The comment header is logically a list of eight-bit-clean vectors; the
  36. number of vectors is bounded to 2^32-1 and the length of each vector
  37. is limited to 2^32-1 bytes. The vector length is encoded; the vector
  38. contents themselves are not null terminated. In addition to the vector
  39. list, there is a single vector for vendor name (also 8 bit clean,
  40. length encoded in 32 bits). For example, the 1.0 release of libvorbis
  41. set the vendor string to "Xiph.Org libVorbis I 20020717".</para>
  42. <para>
  43. The vector lengths and number of vectors are stored lsb first, according
  44. to the bit packing conventions of the vorbis codec. However, since data
  45. in the comment header is octet-aligned, they can simply be read as
  46. unaligned 32 bit little endian unsigned integers.</para>
  47. <para>The comment header is decoded as follows:
  48. <programlisting>
  49. 1) [vendor_length] = read an unsigned integer of 32 bits
  50. 2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets
  51. 3) [user_comment_list_length] = read an unsigned integer of 32 bits
  52. 4) iterate [user_comment_list_length] times {
  53. 5) [length] = read an unsigned integer of 32 bits
  54. 6) this iteration's user comment = read a UTF-8 vector as [length] octets
  55. }
  56. 7) [framing_bit] = read a single bit as boolean
  57. 8) if ( [framing_bit] unset or end-of-packet ) then ERROR
  58. 9) done.
  59. </programlisting>
  60. </para>
  61. </section>
  62. <section><title>Content vector format</title>
  63. <para>
  64. The comment vectors are structured similarly to a UNIX environment variable.
  65. That is, comment fields consist of a field name and a corresponding value and
  66. look like:</para>
  67. <blockquote><programlisting>
  68. comment[0]="ARTIST=me";
  69. comment[1]="TITLE=the sound of Vorbis";
  70. </programlisting></blockquote>
  71. <para>
  72. The field name is case-insensitive and may consist of ASCII 0x20
  73. through 0x7D, 0x3D ('=') excluded. ASCII 0x41 through 0x5A inclusive
  74. (characters A-Z) is to be considered equivalent to ASCII 0x61 through
  75. 0x7A inclusive (characters a-z).
  76. </para>
  77. <para>
  78. The field name is immediately followed by ASCII 0x3D ('=');
  79. this equals sign is used to terminate the field name.
  80. </para>
  81. <para>
  82. 0x3D is followed by 8 bit clean UTF-8 encoded value of the
  83. field contents to the end of the field.
  84. </para>
  85. <section><title>Field names</title>
  86. <para>Below is a proposed, minimal list of standard field names with a
  87. description of intended use. No single or group of field names is
  88. mandatory; a comment header may contain one, all or none of the names
  89. in this list.</para>
  90. <variablelist>
  91. <varlistentry>
  92. <term>TITLE</term>
  93. <listitem>
  94. <simpara>Track/Work name</simpara>
  95. </listitem>
  96. </varlistentry>
  97. <varlistentry>
  98. <term>VERSION</term>
  99. <listitem>
  100. <simpara>The version field may be used to
  101. differentiate multiple
  102. versions of the same track title in a single collection. (e.g. remix
  103. info)
  104. </simpara></listitem>
  105. </varlistentry>
  106. <varlistentry><term>ALBUM</term><listitem><simpara>The collection name to which this track belongs
  107. </simpara></listitem>
  108. </varlistentry>
  109. <varlistentry><term>TRACKNUMBER</term>
  110. <listitem><simpara>The track number of this piece if part of a specific larger collection or album
  111. </simpara></listitem>
  112. </varlistentry>
  113. <varlistentry><term>ARTIST</term>
  114. <listitem><simpara>The artist generally considered responsible for the work. In popular music this is usually the performing band or singer. For classical music it would be the composer. For an audio book it would be the author of the original text.
  115. </simpara></listitem>
  116. </varlistentry>
  117. <varlistentry><term>PERFORMER</term>
  118. <listitem><simpara>The artist(s) who performed the work. In classical music this would be the conductor, orchestra, soloists. In an audio book it would be the actor who did the reading. In popular music this is typically the same as the ARTIST and is omitted.
  119. </simpara></listitem>
  120. </varlistentry>
  121. <varlistentry><term>COPYRIGHT</term>
  122. <listitem><simpara>Copyright attribution, e.g., '2001 Nobody's Band' or '1999 Jack Moffitt'
  123. </simpara></listitem>
  124. </varlistentry>
  125. <varlistentry><term>LICENSE</term>
  126. <listitem><simpara>License information, eg, 'All Rights Reserved', 'Any
  127. Use Permitted', a URL to a license such as a Creative Commons license
  128. ("www.creativecommons.org/blahblah/license.html") or the EFF Open
  129. Audio License ('distributed under the terms of the Open Audio
  130. License. see http://www.eff.org/IP/Open_licenses/eff_oal.html for
  131. details'), etc.
  132. </simpara></listitem>
  133. </varlistentry>
  134. <varlistentry><term>ORGANIZATION</term>
  135. <listitem><simpara>Name of the organization producing the track (i.e.
  136. the 'record label')
  137. </simpara></listitem>
  138. </varlistentry>
  139. <varlistentry><term>DESCRIPTION</term>
  140. <listitem><simpara>A short text description of the contents
  141. </simpara></listitem>
  142. </varlistentry>
  143. <varlistentry><term>GENRE</term>
  144. <listitem><simpara>A short text indication of music genre
  145. </simpara></listitem>
  146. </varlistentry>
  147. <varlistentry><term>DATE</term>
  148. <listitem><simpara>Date the track was recorded
  149. </simpara></listitem>
  150. </varlistentry>
  151. <varlistentry><term>LOCATION</term>
  152. <listitem><simpara>Location where track was recorded
  153. </simpara></listitem>
  154. </varlistentry>
  155. <varlistentry><term>CONTACT</term>
  156. <listitem><simpara>Contact information for the creators or distributors of the track. This could be a URL, an email address, the physical address of the producing label.
  157. </simpara></listitem>
  158. </varlistentry>
  159. <varlistentry><term>ISRC</term>
  160. <listitem><simpara>International Standard Recording Code for the
  161. track; see <ulink
  162. url="http://www.ifpi.org/isrc/">the ISRC
  163. intro page</ulink> for more information on ISRC numbers.
  164. </simpara></listitem>
  165. </varlistentry>
  166. </variablelist>
  167. </section>
  168. <section><title>Implications</title>
  169. <para>Field names should not be 'internationalized'; this is a
  170. concession to simplicity not an attempt to exclude the majority of
  171. the world that doesn't speak English. Field <emphasis>contents</emphasis>,
  172. however, use the UTF-8 character encoding to allow easy representation
  173. of any language.</para>
  174. <para>We have the length of the entirety of the field and restrictions on
  175. the field name so that the field name is bounded in a known way. Thus
  176. we also have the length of the field contents.</para>
  177. <para>Individual 'vendors' may use non-standard field names within
  178. reason. The proper use of comment fields should be clear through
  179. context at this point. Abuse will be discouraged.</para>
  180. <para>There is no vendor-specific prefix to 'nonstandard' field names.
  181. Vendors should make some effort to avoid arbitrarily polluting the
  182. common namespace. We will generally collect the more useful tags
  183. here to help with standardization.</para>
  184. <para>Field names are not required to be unique (occur once) within a
  185. comment header. As an example, assume a track was recorded by three
  186. well know artists; the following is permissible, and encouraged:
  187. <blockquote><programlisting>
  188. ARTIST=Dizzy Gillespie
  189. ARTIST=Sonny Rollins
  190. ARTIST=Sonny Stitt
  191. </programlisting></blockquote>
  192. </para>
  193. </section>
  194. </section>
  195. <section><title>Encoding</title>
  196. <para>
  197. The comment header comprises the entirety of the second bitstream
  198. header packet. Unlike the first bitstream header packet, it is not
  199. generally the only packet on the second page and may not be restricted
  200. to within the second bitstream page. The length of the comment header
  201. packet is (practically) unbounded. The comment header packet is not
  202. optional; it must be present in the bitstream even if it is
  203. effectively empty.</para>
  204. <para>
  205. The comment header is encoded as follows (as per Ogg's standard
  206. bitstream mapping which renders least-significant-bit of the word to be
  207. coded into the least significant available bit of the current
  208. bitstream octet first):
  209. <orderedlist>
  210. <listitem><simpara>
  211. Vendor string length (32 bit unsigned quantity specifying number of octets)
  212. </simpara></listitem>
  213. <listitem><simpara>
  214. Vendor string ([vendor string length] octets coded from beginning of string to end of string, not null terminated)
  215. </simpara></listitem>
  216. <listitem><simpara>
  217. Number of comment fields (32 bit unsigned quantity specifying number of fields)
  218. </simpara></listitem>
  219. <listitem><simpara>
  220. Comment field 0 length (if [Number of comment fields]>0; 32 bit unsigned quantity specifying number of octets)
  221. </simpara></listitem>
  222. <listitem><simpara>
  223. Comment field 0 ([Comment field 0 length] octets coded from beginning of string to end of string, not null terminated)
  224. </simpara></listitem>
  225. <listitem><simpara>
  226. Comment field 1 length (if [Number of comment fields]>1...)...
  227. </simpara></listitem>
  228. </orderedlist>
  229. </para>
  230. <para>
  231. This is actually somewhat easier to describe in code; implementation of the above can be found in <filename>vorbis/lib/info.c</filename>, <function>_vorbis_pack_comment()</function> and <function>_vorbis_unpack_comment()</function>.
  232. </para>
  233. </section>
  234. </section>
  235. </section>