Chris@1: % -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- Chris@1: %!TEX root = Vorbis_I_spec.tex Chris@1: % $Id$ Chris@1: \section{comment field and header specification} \label{vorbis:spec:comment} Chris@1: Chris@1: \subsection{Overview} Chris@1: Chris@1: The Vorbis text comment header is the second (of three) header Chris@1: packets that begin a Vorbis bitstream. It is meant for short text Chris@1: comments, not arbitrary metadata; arbitrary metadata belongs in a Chris@1: separate logical bitstream (usually an XML stream type) that provides Chris@1: greater structure and machine parseability. Chris@1: Chris@1: The comment field is meant to be used much like someone jotting a Chris@1: quick note on the bottom of a CDR. It should be a little information to Chris@1: remember the disc by and explain it to others; a short, to-the-point Chris@1: text note that need not only be a couple words, but isn't going to be Chris@1: more than a short paragraph. The essentials, in other words, whatever Chris@1: they turn out to be, eg: Chris@1: Chris@1: \begin{quote} Chris@1: Honest Bob and the Factory-to-Dealer-Incentives, \textit{``I'm Still Chris@1: Around''}, opening for Moxy Fr\"{u}vous, 1997. Chris@1: \end{quote} Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: \subsection{Comment encoding} Chris@1: Chris@1: \subsubsection{Structure} Chris@1: Chris@1: The comment header is logically a list of eight-bit-clean vectors; the Chris@1: number of vectors is bounded to $2^{32}-1$ and the length of each vector Chris@1: is limited to $2^{32}-1$ bytes. The vector length is encoded; the vector Chris@1: contents themselves are not null terminated. In addition to the vector Chris@1: list, there is a single vector for vendor name (also 8 bit clean, Chris@1: length encoded in 32 bits). For example, the 1.0 release of libvorbis Chris@1: set the vendor string to ``Xiph.Org libVorbis I 20020717''. Chris@1: Chris@1: The vector lengths and number of vectors are stored lsb first, according Chris@1: to the bit packing conventions of the vorbis codec. However, since data Chris@1: in the comment header is octet-aligned, they can simply be read as Chris@1: unaligned 32 bit little endian unsigned integers. Chris@1: Chris@1: The comment header is decoded as follows: Chris@1: Chris@1: \begin{programlisting} Chris@1: 1) [vendor\_length] = read an unsigned integer of 32 bits Chris@1: 2) [vendor\_string] = read a UTF-8 vector as [vendor\_length] octets Chris@1: 3) [user\_comment\_list\_length] = read an unsigned integer of 32 bits Chris@1: 4) iterate [user\_comment\_list\_length] times { Chris@1: 5) [length] = read an unsigned integer of 32 bits Chris@1: 6) this iteration's user comment = read a UTF-8 vector as [length] octets Chris@1: } Chris@1: 7) [framing\_bit] = read a single bit as boolean Chris@1: 8) if ( [framing\_bit] unset or end-of-packet ) then ERROR Chris@1: 9) done. Chris@1: \end{programlisting} Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: \subsubsection{Content vector format} Chris@1: Chris@1: The comment vectors are structured similarly to a UNIX environment variable. Chris@1: That is, comment fields consist of a field name and a corresponding value and Chris@1: look like: Chris@1: Chris@1: \begin{quote} Chris@1: \begin{programlisting} Chris@1: comment[0]="ARTIST=me"; Chris@1: comment[1]="TITLE=the sound of Vorbis"; Chris@1: \end{programlisting} Chris@1: \end{quote} Chris@1: Chris@1: The field name is case-insensitive and may consist of ASCII 0x20 Chris@1: through 0x7D, 0x3D ('=') excluded. ASCII 0x41 through 0x5A inclusive Chris@1: (characters A-Z) is to be considered equivalent to ASCII 0x61 through Chris@1: 0x7A inclusive (characters a-z). Chris@1: Chris@1: Chris@1: The field name is immediately followed by ASCII 0x3D ('='); Chris@1: this equals sign is used to terminate the field name. Chris@1: Chris@1: Chris@1: 0x3D is followed by 8 bit clean UTF-8 encoded value of the Chris@1: field contents to the end of the field. Chris@1: Chris@1: Chris@1: \paragraph{Field names} Chris@1: Chris@1: Below is a proposed, minimal list of standard field names with a Chris@1: description of intended use. No single or group of field names is Chris@1: mandatory; a comment header may contain one, all or none of the names Chris@1: in this list. Chris@1: Chris@1: \begin{description} %[style=nextline] Chris@1: \item[TITLE] Chris@1: Track/Work name Chris@1: Chris@1: \item[VERSION] Chris@1: The version field may be used to differentiate multiple Chris@1: versions of the same track title in a single collection. (e.g. remix Chris@1: info) Chris@1: Chris@1: \item[ALBUM] Chris@1: The collection name to which this track belongs Chris@1: Chris@1: \item[TRACKNUMBER] Chris@1: The track number of this piece if part of a specific larger collection or album Chris@1: Chris@1: \item[ARTIST] Chris@1: 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. Chris@1: Chris@1: \item[PERFORMER] Chris@1: 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. Chris@1: Chris@1: \item[COPYRIGHT] Chris@1: Copyright attribution, e.g., '2001 Nobody's Band' or '1999 Jack Moffitt' Chris@1: Chris@1: \item[LICENSE] Chris@1: License information, eg, 'All Rights Reserved', 'Any Chris@1: Use Permitted', a URL to a license such as a Creative Commons license Chris@1: ("www.creativecommons.org/blahblah/license.html") or the EFF Open Chris@1: Audio License ('distributed under the terms of the Open Audio Chris@1: License. see http://www.eff.org/IP/Open\_licenses/eff\_oal.html for Chris@1: details'), etc. Chris@1: Chris@1: \item[ORGANIZATION] Chris@1: Name of the organization producing the track (i.e. Chris@1: the 'record label') Chris@1: Chris@1: \item[DESCRIPTION] Chris@1: A short text description of the contents Chris@1: Chris@1: \item[GENRE] Chris@1: A short text indication of music genre Chris@1: Chris@1: \item[DATE] Chris@1: Date the track was recorded Chris@1: Chris@1: \item[LOCATION] Chris@1: Location where track was recorded Chris@1: Chris@1: \item[CONTACT] Chris@1: 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. Chris@1: Chris@1: \item[ISRC] Chris@1: International Standard Recording Code for the Chris@1: track; see \href{http://www.ifpi.org/isrc/}{the ISRC Chris@1: intro page} for more information on ISRC numbers. Chris@1: Chris@1: \end{description} Chris@1: Chris@1: Chris@1: Chris@1: \paragraph{Implications} Chris@1: Chris@1: Field names should not be 'internationalized'; this is a Chris@1: concession to simplicity not an attempt to exclude the majority of Chris@1: the world that doesn't speak English. Field \emph{contents}, Chris@1: however, use the UTF-8 character encoding to allow easy representation Chris@1: of any language. Chris@1: Chris@1: We have the length of the entirety of the field and restrictions on Chris@1: the field name so that the field name is bounded in a known way. Thus Chris@1: we also have the length of the field contents. Chris@1: Chris@1: Individual 'vendors' may use non-standard field names within Chris@1: reason. The proper use of comment fields should be clear through Chris@1: context at this point. Abuse will be discouraged. Chris@1: Chris@1: There is no vendor-specific prefix to 'nonstandard' field names. Chris@1: Vendors should make some effort to avoid arbitrarily polluting the Chris@1: common namespace. We will generally collect the more useful tags Chris@1: here to help with standardization. Chris@1: Chris@1: Field names are not required to be unique (occur once) within a Chris@1: comment header. As an example, assume a track was recorded by three Chris@1: well know artists; the following is permissible, and encouraged: Chris@1: Chris@1: \begin{quote} Chris@1: \begin{programlisting} Chris@1: ARTIST=Dizzy Gillespie Chris@1: ARTIST=Sonny Rollins Chris@1: ARTIST=Sonny Stitt Chris@1: \end{programlisting} Chris@1: \end{quote} Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: \subsubsection{Encoding} Chris@1: Chris@1: The comment header comprises the entirety of the second bitstream Chris@1: header packet. Unlike the first bitstream header packet, it is not Chris@1: generally the only packet on the second page and may not be restricted Chris@1: to within the second bitstream page. The length of the comment header Chris@1: packet is (practically) unbounded. The comment header packet is not Chris@1: optional; it must be present in the bitstream even if it is Chris@1: effectively empty. Chris@1: Chris@1: The comment header is encoded as follows (as per Ogg's standard Chris@1: bitstream mapping which renders least-significant-bit of the word to be Chris@1: coded into the least significant available bit of the current Chris@1: bitstream octet first): Chris@1: Chris@1: \begin{enumerate} Chris@1: \item Chris@1: Vendor string length (32 bit unsigned quantity specifying number of octets) Chris@1: Chris@1: \item Chris@1: Vendor string ([vendor string length] octets coded from beginning of string to end of string, not null terminated) Chris@1: Chris@1: \item Chris@1: Number of comment fields (32 bit unsigned quantity specifying number of fields) Chris@1: Chris@1: \item Chris@1: Comment field 0 length (if [Number of comment fields] $>0$; 32 bit unsigned quantity specifying number of octets) Chris@1: Chris@1: \item Chris@1: Comment field 0 ([Comment field 0 length] octets coded from beginning of string to end of string, not null terminated) Chris@1: Chris@1: \item Chris@1: Comment field 1 length (if [Number of comment fields] $>1$...)... Chris@1: Chris@1: \end{enumerate} Chris@1: Chris@1: Chris@1: 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()}. Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: Chris@1: