annotate src/libvorbis-1.3.3/doc/05-comment.tex @ 84:08ae793730bd

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