Harmonize the spec and stand-alone versions of the comment header docs.
[platform/upstream/libvorbis.git] / doc / v-comment.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
2 <html>\r
3 <head>\r
4 \r
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>\r
6 <title>Ogg Vorbis Documentation</title>\r
7 \r
8 <style type="text/css">\r
9 body {\r
10   margin: 0 18px 0 18px;\r
11   padding-bottom: 30px;\r
12   font-family: Verdana, Arial, Helvetica, sans-serif;\r
13   color: #333333;\r
14   font-size: .8em;\r
15 }\r
16 \r
17 a {\r
18   color: #3366cc;\r
19 }\r
20 \r
21 img {\r
22   border: 0;\r
23 }\r
24 \r
25 #xiphlogo {\r
26   margin: 30px 0 16px 0;\r
27 }\r
28 \r
29 #content p {\r
30   line-height: 1.4;\r
31 }\r
32 \r
33 h1, h1 a, h2, h2 a, h3, h3 a {\r
34   font-weight: bold;\r
35   color: #ff9900;\r
36   margin: 1.3em 0 8px 0;\r
37 }\r
38 \r
39 h1 {\r
40   font-size: 1.3em;\r
41 }\r
42 \r
43 h2 {\r
44   font-size: 1.2em;\r
45 }\r
46 \r
47 h3 {\r
48   font-size: 1.1em;\r
49 }\r
50 \r
51 li {\r
52   line-height: 1.4;\r
53 }\r
54 \r
55 #copyright {\r
56   margin-top: 30px;\r
57   line-height: 1.5em;\r
58   text-align: center;\r
59   font-size: .8em;\r
60   color: #888888;\r
61   clear: both;\r
62 }\r
63 </style>\r
64 \r
65 </head>\r
66 \r
67 <body>\r
68 \r
69 <div id="xiphlogo">\r
70   <a href="http://www.xiph.org/"><img src="fish_xiph_org.png" alt="Fish Logo and Xiph.org"/></a>\r
71 </div>\r
72 \r
73 <h1>Ogg Vorbis I format specification: comment field and header specification</h1>\r
74 \r
75 <h1>Overview</h1>\r
76 \r
77 <p>The Vorbis text comment header is the second (of three) header\r
78 packets that begin a Vorbis bitstream. It is meant for short, text\r
79 comments, not arbitrary metadata; arbitrary metadata belongs in a\r
80 separate logical bitstream (usually an XML stream type) that provides\r
81 greater structure and machine parseability.</p>\r
82 \r
83 <p>The comment field is meant to be used much like someone jotting a\r
84 quick note on the bottom of a CDR. It should be a little information to\r
85 remember the disc by and explain it to others; a short, to-the-point\r
86 text note that need not only be a couple words, but isn't going to be\r
87 more than a short paragraph. The essentials, in other words, whatever\r
88 they turn out to be, eg:</p>\r
89 \r
90 <blockquote><p>\r
91 "Honest Bob and the Factory-to-Dealer-Incentives, _I'm Still Around_,\r
92 opening for Moxy Fr&uuml;vous, 1997"\r
93 </p></blockquote>\r
94 \r
95 <h1>Comment encoding</h1>\r
96 \r
97 <h2>Structure</h2>\r
98 \r
99 <p>The comment header logically is a list of eight-bit-clean vectors; the\r
100 number of vectors is bounded to 2^32-1 and the length of each vector\r
101 is limited to 2^32-1 bytes. The vector length is encoded; the vector\r
102 contents themselves are not null terminated. In addition to the vector\r
103 list, there is a single vector for vendor name (also 8 bit clean,\r
104 length encoded in 32 bits). For example, the 1.0 release of libvorbis \r
105 set the vendor string to "Xiph.Org libVorbis I 20020717".</p>\r
106 \r
107 <p>The comment header is decoded as follows:</p>\r
108 \r
109 <pre>\r
110   1) [vendor_length] = read an unsigned integer of 32 bits\r
111   2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets\r
112   3) [user_comment_list_length] = read an unsigned integer of 32 bits\r
113   4) iterate [user_comment_list_length] times {\r
114 \r
115        5) [length] = read an unsigned integer of 32 bits\r
116        6) this iteration's user comment = read a UTF-8 vector as [length] octets\r
117 \r
118      }\r
119 \r
120   7) [framing_bit] = read a single bit as boolean\r
121   8) if ( [framing_bit] unset or end of packet ) then ERROR\r
122   9) done.\r
123 </pre>\r
124 \r
125 <h2>Content vector format</h2>\r
126 \r
127 <p>The comment vectors are structured similarly to a UNIX environment variable.\r
128 That is, comment fields consist of a field name and a corresponding value and\r
129 look like:</p>\r
130 \r
131 <pre>\r
132 comment[0]="ARTIST=me"; \r
133 comment[1]="TITLE=the sound of Vorbis"; \r
134 </pre>\r
135 \r
136 <ul>\r
137 <li>A case-insensitive field name that may consist of ASCII 0x20 through\r
138 0x7D, 0x3D ('=') excluded. ASCII 0x41 through 0x5A inclusive (A-Z) is\r
139 to be considered equivalent to ASCII 0x61 through 0x7A inclusive\r
140 (a-z).</li>\r
141 <li>The field name is immediately followed by ASCII 0x3D ('='); \r
142 this equals sign is used to terminate the field name.</li>\r
143 <li>0x3D is followed by the 8 bit clean UTF-8 encoded value of the \r
144 field contents to the end of the field.</li>\r
145 </ul>\r
146 \r
147 <h3>Field names</h3>\r
148 \r
149 <p>Below is a proposed, minimal list of standard field names with a\r
150 description of intended use. No single or group of field names is\r
151 mandatory; a comment header may contain one, all or none of the names\r
152 in this list.</p>\r
153 \r
154 <dl>\r
155 \r
156 <dt>TITLE</dt>\r
157 <dd>Track/Work name</dd>\r
158 \r
159 <dt>VERSION</dt>\r
160 <dd>The version field may be used to differentiate multiple\r
161 versions of the same track title in a single collection.\r
162 (e.g. remix info)</dd>\r
163 \r
164 <dt>ALBUM</dt>\r
165 <dd>The collection name to which this track belongs</dd>\r
166 \r
167 <dt>TRACKNUMBER</dt>\r
168 <dd>The track number of this piece if part of a specific larger collection or album</dd>\r
169 \r
170 <dt>ARTIST</dt>\r
171 <dd>The artist generally considered responsible for the work. In popular music\r
172 this is usually the performing band or singer. For classical music it would be\r
173 the composer. For an audio book it would be the author of the original text.</dd>\r
174 \r
175 <dt>PERFORMER</dt>\r
176 <dd>The artist(s) who performed the work. In classical music this would be the\r
177 conductor, orchestra, soloists. In an audio book it would be the actor who did\r
178 the reading. In popular music this is typically the same as the ARTIST and\r
179 is omitted.</dd>\r
180 \r
181 <dt>COPYRIGHT</dt>\r
182 <dd>Copyright attribution, e.g., '2001 Nobody's Band' or '1999 Jack Moffitt'</dd>\r
183 \r
184 <dt>LICENSE</dt>\r
185 <dd>License information, eg, 'All Rights Reserved', 'Any\r
186 Use Permitted', a URL to a license such as a Creative Commons license\r
187 ("www.creativecommons.org/blahblah/license.html") or the EFF Open\r
188 Audio License ('distributed under the terms of the Open Audio\r
189 License. see http://www.eff.org/IP/Open_licenses/eff_oal.html for\r
190 details'), etc.</dd>\r
191 \r
192 <dt>ORGANIZATION</dt>\r
193 <dd>Name of the organization producing the track (i.e.\r
194 the 'record label')</dd>\r
195 \r
196 <dt>DESCRIPTION</dt>\r
197 <dd>A short text description of the contents</dd>\r
198 \r
199 <dt>GENRE</dt>\r
200 <dd>A short text indication of music genre</dd>\r
201 \r
202 <dt>DATE</dt>\r
203 <dd>Date the track was recorded</dd>\r
204 \r
205 <dt>LOCATION</dt>\r
206 <dd>Location where track was recorded</dd>\r
207 \r
208 <dt>CONTACT</dt>\r
209 <dd>Contact information for the creators or distributors of the track.\r
210 This could be a URL, an email address, the physical address of\r
211 the producing label.</dd>\r
212 \r
213 <dt>ISRC</dt>\r
214 <dd>ISRC number for the track; see <a href="http://www.ifpi.org/site-content/online/isrc_intro.html">the\r
215 ISRC intro page</a> for more information on ISRC numbers.</dd>\r
216 \r
217 </dl>\r
218 \r
219 <h3>Implications</h3>\r
220 \r
221 <ul>\r
222 <li>Field names should not be 'internationalized'; this is a\r
223 concession to simplicity not an attempt to exclude the majority of\r
224 the world that doesn't speak English. Field <emph>contents</emph>, \r
225 however, use the UTF-8 character encoding to allow easy representation \r
226 of any language.</li>\r
227 <li>We have the length of the entirety of the field and restrictions on\r
228 the field name so that the field name is bounded in a known way. Thus\r
229 we also have the length of the field contents.</li>\r
230 <li>Individual 'vendors' may use non-standard field names within\r
231 reason. The proper use of comment fields should be clear through\r
232 context at this point. Abuse will be discouraged.</li>\r
233 <li>There is no vendor-specific prefix to 'nonstandard' field names.\r
234 Vendors should make some effort to avoid arbitrarily polluting the\r
235 common namespace. We will generally collect the more useful tags\r
236 here to help with standardization.</li>\r
237 <li>Field names are not required to be unique (occur once) within a\r
238 comment header. As an example, assume a track was recorded by three\r
239 well know artists; the following is permissible, and encouraged:\r
240 <pre>\r
241               ARTIST=Dizzy Gillespie \r
242               ARTIST=Sonny Rollins \r
243               ARTIST=Sonny Stitt \r
244 </pre></li>\r
245 </ul>\r
246 \r
247 <h2>Encoding</h2> \r
248 \r
249 <p>The comment header comprises the entirety of the second bitstream\r
250 header packet. Unlike the first bitstream header packet, it is not\r
251 generally the only packet on the second page and may not be restricted\r
252 to within the second bitstream page. The length of the comment header\r
253 packet is (practically) unbounded. The comment header packet is not\r
254 optional; it must be present in the bitstream even if it is\r
255 effectively empty.</p>\r
256 \r
257 <p>The comment header is encoded as follows (as per Ogg's standard\r
258 bitstream mapping which renders least-significant-bit of the word to be\r
259 coded into the least significant available bit of the current\r
260 bitstream octet first):</p>\r
261 \r
262 <ol>\r
263 <li>Vendor string length (32 bit unsigned quantity specifying number of octets)</li>\r
264 <li>Vendor string ([vendor string length] octets coded from beginning of string\r
265 to end of string, not null terminated)</li>\r
266 <li>Number of comment fields (32 bit unsigned quantity specifying number of fields)</li>\r
267 <li>Comment field 0 length (if [Number of comment fields]>0; 32 bit unsigned\r
268 quantity specifying number of octets)</li>\r
269 <li>Comment field 0 ([Comment field 0 length] octets coded from beginning of\r
270 string to end of string, not null terminated)</li>\r
271 <li>Comment field 1 length (if [Number of comment fields]>1...)...</li>\r
272 </ol>\r
273 \r
274 <p>This is actually somewhat easier to describe in code; implementation of the above\r
275 can be found in vorbis/lib/info.c:_vorbis_pack_comment(),_vorbis_unpack_comment()</p>\r
276 \r
277 <div id="copyright">\r
278   The Xiph Fish Logo is a\r
279   trademark (&trade;) of Xiph.Org.<br/>\r
280 \r
281   These pages &copy; 1994 - 2005 Xiph.Org. All rights reserved.\r
282 </div>\r
283 \r
284 </body>\r
285 </html>\r