[xiph-cvs] cvs commit: ices/src id3.c
Brendan
brendan at xiph.org
Wed Mar 5 14:54:35 PST 2003
brendan 03/03/05 17:54:35
Modified: src id3.c
Log:
Apparently the ID3v2.3 frame length isn't synchsafe. The official specification is
ambiguous and iTunes disagrees, but other ID3 code I've looked at seems to think
so, and the v2.3 files I've found in the wild confirm this.
Revision Changes Path
1.21 +21 -1 ices/src/id3.c
Index: id3.c
===================================================================
RCS file: /cvs/ice/ices/src/id3.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- id3.c 5 Mar 2003 16:15:44 -0000 1.20
+++ id3.c 5 Mar 2003 22:54:35 -0000 1.21
@@ -64,6 +64,7 @@
static int id3v2_skip_data (input_stream_t* source, id3v2_tag* tag, size_t len);
static int id3v2_decode_synchsafe (unsigned char* synchsafe);
static int id3v2_decode_synchsafe3 (unsigned char* synchsafe);
+static int id3v2_decode_unsafe (unsigned char* in);
/* Global function definitions */
@@ -177,7 +178,9 @@
remaining -= rv;
}
- ices_metadata_set (tag.artist, tag.title);
+ /* allow fallback to ID3v1 */
+ if (tag.artist || tag.title)
+ ices_metadata_set (tag.artist, tag.title);
ices_util_free (tag.artist);
ices_util_free (tag.title);
@@ -232,6 +235,9 @@
if (tag->major_version < 3) {
len = id3v2_decode_synchsafe3 (hdr + 3);
hdr[3] = '\0';
+ } else if (tag->major_version == 3) {
+ len = id3v2_decode_unsafe (hdr + 4);
+ hdr[4] = '\0';
} else {
len = id3v2_decode_synchsafe (hdr + 4);
hdr[4] = '\0';
@@ -326,6 +332,20 @@
res = synchsafe[2];
res |= synchsafe[1] << 7;
res |= synchsafe[0] << 14;
+
+ return res;
+}
+
+/* id3v2.3 badly specifies frame length */
+static int
+id3v2_decode_unsafe (unsigned char* in)
+{
+ int res;
+
+ res = in[3];
+ res |= in[2] << 8;
+ res |= in[1] << 16;
+ res |= in[0] << 24;
return res;
}
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list