3 * libid3tag - ID3 tag manipulation library
4 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * $Id: compat.gperf,v 1.11 2004/01/23 09:41:32 rob Exp $
43 # define EQ(id) #id, 0
44 # define OBSOLETE 0, 0
45 # define TX(id) #id, translate_##id
47 static id3_compat_func_t translate_TCON;
52 # ID3v2.2 and ID3v2.3 frames
54 # Only obsolete frames or frames with an equivalent ID3v2.4 frame ID are
55 # listed here. If a frame ID is not listed, it is assumed that the same
56 # frame ID is itself the equivalent ID3v2.4 frame ID.
58 # This list may also include frames with new content interpretations; the
59 # translation function will rewrite the contents to comply with ID3v2.4.
61 BUF, EQ(RBUF) /* Recommended buffer size */
62 CNT, EQ(PCNT) /* Play counter */
63 COM, EQ(COMM) /* Comments */
64 CRA, EQ(AENC) /* Audio encryption */
65 CRM, OBSOLETE /* Encrypted meta frame [obsolete] */
66 EQU, OBSOLETE /* Equalization [obsolete] */
67 EQUA, OBSOLETE /* Equalization [obsolete] */
68 ETC, EQ(ETCO) /* Event timing codes */
69 GEO, EQ(GEOB) /* General encapsulated object */
70 IPL, EQ(TIPL) /* Involved people list */
71 IPLS, EQ(TIPL) /* Involved people list */
72 LNK, EQ(LINK) /* Linked information */
73 MCI, EQ(MCDI) /* Music CD identifier */
74 MLL, EQ(MLLT) /* MPEG location lookup table */
75 PIC, EQ(APIC) /* Attached picture */
76 POP, EQ(POPM) /* Popularimeter */
77 REV, EQ(RVRB) /* Reverb */
78 RVA, OBSOLETE /* Relative volume adjustment [obsolete] */
79 RVAD, OBSOLETE /* Relative volume adjustment [obsolete] */
80 SLT, EQ(SYLT) /* Synchronised lyric/text */
81 STC, EQ(SYTC) /* Synchronised tempo codes */
82 TAL, EQ(TALB) /* Album/movie/show title */
83 TBP, EQ(TBPM) /* BPM (beats per minute) */
84 TCM, EQ(TCOM) /* Composer */
85 TCO, TX(TCON) /* Content type */
86 TCON, TX(TCON) /* Content type */
87 TCR, EQ(TCOP) /* Copyright message */
88 TDA, OBSOLETE /* Date [obsolete] */
89 TDAT, OBSOLETE /* Date [obsolete] */
90 TDY, EQ(TDLY) /* Playlist delay */
91 TEN, EQ(TENC) /* Encoded by */
92 TFT, EQ(TFLT) /* File type */
93 TIM, OBSOLETE /* Time [obsolete] */
94 TIME, OBSOLETE /* Time [obsolete] */
95 TKE, EQ(TKEY) /* Initial key */
96 TLA, EQ(TLAN) /* Language(s) */
97 TLE, EQ(TLEN) /* Length */
98 TMT, EQ(TMED) /* Media type */
99 TOA, EQ(TOPE) /* Original artist(s)/performer(s) */
100 TOF, EQ(TOFN) /* Original filename */
101 TOL, EQ(TOLY) /* Original lyricist(s)/text writer(s) */
102 TOR, EQ(TDOR) /* Original release year [obsolete] */
103 TORY, EQ(TDOR) /* Original release year [obsolete] */
104 TOT, EQ(TOAL) /* Original album/movie/show title */
105 TP1, EQ(TPE1) /* Lead performer(s)/soloist(s) */
106 TP2, EQ(TPE2) /* Band/orchestra/accompaniment */
107 TP3, EQ(TPE3) /* Conductor/performer refinement */
108 TP4, EQ(TPE4) /* Interpreted, remixed, or otherwise modified by */
109 TPA, EQ(TPOS) /* Part of a set */
110 TPB, EQ(TPUB) /* Publisher */
111 TRC, EQ(TSRC) /* ISRC (international standard recording code) */
112 TRD, OBSOLETE /* Recording dates [obsolete] */
113 TRDA, OBSOLETE /* Recording dates [obsolete] */
114 TRK, EQ(TRCK) /* Track number/position in set */
115 TSI, OBSOLETE /* Size [obsolete] */
116 TSIZ, OBSOLETE /* Size [obsolete] */
117 TSS, EQ(TSSE) /* Software/hardware and settings used for encoding */
118 TT1, EQ(TIT1) /* Content group description */
119 TT2, EQ(TIT2) /* Title/songname/content description */
120 TT3, EQ(TIT3) /* Subtitle/description refinement */
121 TXT, EQ(TEXT) /* Lyricist/text writer */
122 TXX, EQ(TXXX) /* User defined text information frame */
123 TYE, OBSOLETE /* Year [obsolete] */
124 TYER, OBSOLETE /* Year [obsolete] */
125 UFI, EQ(UFID) /* Unique file identifier */
126 ULT, EQ(USLT) /* Unsynchronised lyric/text transcription */
127 WAF, EQ(WOAF) /* Official audio file webpage */
128 WAR, EQ(WOAR) /* Official artist/performer webpage */
129 WAS, EQ(WOAS) /* Official audio source webpage */
130 WCM, EQ(WCOM) /* Commercial information */
131 WCP, EQ(WCOP) /* Copyright/legal information */
132 WPB, EQ(WPUB) /* Publishers official webpage */
133 WXX, EQ(WXXX) /* User defined URL link frame */
137 int translate_TCON(struct id3_frame *frame, char const *oldid,
138 id3_byte_t const *data, id3_length_t length)
140 id3_byte_t const *end;
141 enum id3_field_textencoding encoding;
142 id3_ucs4_t *string = 0, *ptr, *endptr;
145 /* translate old TCON syntax into multiple strings */
147 assert(frame->nfields == 2);
149 encoding = ID3_FIELD_TEXTENCODING_ISO_8859_1;
153 if (id3_field_parse(&frame->fields[0], &data, end - data, &encoding) == -1)
156 string = id3_parse_string(&data, end - data, encoding, 0);
161 while (*ptr == '(') {
166 while (*endptr && *endptr != ')')
172 if (id3_field_addstring(&frame->fields[1], ptr) == -1)
178 if (*ptr && id3_field_addstring(&frame->fields[1], ptr) == -1)
193 * NAME: compat->fixup()
194 * DESCRIPTION: finish compatibility translations
196 int id3_compat_fixup(struct id3_tag *tag)
198 struct id3_frame *frame;
200 id3_ucs4_t timestamp[17] = { 0 };
203 /* create a TDRC frame from obsolete TYER/TDAT/TIME frames */
210 * TDRC: yyyy-MM-ddTHH:mm
214 while ((frame = id3_tag_findframe(tag, ID3_FRAME_OBSOLETE, index++))) {
216 id3_byte_t const *data, *end;
218 enum id3_field_textencoding encoding;
221 id = id3_field_getframeid(&frame->fields[0]);
224 if (strcmp(id, "TYER") != 0 && strcmp(id, "YTYE") != 0 &&
225 strcmp(id, "TDAT") != 0 && strcmp(id, "YTDA") != 0 &&
226 strcmp(id, "TIME") != 0 && strcmp(id, "YTIM") != 0)
229 data = id3_field_getbinarydata(&frame->fields[1], &length);
237 encoding = id3_parse_uint(&data, 1);
238 string = id3_parse_string(&data, end - data, encoding, 0);
240 if (id3_ucs4_length(string) < 4) {
245 if (strcmp(id, "TYER") == 0 ||
246 strcmp(id, "YTYE") == 0) {
247 timestamp[0] = string[0];
248 timestamp[1] = string[1];
249 timestamp[2] = string[2];
250 timestamp[3] = string[3];
252 else if (strcmp(id, "TDAT") == 0 ||
253 strcmp(id, "YTDA") == 0) {
255 timestamp[5] = string[2];
256 timestamp[6] = string[3];
258 timestamp[8] = string[0];
259 timestamp[9] = string[1];
261 else { /* TIME or YTIM */
263 timestamp[11] = string[0];
264 timestamp[12] = string[1];
266 timestamp[14] = string[2];
267 timestamp[15] = string[3];
276 frame = id3_frame_new("TDRC");
282 if (id3_field_settextencoding(&frame->fields[0],
283 ID3_FIELD_TEXTENCODING_ISO_8859_1) == -1 ||
284 id3_field_setstrings(&frame->fields[1], 1, &strings) == -1 ||
285 id3_tag_attachframe(tag, frame) == -1) {
286 id3_frame_delete(frame);