File: id3guide.html

package info (click to toggle)
libid3 3.05-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 560 kB
  • ctags: 568
  • sloc: cpp: 3,582; makefile: 85
file content (1282 lines) | stat: -rw-r--r-- 24,938 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<HTML>

<HEAD>

   <TITLE>ID3v2.3 Programming Guidelines</TITLE>

   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

   <META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (WinNT; I) [Netscape]">

</HEAD>

<BODY>



<TABLE CELLSPACING=0 CELLPADDING=0 WIDTH="100%" >

<TR>

<TD ALIGN=CENTER VALIGN=TOP><FONT SIZE=+3>ID3v2.3 Programming Guidelines</FONT>

</TD>



<TD ALIGN=RIGHT><IMG SRC="id3v2.gif" HEIGHT=50 WIDTH=52></TD>

</TR>

</TABLE>



<P>Applies to: ID3v2.3<BR>

Old versions:&nbsp;<A HREF="id3g-2.htm">ID3v2.2 Guidelines</A> (August

1998)</P>



<H2>Table of Contents</H2>



<P>1. <A HREF="#Intro">Introduction</A> <BR>

1.1. <A HREF="#Usage">Use of this document</A> <BR>

2. <A HREF="#id3v23new">What's new</A> in ID3v2.3? <BR>

3. Programming Considerations <BR>

&nbsp;&nbsp;&nbsp;&nbsp; 3.1 <A HREF="#padding">Padding</A> <BR>

&nbsp;&nbsp;&nbsp;&nbsp; 3.2 <A HREF="#ROmedia">Read-only media</A> <BR>

&nbsp;&nbsp;&nbsp;&nbsp; 3.3 <A HREF="#SmallFrames">&quot;Insignificant&quot;

frames</A> <BR>

&nbsp;&nbsp;&nbsp;&nbsp; 3.4 <A HREF="#iformat">Preferred image formats</A>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp; 3.5 <A HREF="#manytags">Multiple tags</A> <BR>

&nbsp;&nbsp;&nbsp;&nbsp; 3.6 <A HREF="#unsync">Unsynchronization</A> <BR>

4. Pitfalls &amp; General Advice <BR>

&nbsp;&nbsp;&nbsp;&nbsp; 4.1 <A HREF="#rtfm">RTFM</A> and yes, the details

matter! <BR>

&nbsp;&nbsp;&nbsp;&nbsp; 4.2 <A HREF="#cB4e">Compression before encryption</A>

<BR>

&nbsp;&nbsp;&nbsp;&nbsp; 4.3 <A HREF="#userErr">Validating user input</A>

<BR>

5. <A HREF="#Credit">Credits</A> <BR>

6. <A HREF="#Refs">References</A> <BR>

7. <A HREF="#copyright">Copyright &amp; Legal Notices</A> </P>



<P>

<HR></P>



<H2><A NAME="Intro"></A>Introduction</H2>



<P>There are many people who enjoy .MP3 compressed music. The MP3 specification

only defined the storage of musical data and did not provide the storage

of metadata related to the musical composition; e.g., title, composer and

artist, publisher, etc. The ID3 tag standard was created to remedy this

need... </P>



<P><B>Rationale:</B> Specifications are like grammar: they provide the

rules of formatting data but few clues as to how to speak concisely and

efficiently. The goal of this document is to answer the &quot;Should I

do...&quot; and &quot;Would doing X make it easier/faster/smaller...&quot;

type questions. </P>



<P><B>Audience:</B> This document is geared toward programmers dealing

directly with ID3v2.3 tags. There is a heavy slant towards writing tags

correctly since decoding is relatively straightforward. You should familiarize

yourself with the <A HREF="http://www.id3.org/develop.html">ID3v2 and related

standards</A> since this document refers to and uses the terminology from

those documents.</P>



<P><B>Coverage:</B>&nbsp;Although ID3v2 tags were created for use with

MPEG&nbsp;Layer-3 audio streams, flexibility was a goal from the start.

Even though much of this document refers to .MP3 files, the principles

are generally applicable to other formats.</P>



<P>

<HR WIDTH="85%"></P>



<H2><A NAME="Usage"></A>Use of this document</H2>



<P>These are merely Guidelines and as such they are not part of the ID3v2

standard. </P>



<OL>

<LI>If anything in this document contradicts the published ID3v2 standard,

then the standard shall prevail. The ID3v2 standard always has the final

word.</LI>



<LI>These Guidelines are not binding on anyone (whereas the standard <I>is</I>

binding, for obvious reasons.) This means you, as a programmer, should

never assume anyone else will abide by these guidelines. A protocol designer

once said: </LI>



<OL>

<P><I>&quot;Be flexible in what you accept, but strict in what you write.&quot;</I>

</P>

</OL>



<LI>Use your judgement and common sense.</LI>

</OL>



<P>

<HR WIDTH="85%"></P>



<H2><A NAME="id3v23new"></A>What's new in ID3v2.3?</H2>



<P>For starters, the naming convention changed. &quot;ID3v2&quot; now refers

to the family of frame-based tagging methods which utilize the 10-byte

header beginning with &quot;ID3&quot; followed by version information.

&quot;ID3v2<B>.3.0</B>&quot; refers to the informal standard dated September

1998. The informal standard formerly known as &quot;ID3v2&quot; has been

renamed to &quot;ID3v2.2&quot;</P>



<P>This document concentrates on ID3v2.3. Guidelines for ID3v2.2 are available

<A HREF="id3g-2.htm">here</A>.</P>



<P>A summary of the differences between ID3v2.3.0 and v2.2 are listed below.

Section numbers match the 

<A HREF="http://www.lysator.liu.se/id3v2/id3v2.3.0.txt">ID3v2.3.0 Informal Standard</A>.</P>



<H3>Structural changes:</H3>



<UL>

<LI>The <B>Frame Header</B> has been expanded. The Frame ID and Frame Size

fields are now four bytes long. Two bytes of Flags have been added. See

&sect;3.3.</LI>



<LI>An optional <B>Extended Header</B> can follow the ID3v2 tag header

&sect;3.2. Among other things, the extended header can store a CRC of the

entire tag.</LI>

</UL>



<H3>Clarifications:</H3>



<UL>

<LI>Pre-defined Frame IDs have been renamed to four characters long.</LI>



<LI>Unicode strings are now <I>required</I> to start with the Byte Order Mark (BOM)

character. See &sect;3.3.</LI>



<LI>Compression and encryption are done on a frame-by-frame basis. The

compression algorithm are those offered in zlib. &sect;3.3</LI>



<LI>Attached Picture [APIC] frame:&nbsp;the Image Format field has been

replaced MIME&nbsp;Type &sect;4.15.</LI>

</UL>



<P><B>New frames:</B> </P>



<UL>

<LI>Position Synchronization frame [POSS] &sect;4.22</LI>



<LI>Terms of Use frame [USER] &sect;4.23</LI>



<LI>Ownership frame [OWNE]  &sect;4.24</LI>



<LI>Commercial frame [COMR]  &sect;4.25</LI>



<LI>Private frame [PRIV]  &sect;4.28</LI>



<LI>Encryption Method Registration [ENCR] &sect;4.25</LI>



<LI>Group ID&nbsp;Registration [GRID] &sect;4.26.Used in conjunction with

new frame features described in  &sect;3.3</LI>



<LI>Text frames:&nbsp;Internet Radio Station Name [TRSN] and Internet Radio

Station Owner [TRSO]</LI>



<LI>URL&nbsp;link frames:&nbsp;Official internet radio station homepage

[WORS] and Payment [WPAY]</LI>

</UL>



<P><B>Deleted frames:</B> Encrypted meta-frame.</P>



<P>

<HR WIDTH="85%"></P>



<H2><A NAME="padding"></A>3.1 Padding</H2>



<P>The use of padding and how much should be used has been a matter of

debate ever since the first draft of ID3v2. (Take a look in the mailing

list <A HREF="http://www.id3.org/maillist.html">archives</A> for arguments.)</P>



<P>Before making recommendations let's quantify the issue:</P>



<UL>

<LI>A two minute song compressed at 44Khz and 128Kb/sec takes about 1990K&nbsp;(slightly

less than 2MB)&nbsp;of disk space. The average size of .MP3 files in my

collection is 3.5MB</LI>



<LI>ID3v1 and Lyrics3 tags are only 128 bytes and 3K, respectively - and

they served most songs just fine.</LI>



<LI>An ID3v2 tag with basic information (title, artist/composer, copyright)&nbsp;is

typically less than 1K in size. Toss in publisher information and lyrics

and it comes out to 3K or so.</LI>



<LI>Adding a 3K tag to a 2MB song will increase its size by 0.15%</LI>



<LI>Adding a 10K tag to a 2MB song increases its size by 0.5%</LI>



<LI>Suppose a&nbsp;CD-ROM holds 160 songs. Tagging all of them with 3K

tags requires less than a megabyte.</LI>

</UL>



<P>So in reality tags are tiny compared to the amount of audio data accompanying

it. A few KB of padding will not increase the file size noticeably. Remember

also the padding is required to be 0's, which means on a slow modem link

the padding is compressed significantly.</P>



<P>There is but one reason to use padding: since ID3v2 tags are stored

at the beginning of the file, it would be a major pain to rewrite the entire

multi-megabyte file to add a 50-byte frame. Padding reserves space in advance.</P>



<P>The issue then is how much padding should be used. </P>



<P><B>James's</B> recommendations:</P>



<UL>

<LI>What do most people care about?&nbsp;Probably title, artist, composer,

band, publisher, lyrics and copyright. 4K will usually be enough for all

that plus some miscellaneous information such as media type, file size,

playcounter, time codes, etc.</LI>



<LI>If you are editing an existing tag and run out of room (meaning you

must rewrite the entire file) then double the amount of space reserved

for the tag. For example, a file has a 4K tag filled with 3K of data. User

wants to add 2K of data, so you rewrite the file reserving 8K at the beginning;

then save the 5K of data and leaving 3K of padding. </LI>



<P>Obviously there should be an upper bound on doubling; a reasonable number

would be 16K or 32K. For example, a file has a 25K tag but only 4K of padding

left and the user wants to add 7K of new data. Rewrite the file and reserve

41K: save 28K of tag data and leave 13K of padding.</P>



<LI>Pictures are large and vary in size. If there are pictures then you

should add more padding; use your judgement here.</LI>



<LI>Do not forgo padding in files destined for read-only media or streaming

applications. The user may want to save the file to another location and

edit the tag.</LI>



<LI>Include an option to let the user disable padding if (s)he <I>really</I>

wants to.</LI>

</UL>



<P><B>Martin</B> has a good idea: Add enough padding to round out the file

to a full cluster. Obviously a minimum amount of padding has to be added

to be useful, but beyond the minimum, everything up to the next cluster

size will not occupy additional disk space. (Each operating system has

its own terminology; Microsoft uses <I>cluster,</I> Apple uses <I>allocation

block</I>. How files are stored on disk is beyond the scope of this document;

consult an OS&nbsp;book and API reference for details.)</P>



<P>Here are some common cluster sizes:</P>



<TABLE BORDER=1 >

<TR>

<TH ROWSPAN="2" NOWRAP>Operating system<BR>

(file system type)</TH>



<TH ALIGN=CENTER COLSPAN="7" NOWRAP>Disk size </TH>

</TR>



<TR>

<TD>&lt; 256MB</TD>



<TD>up to 512MB</TD>



<TD>up to 1GB</TD>



<TD>up to 2GB</TD>



<TD>up to 8GB</TD>



<TD>up to 16GB</TD>



<TD>&gt; 16GB</TD>

</TR>



<TR>

<TD>DOS&nbsp;&amp;&nbsp;Windows 95<BR>

(FAT16)</TD>



<TD ALIGN=CENTER>4K</TD>



<TD ALIGN=CENTER>8K</TD>



<TD ALIGN=CENTER>16K</TD>



<TD ALIGN=CENTER>32K</TD>



<TD ALIGN=CENTER COLSPAN="3">N/A<BR>

(FAT16 can't handle drives&nbsp;&gt;&nbsp;4GB)</TD>

</TR>



<TR>

<TD>Win95 OSR2 &amp;&nbsp;Win98<BR>

(FAT32)</TD>



<TD ALIGN=CENTER>N/A</TD>



<TD ALIGN=CENTER COLSPAN="4">4K</TD>



<TD ALIGN=CENTER>8K</TD>



<TD ALIGN=CENTER>16K or 32K</TD>

</TR>



<TR>

<TD>Windows NT<BR>

(NTFS)</TD>



<TD ALIGN=CENTER COLSPAN="7">0.5K to 64K<BR>

(0.5K to 4K clusters are most common)</TD>

</TR>



<TR>

<TD>MacOS pre-8.1<BR>

(HFS)</TD>



<TD ALIGN=CENTER>0.5K - 4K</TD>



<TD ALIGN=CENTER>4.5K - 8K</TD>



<TD ALIGN=CENTER>8.5K - 16K</TD>



<TD ALIGN=CENTER>16.5K - 32K</TD>



<TD ALIGN=CENTER COLSPAN="3">N/A<BR>

(HFS&nbsp;can't handle disks&nbsp;&gt;&nbsp;2GB)</TD>

</TR>



<TR>

<TD>MacOS 8.1 and later<BR>

(HFS+)</TD>



<TD ALIGN=CENTER>0.5K</TD>



<TD ALIGN=CENTER>1K</TD>



<TD ALIGN=CENTER>2K</TD>



<TD ALIGN=CENTER COLSPAN="4">Default is 4K; user-selectable up to 4K</TD>

</TR>



<TR>

<TD>CD-ROM, 650MB<BR>

(ISO&nbsp;9660)</TD>



<TD ALIGN=CENTER COLSPAN="3">always 2K</TD>

</TR>



<TR>

<TD>DVD-ROM<BR>

(UDF)</TD>



<TD ALIGN=CENTER COLSPAN="7">always 2K</TD>

</TR>

</TABLE>



<P>Advanced operating systems employ tricks to optimize disk space. For

example, Novell NetWare 4 uses 64K disk blocks but can split a block into

0.5K pieces, thus creating the illusion of 512-byte blocks. UNIX&nbsp;file

systems have their own methods to utilize disk space efficiently.</P>



<P><B>James's</B> shortcut on choosing an appropriate cluster size: 2K

(Nice even number, not too big, not too small)</P>



<H2><A NAME="ROmedia"></A>3.2 Read-only media</H2>



<P>Never assume a .MP3 file is writable unless the user is specifically

editing the tag. MP3 files can be stored on read-only media such as a CD-ROM

or a network share. If the user is editing the tag, it is an error if the

file is write-protected because the user's changes cannot be saved. If

a player is merely updating the playcounter or popularity-meter, it should

not pop up a message complaining the file cannot be written to. </P>



<P><B>James</B>: Include a visual cue to indicate whether the file is write-protected.

For example, a small icon similar in size and color to the stereo indicator

in WinAMP. A quick glance will determine whether certain settings will

be saved. </P>



<H2><A NAME="SmallFrames"></A>3.3 &quot;Insignificant&quot; frames</H2>



<P>&quot;Insignificant&quot; frames are small frames that don't necessarily

have meaning when a ID3v2 tag is created. The issue is whether the tag

editor should add these frames when they do not already exist. </P>



<P>For example, if Joe is adding tags to a fresh batch of .MP3 files, should

the tag editor include a playcounter [PCNT] frame in the tag? The tag editor

has no idea how many times the particular file has been played; unless

Joe tells it otherwise, the editor has to create a [PCNT] frame with a

count of 0. </P>



<P>There are two ways to look at this. On the one hand, the frame is so

small it takes almost no effort to include it. Since there will usually

be a few hundred bytes of padding, the ten bytes used by the counter frame

is in a sense &quot;free.&quot; A player will probably add it later anyway

when the file is used. </P>



<P>On the other hand, if the frame is not holding useful information, why

bother adding it? Padding, if used, effectively reserves space for these

frames. Consider also the absence of a frame can be meaningful: the lack

of a playcounter frame may indicate &quot;I do not know how many times

this piece has been played&quot; as opposed to a count of 0, which

indicates &quot;This song has never been played.&quot; </P>



<P>These can be considered &quot;insignificant&quot; frames: </P>



<UL>

<LI>Playcounter [PCNT]<BR>

(<B>James</B>: an integrated ripper-encoder-tagger can include a playcount

of 0 in newly created files, since by definition they have never been used..)

</LI>



<LI>Others, anyone?</LI>

</UL>



<P><B>Martin</B>: It is considered good manner to allow the user to disable

writing of frames (s)he doesn't want. At least in an advanced menu in a

hidden place. Perhaps the user doesn't want the TSI, TLE, TMT and MLL frame

to be added automatically, even though it might be the default setting.</P>



<H2><A NAME="iformat"></A>3.4 Preferred image formats</H2>



<P>A question Martin gets often is why the ID3v2 document says &quot;...

PNG&nbsp;and JPEG picture format should be used...&quot; Interoperability

means it is almost guaranteed another ID3v2 tag/picture decoder can handle

the PNG and JPEG formats. The chances a Macintosh application can display

BMP files are slim; likewise, the complexities of EPS and TIFF are best

left out.</P>



<P>Consider these other arguments favoring PNG and JPEG:</P>



<UL>

<LI>PNG compresses better than BMP, GIF and most other lossless formats.</LI>



<LI>JPEG has superior compression to most formats, especially for photographic

pictures. (JPEG is not suitable for line-art and computer-generated graphics

- use PNG for these.)</LI>



<LI>Both formats are patent- and royalty-free (which is not the case with

GIF, whose LZW compression algorithm is patented by Unisys.) </LI>

</UL>



<P><B>Martin</B>: The freedom to use whatever format you like in the picture

frame is of course a freedom under responsibility. Do you want to make

cross platform tags? Do you want to avoid legal trouble, at least for the

principle? If so, use PNG and JPEG.</P>



<P><B>Dirk</B>: Applications may want to convert the incoming picture type

to PNG or JPEG first, or failing that, at least inform the user that they

<I>should</I> be using PNG or JPEG, but allow the user to override this

if they insist on using, say, a PCX.</P>



<H2><A NAME="manytags"></A>3.5 Multiple tags</H2>



<P>Decoders should be prepared to handle multiple ID3v2 tags per stream.

This is especially important for players/decoders wanting to handle netradio-type

applications since the notion of distinct files may not apply. </P>



<P><B>Dirk</B>: An easy way to achieve this would be to use a central 'frame

dispatch' routine, kind of like a demultiplexer. </P>



<H2><A NAME="unsync"></A>3.6 Unsynchronization</H2>



<P>The ID3v2 standard states&nbsp;&quot;The only purpose of the 'unsychronisation

scheme' is to make the ID3v2 tag as compatible as possible with existing

software <I>[at the time the ID3v2.2 standard was drafted]</I>&quot; What

are the implications?</P>



<OL>

<LI>.MP3 decoders, regardless of age, will not be affected by extraneous 

data (i.e., tags)&nbsp;that does not contain a MPEG&nbsp;sync sequence.</LI>



<LI>There is minimal impact if a decoder does not recognize ID3v2 tags

but encounters something with a sync sequence. At worst a click or pop

will be heard at the beginning of the piece, as if some data corruption

has occurred.</LI>



<LI>New software is expected to take advantage of ID3v2. Unsynchronization

is not necessary with ID3v2 compliant software.</LI>

</OL>



<P>(Software which does not behave according to items 1 and 2 above are

categorically deemed &quot;broken.&quot; Microsoft's Media Player is an

example of such software.)</P>



<P><B>Martin</B>: I believe that unsynchronization should be done as seldom

as possible since it increases the size of the tag as well as the parsing

time. In other words, I think unsynchronization should be turned off as

default.</P>



<P>However, it is important to be able to undo unsynchronization when reading

tags; otherwise unsynchronized tags will not be read correctly.</P>



<P>

<HR WIDTH="85%"></P>



<H2><A NAME="rtfm"></A>4.1 RTFM (details are important!)</H2>



<P>When the ID3v2 document refers to another standard it is assumed that

the implementor is familiar with that standard as well. When it says URL

it does not mean 'www.buymusic.com', it means 'http://www.buymusic.com/'

A&nbsp;&quot;URL&nbsp;containing an e-mail address&quot; must include the

'mailto:' qualifier. Those who at least take a quick look at the related

standards will not make these kinds of mistakes.</P>



<P>If these details are so important, why aren't they spelled out in the

ID3v2 standard? According to Martin, &quot;There has been people who said

to me, 'You must write these kind of things in the document, or else people

will make these mistakes.' The latest ID3 v2.01 draft is <I>only</I> 74,657

bytes of pure text because I did not. Guess why there are references to

the standards in the document!&quot; </P>



<H2><A NAME="cB4e"></A>4.2 Compression before encryption</H2>



<P>Encryption works by scrambling data to produce what amounts to random

bits for an attacker. Data compression works by replacing or removing redundant

information. It follows that the output of any decent crypto algorithm

will not be compressible; therefore if you wish to use both compression

and encryption, you must compress the data before encrypting it. </P>



<P>Compressing before encryption also affords better security, since predictable

headers and such will be hidden by compression. </P>



<P>Remember: <I>compression</I> comes before <I>encryption</I> in the dictionary

(at least in English) and that is how it should be in your application.

</P>



<H2><A NAME="userErr"></A>4.3 Validating user input</H2>



<P>Never trust the input from the user to be sensible or formatted correctly.

Is the ISRC a valid one? Does the month 13 exist? Could this piece of music

be from disc 5 out of a 3 disc set?</P>



<P><B>Dirk</B>:&nbsp;Personally, I think having input validation occur

when the user signifies that the tag is &quot;finished&quot; is a good

way of going about it, if only because I know I'll get half way through

something and want to stop and do something else before I forget.</P>



<P><B>James</B>:&nbsp;Extremely strict validation becomes restrictions

on versatility and usability. An option to turn off or accept potentially

invalid data can be included somewhere. For example, by default Microsoft

Visual Basic checks for syntax errors as code is entered; however, users

can disable that feature if they wish to delay syntax checking until compile

time. </P>



<P>Things to watch out for (this is by no means an all-inclusive list):</P>



<UL>

<LI>Properly formatted URLs (see <A HREF="#rtfm">RTFM</A>, above.)&nbsp;But

should your application verify whether the URL actually exists? That may

be too complicated; Martin and James's opinion is no verification.</LI>



<LI>Proper MIME types.</LI>



<LI>Are characters valid?&nbsp;Most text fields forbid control characters,

even newlines. NULs are not allowed except in Unicode strings or to indicate

end-of-string for terminated strings.</LI>



<LI>Numerical strings must consist solely of the characters '0' through

'9'</LI>



<LI>Are lists handled properly?&nbsp;The list separator is a slash:&nbsp;/

What happens if the user enters a / in an item?</LI>



<LI>Are characters such as ( escaped where necessary?</LI>



<LI>Do dates and times make sense? Years must be four digits long and be

in the right century.&nbsp;(No Y2K problems here!)</LI>



<LI>Is an image really the format the user claims it is? Some people believe

renaming a .BMP file to .PNG will change its format accordingly.</LI>

</UL>



<P>Your application should never crash because the user does something

stupid. Likewise, your application should not crash because of erroneous

or malformed data in a tag. It is particularly important your application

can recognize Unicode text frames and ignore them if the operating system

or your program cannot handle Unicode.</P>



<P>

<HR WIDTH="85%"></P>



<H2><A NAME="Credit"></A>Credits &amp; Contributors</H2>



<UL>

<LI><A HREF="mailto:dirk@id3.org">Dirk Mahoney</A>, creator of the <A HREF="http://www.id3.org/id3lib/">ID3Lib</A>

C++ tag processing library.</LI>



<LI><A HREF="mailto:merlin@starr.econ.nyu.edu">James Lin</A>, author of

these Guidelines.</LI>



<LI><A HREF="mailto:nilsson@id3.org">Martin Nilsson</A>, author of the

ID3v2 standard.</LI>

</UL>



<H2><A NAME="Refs"></A>References</H2>



<UL>

<LI><A HREF="http://www.id3.org/">www.id3.org</A>: Home of the <A HREF="http://www.id3.org/develop.html">ID3v2

Informal Standard</A> and lots of other useful material.</LI>

</UL>



<P>

<HR WIDTH="85%"></P>



<H2><A NAME="copyright"></A>Copyright &amp; Legal Notice</H2>



<P>Copyright &copy; 1998 James Lin and Merlin's Workshop. </P>



<P>The goal of this document is to provide hints on how to implement the

ID3v2 standard(s) correctly and efficiently. Distribution of this document

is unlimited as long as no changes are made to its content: </P>



<P><B>This document and translations of it may be copied and furnished

to others, in any format or medium, provided no modifications are made

to the content unless written permission has been obtained from the author.</B>

</P>



<P><B>This document is provided &quot;AS IS&quot; without warranty of any

kind, either expressed or implied, including but not limited to, the implied

warranties of merchantability and fitness for a particular purpose.</B>

</P>



<P><B>In no event unless required by applicable law will the author of

this document be liable for damages, including any general, special, incidental

or consequential damages arising out of the use or inability to use any

information (including but not limited to loss or corruption of data or

losses sustained by third parties), even if the author has been advised

of the possibility of such damages.</B> </P>



<P>

<HR WIDTH="100%"><A HREF="../copy.htm">Copyright</A> &copy; 1998 Merlin's

Workshop. <I>Last updated October 17, 1998</I> </P>



</BODY>

</HTML>