05-comment.tex 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. % -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*-
  2. %!TEX root = Vorbis_I_spec.tex
  3. % $Id$
  4. \section{comment field and header specification} \label{vorbis:spec:comment}
  5. \subsection{Overview}
  6. The Vorbis text comment header is the second (of three) header
  7. packets that begin a Vorbis bitstream. It is meant for short text
  8. comments, not arbitrary metadata; arbitrary metadata belongs in a
  9. separate logical bitstream (usually an XML stream type) that provides
  10. greater structure and machine parseability.
  11. The comment field is meant to be used much like someone jotting a
  12. quick note on the bottom of a CDR. It should be a little information to
  13. remember the disc by and explain it to others; a short, to-the-point
  14. text note that need not only be a couple words, but isn't going to be
  15. more than a short paragraph. The essentials, in other words, whatever
  16. they turn out to be, eg:
  17. \begin{quote}
  18. Honest Bob and the Factory-to-Dealer-Incentives, \textit{``I'm Still
  19. Around''}, opening for Moxy Fr\"{u}vous, 1997.
  20. \end{quote}
  21. \subsection{Comment encoding}
  22. \subsubsection{Structure}
  23. The comment header is logically a list of eight-bit-clean vectors; the
  24. number of vectors is bounded to $2^{32}-1$ and the length of each vector
  25. is limited to $2^{32}-1$ bytes. The vector length is encoded; the vector
  26. contents themselves are not null terminated. In addition to the vector
  27. list, there is a single vector for vendor name (also 8 bit clean,
  28. length encoded in 32 bits). For example, the 1.0 release of libvorbis
  29. set the vendor string to ``Xiph.Org libVorbis I 20020717''.
  30. The vector lengths and number of vectors are stored lsb first, according
  31. to the bit packing conventions of the vorbis codec. However, since data
  32. in the comment header is octet-aligned, they can simply be read as
  33. unaligned 32 bit little endian unsigned integers.
  34. The comment header is decoded as follows:
  35. \begin{programlisting}
  36. 1) [vendor_length] = read an unsigned integer of 32 bits
  37. 2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets
  38. 3) [user_comment_list_length] = read an unsigned integer of 32 bits
  39. 4) iterate [user_comment_list_length] times {
  40. 5) [length] = read an unsigned integer of 32 bits
  41. 6) this iteration's user comment = read a UTF-8 vector as [length] octets
  42. }
  43. 7) [framing_bit] = read a single bit as boolean
  44. 8) if ( [framing_bit] unset or end-of-packet ) then ERROR
  45. 9) done.
  46. \end{programlisting}
  47. \subsubsection{Content vector format}
  48. The comment vectors are structured similarly to a UNIX environment variable.
  49. That is, comment fields consist of a field name and a corresponding value and
  50. look like:
  51. \begin{quote}
  52. \begin{programlisting}
  53. comment[0]="ARTIST=me";
  54. comment[1]="TITLE=the sound of Vorbis";
  55. \end{programlisting}
  56. \end{quote}
  57. The field name is case-insensitive and may consist of ASCII 0x20
  58. through 0x7D, 0x3D ('=') excluded. ASCII 0x41 through 0x5A inclusive
  59. (characters A-Z) is to be considered equivalent to ASCII 0x61 through
  60. 0x7A inclusive (characters a-z).
  61. The field name is immediately followed by ASCII 0x3D ('=');
  62. this equals sign is used to terminate the field name.
  63. 0x3D is followed by 8 bit clean UTF-8 encoded value of the
  64. field contents to the end of the field.
  65. \paragraph{Field names}
  66. Below is a proposed, minimal list of standard field names with a
  67. description of intended use. No single or group of field names is
  68. mandatory; a comment header may contain one, all or none of the names
  69. in this list.
  70. \begin{description} %[style=nextline]
  71. \item[TITLE]
  72. Track/Work name
  73. \item[VERSION]
  74. The version field may be used to differentiate multiple
  75. versions of the same track title in a single collection. (e.g. remix
  76. info)
  77. \item[ALBUM]
  78. The collection name to which this track belongs
  79. \item[TRACKNUMBER]
  80. The track number of this piece if part of a specific larger collection or album
  81. \item[ARTIST]
  82. 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.
  83. \item[PERFORMER]
  84. 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.
  85. \item[COPYRIGHT]
  86. Copyright attribution, e.g., '2001 Nobody's Band' or '1999 Jack Moffitt'
  87. \item[LICENSE]
  88. License information, eg, 'All Rights Reserved', 'Any
  89. Use Permitted', a URL to a license such as a Creative Commons license
  90. ("www.creativecommons.org/blahblah/license.html") or the EFF Open
  91. Audio License ('distributed under the terms of the Open Audio
  92. License. see http://www.eff.org/IP/Open_licenses/eff_oal.html for
  93. details'), etc.
  94. \item[ORGANIZATION]
  95. Name of the organization producing the track (i.e.
  96. the 'record label')
  97. \item[DESCRIPTION]
  98. A short text description of the contents
  99. \item[GENRE]
  100. A short text indication of music genre
  101. \item[DATE]
  102. Date the track was recorded
  103. \item[LOCATION]
  104. Location where track was recorded
  105. \item[CONTACT]
  106. 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.
  107. \item[ISRC]
  108. International Standard Recording Code for the
  109. track; see \href{http://www.ifpi.org/isrc/}{the ISRC
  110. intro page} for more information on ISRC numbers.
  111. \end{description}
  112. \paragraph{Implications}
  113. Field names should not be 'internationalized'; this is a
  114. concession to simplicity not an attempt to exclude the majority of
  115. the world that doesn't speak English. Field \emph{contents},
  116. however, use the UTF-8 character encoding to allow easy representation
  117. of any language.
  118. We have the length of the entirety of the field and restrictions on
  119. the field name so that the field name is bounded in a known way. Thus
  120. we also have the length of the field contents.
  121. Individual 'vendors' may use non-standard field names within
  122. reason. The proper use of comment fields should be clear through
  123. context at this point. Abuse will be discouraged.
  124. There is no vendor-specific prefix to 'nonstandard' field names.
  125. Vendors should make some effort to avoid arbitrarily polluting the
  126. common namespace. We will generally collect the more useful tags
  127. here to help with standardization.
  128. Field names are not required to be unique (occur once) within a
  129. comment header. As an example, assume a track was recorded by three
  130. well know artists; the following is permissible, and encouraged:
  131. \begin{quote}
  132. \begin{programlisting}
  133. ARTIST=Dizzy Gillespie
  134. ARTIST=Sonny Rollins
  135. ARTIST=Sonny Stitt
  136. \end{programlisting}
  137. \end{quote}
  138. \subsubsection{Encoding}
  139. The comment header comprises the entirety of the second bitstream
  140. header packet. Unlike the first bitstream header packet, it is not
  141. generally the only packet on the second page and may not be restricted
  142. to within the second bitstream page. The length of the comment header
  143. packet is (practically) unbounded. The comment header packet is not
  144. optional; it must be present in the bitstream even if it is
  145. effectively empty.
  146. The comment header is encoded as follows (as per Ogg's standard
  147. bitstream mapping which renders least-significant-bit of the word to be
  148. coded into the least significant available bit of the current
  149. bitstream octet first):
  150. \begin{enumerate}
  151. \item
  152. Vendor string length (32 bit unsigned quantity specifying number of octets)
  153. \item
  154. Vendor string ([vendor string length] octets coded from beginning of string to end of string, not null terminated)
  155. \item
  156. Number of comment fields (32 bit unsigned quantity specifying number of fields)
  157. \item
  158. Comment field 0 length (if [Number of comment fields] $>0$; 32 bit unsigned quantity specifying number of octets)
  159. \item
  160. Comment field 0 ([Comment field 0 length] octets coded from beginning of string to end of string, not null terminated)
  161. \item
  162. Comment field 1 length (if [Number of comment fields] $>1$...)...
  163. \end{enumerate}
  164. This is actually somewhat easier to describe in code; implementation of the above can be found in \filename{vorbis/lib/info.c}, \function{_vorbis_pack_comment()} and \function{_vorbis_unpack_comment()}.