05-comment.tex 8.1 KB

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