05-comment.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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>The comment header is decoded as follows:
  43. <programlisting>
  44. 1) [vendor_length] = read an unsigned integer of 32 bits
  45. 2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets
  46. 3) [user_comment_list_length] = read an unsigned integer of 32 bits
  47. 4) iterate [user_comment_list_length] times {
  48. 5) [length] = read an unsigned integer of 32 bits
  49. 6) this iteration's user comment = read a UTF-8 vector as [length] octets
  50. }
  51. 7) [framing_bit] = read a single bit as boolean
  52. 8) if ( [framing_bit] unset or end-of-packet ) then ERROR
  53. 9) done.
  54. </programlisting>
  55. </para>
  56. </section>
  57. <section><title>Content vector format</title>
  58. <para>
  59. The comment vectors are structured similarly to a UNIX environment variable.
  60. That is, comment fields consist of a field name and a corresponding value and
  61. look like:</para>
  62. <blockquote><programlisting>
  63. comment[0]="ARTIST=me";
  64. comment[1]="TITLE=the sound of Vorbis";
  65. </programlisting></blockquote>
  66. <para>
  67. The field name is case-insensitive and may consist of ASCII 0x20
  68. through 0x7D, 0x3D ('=') excluded. ASCII 0x41 through 0x5A inclusive
  69. (characters A-Z) is to be considered equivalent to ASCII 0x61 through
  70. 0x7A inclusive (characters a-z).
  71. </para>
  72. <para>
  73. The field name is immediately followed by ASCII 0x3D ('=');
  74. this equals sign is used to terminate the field name.
  75. </para>
  76. <para>
  77. 0x3D is followed by 8 bit clean UTF-8 encoded value of the
  78. field contents to the end of the field.
  79. </para>
  80. <section><title>Field names</title>
  81. <para>Below is a proposed, minimal list of standard field names with a
  82. description of intended use. No single or group of field names is
  83. mandatory; a comment header may contain one, all or none of the names
  84. in this list.</para>
  85. <variablelist>
  86. <varlistentry>
  87. <term>TITLE</term>
  88. <listitem>
  89. <simpara>Track/Work name</simpara>
  90. </listitem>
  91. </varlistentry>
  92. <varlistentry>
  93. <term>VERSION</term>
  94. <listitem>
  95. <simpara>The version field may be used to
  96. differentiate multiple
  97. versions of the same track title in a single collection. (e.g. remix
  98. info)
  99. </simpara></listitem>
  100. </varlistentry>
  101. <varlistentry><term>ALBUM</term><listitem><simpara>The collection name to which this track belongs
  102. </simpara></listitem>
  103. </varlistentry>
  104. <varlistentry><term>TRACKNUMBER</term>
  105. <listitem><simpara>The track number of this piece if part of a specific larger collection or album
  106. </simpara></listitem>
  107. </varlistentry>
  108. <varlistentry><term>ARTIST</term>
  109. <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.
  110. </simpara></listitem>
  111. </varlistentry>
  112. <varlistentry><term>PERFORMER</term>
  113. <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.
  114. </simpara></listitem>
  115. </varlistentry>
  116. <varlistentry><term>COPYRIGHT</term>
  117. <listitem><simpara>Copyright attribution, e.g., '2001 Nobody's Band' or '1999 Jack Moffitt'
  118. </simpara></listitem>
  119. </varlistentry>
  120. <varlistentry><term>LICENSE</term>
  121. <listitem><simpara>License information, eg, 'All Rights Reserved', 'Any
  122. Use Permitted', a URL to a license such as a Creative Commons license
  123. ("www.creativecommons.org/blahblah/license.html") or the EFF Open
  124. Audio License ('distributed under the terms of the Open Audio
  125. License. see http://www.eff.org/IP/Open_licenses/eff_oal.html for
  126. details'), etc.
  127. </simpara></listitem>
  128. </varlistentry>
  129. <varlistentry><term>ORGANIZATION</term>
  130. <listitem><simpara>Name of the organization producing the track (i.e.
  131. the 'record label')
  132. </simpara></listitem>
  133. </varlistentry>
  134. <varlistentry><term>DESCRIPTION</term>
  135. <listitem><simpara>A short text description of the contents
  136. </simpara></listitem>
  137. </varlistentry>
  138. <varlistentry><term>GENRE</term>
  139. <listitem><simpara>A short text indication of music genre
  140. </simpara></listitem>
  141. </varlistentry>
  142. <varlistentry><term>DATE</term>
  143. <listitem><simpara>Date the track was recorded
  144. </simpara></listitem>
  145. </varlistentry>
  146. <varlistentry><term>LOCATION</term>
  147. <listitem><simpara>Location where track was recorded
  148. </simpara></listitem>
  149. </varlistentry>
  150. <varlistentry><term>CONTACT</term>
  151. <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.
  152. </simpara></listitem>
  153. </varlistentry>
  154. <varlistentry><term>ISRC</term>
  155. <listitem><simpara>International Standard Recording Code for the
  156. track; see <ulink
  157. url="http://www.ifpi.org/isrc/">the ISRC
  158. intro page</ulink> for more information on ISRC numbers.
  159. </simpara></listitem>
  160. </varlistentry>
  161. </variablelist>
  162. </section>
  163. <section><title>Implications</title>
  164. <para>Field names should not be 'internationalized'; this is a
  165. concession to simplicity not an attempt to exclude the majority of
  166. the world that doesn't speak English. Field <emphasis>contents</emphasis>,
  167. however, use the UTF-8 character encoding to allow easy representation
  168. of any language.</para>
  169. <para>We have the length of the entirety of the field and restrictions on
  170. the field name so that the field name is bounded in a known way. Thus
  171. we also have the length of the field contents.</para>
  172. <para>Individual 'vendors' may use non-standard field names within
  173. reason. The proper use of comment fields should be clear through
  174. context at this point. Abuse will be discouraged.</para>
  175. <para>There is no vendor-specific prefix to 'nonstandard' field names.
  176. Vendors should make some effort to avoid arbitrarily polluting the
  177. common namespace. We will generally collect the more useful tags
  178. here to help with standardization.</para>
  179. <para>Field names are not required to be unique (occur once) within a
  180. comment header. As an example, assume a track was recorded by three
  181. well know artists; the following is permissible, and encouraged:
  182. <blockquote><programlisting>
  183. ARTIST=Dizzy Gillespie
  184. ARTIST=Sonny Rollins
  185. ARTIST=Sonny Stitt
  186. </programlisting></blockquote>
  187. </para>
  188. </section>
  189. </section>
  190. <section><title>Encoding</title>
  191. <para>
  192. The comment header comprises the entirety of the second bitstream
  193. header packet. Unlike the first bitstream header packet, it is not
  194. generally the only packet on the second page and may not be restricted
  195. to within the second bitstream page. The length of the comment header
  196. packet is (practically) unbounded. The comment header packet is not
  197. optional; it must be present in the bitstream even if it is
  198. effectively empty.</para>
  199. <para>
  200. The comment header is encoded as follows (as per Ogg's standard
  201. bitstream mapping which renders least-significant-bit of the word to be
  202. coded into the least significant available bit of the current
  203. bitstream octet first):
  204. <orderedlist>
  205. <listitem><simpara>
  206. Vendor string length (32 bit unsigned quantity specifying number of octets)
  207. </simpara></listitem>
  208. <listitem><simpara>
  209. Vendor string ([vendor string length] octets coded from beginning of string to end of string, not null terminated)
  210. </simpara></listitem>
  211. <listitem><simpara>
  212. Number of comment fields (32 bit unsigned quantity specifying number of fields)
  213. </simpara></listitem>
  214. <listitem><simpara>
  215. Comment field 0 length (if [Number of comment fields]>0; 32 bit unsigned quantity specifying number of octets)
  216. </simpara></listitem>
  217. <listitem><simpara>
  218. Comment field 0 ([Comment field 0 length] octets coded from beginning of string to end of string, not null terminated)
  219. </simpara></listitem>
  220. <listitem><simpara>
  221. Comment field 1 length (if [Number of comment fields]>1...)...
  222. </simpara></listitem>
  223. </orderedlist>
  224. </para>
  225. <para>
  226. 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>.
  227. </para>
  228. </section>
  229. </section>
  230. </section>