Update of /cvsroot/audacity/lib-src/libid3tag
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv12006
Modified Files:
frame.c id3tag.h tag.c
Log Message:
Forward porting id3v2.3 fix from 1.2 branch.
Index: id3tag.h
===================================================================
RCS file: /cvsroot/audacity/lib-src/libid3tag/id3tag.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- id3tag.h 8 Jun 2004 06:38:15 -0000 1.3
+++ id3tag.h 29 Apr 2007 05:10:24 -0000 1.4
@@ -131,6 +131,8 @@
/* library options */
+#define ID3_TAG_HAS_TAG_OPTION_ID3V2_3
+
enum {
ID3_TAG_OPTION_UNSYNCHRONISATION = 0x0001, /* use unsynchronisation */
ID3_TAG_OPTION_COMPRESSION = 0x0002, /* use compression */
@@ -139,7 +141,8 @@
ID3_TAG_OPTION_APPENDEDTAG = 0x0010, /* tag will be appended */
ID3_TAG_OPTION_FILEALTERED = 0x0020, /* audio data was altered */
- ID3_TAG_OPTION_ID3V1 = 0x0100 /* render ID3v1/ID3v1.1 tag */
+ ID3_TAG_OPTION_ID3V1 = 0x0100,/* render ID3v1/ID3v1.1 tag */
+ ID3_TAG_OPTION_ID3V2_3 = 0x0200 /* render ID3v2.3 tag */
};
struct id3_frame {
Index: tag.c
===================================================================
RCS file: /cvsroot/audacity/lib-src/libid3tag/tag.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tag.c 8 Jun 2004 06:38:15 -0000 1.3
+++ tag.c 29 Apr 2007 05:10:24 -0000 1.4
@@ -762,6 +762,155 @@
}
/*
+ * NAME: v2_3_render()
+ * DESCRIPTION: render a v2.3 ID3 tag for compatibility
+ * AUTHOR: Dominic Mazzoni
+ */
+
+#define ID3V2_3_TAG_VERSION 0x0300
+#define ID3V2_3_TAG_FLAG_KNOWNFLAGS 0xc0
+
+id3_length_t v2_3_render(struct id3_tag const *tag, id3_byte_t *buffer)
+{
+ id3_length_t size = 0;
+ id3_byte_t **ptr,
+ *header_ptr = 0, *tagsize_ptr = 0, *crc_ptr = 0, *frames_ptr = 0;
+ int flags, extendedflags;
+ unsigned int i;
+
+ assert(tag);
+
+ /* a tag must contain at least one (renderable) frame */
+
+ for (i = 0; i < tag->nframes; ++i) {
+ if (id3_frame_render(tag->frames[i], 0, 0) > 0)
+ break;
+ }
+
+ if (i == tag->nframes)
+ return 0;
+
+ ptr = buffer ? &buffer : 0;
+
+ /* get flags */
+
+ flags = tag->flags & ID3V2_3_TAG_FLAG_KNOWNFLAGS;
+ extendedflags = tag->extendedflags & ID3_TAG_EXTENDEDFLAG_KNOWNFLAGS;
+
+ extendedflags &= ~ID3_TAG_EXTENDEDFLAG_CRCDATAPRESENT;
+ if (tag->options & ID3_TAG_OPTION_CRC)
+ extendedflags |= ID3_TAG_EXTENDEDFLAG_CRCDATAPRESENT;
+
+ extendedflags &= ~ID3_TAG_EXTENDEDFLAG_TAGRESTRICTIONS;
+ if (tag->restrictions)
+ extendedflags |= ID3_TAG_EXTENDEDFLAG_TAGRESTRICTIONS;
+
+
+ extendedflags = 0;
+
+
+ flags &= ~ID3_TAG_FLAG_UNSYNCHRONISATION;
+ if (tag->options & ID3_TAG_OPTION_UNSYNCHRONISATION)
+ flags |= ID3_TAG_FLAG_UNSYNCHRONISATION;
+
+ flags &= ~ID3_TAG_FLAG_EXTENDEDHEADER;
+ if (extendedflags)
+ flags |= ID3_TAG_FLAG_EXTENDEDHEADER;
+
+ /* header */
+
+ if (ptr)
+ header_ptr = *ptr;
+
+ size += id3_render_immediate(ptr, "ID3", 3);
+ size += id3_render_int(ptr, ID3V2_3_TAG_VERSION, 2);
+ size += id3_render_int(ptr, flags, 1);
+
+ if (ptr)
+ tagsize_ptr = *ptr;
+
+ size += id3_render_syncsafe(ptr, 0, 4);
+
+ /* extended header */
+
+ if (flags & ID3_TAG_FLAG_EXTENDEDHEADER) {
+ id3_length_t ehsize = 0;
+ id3_byte_t *ehsize_ptr = 0;
+
+ if (ptr)
+ ehsize_ptr = *ptr;
+
+ ehsize += id3_render_syncsafe(ptr, 0, 4);
+ ehsize += id3_render_int(ptr, 1, 1);
+ ehsize += id3_render_int(ptr, extendedflags, 1);
+
+ if (extendedflags & ID3_TAG_EXTENDEDFLAG_TAGISANUPDATE)
+ ehsize += id3_render_int(ptr, 0, 1);
+
+ if (extendedflags & ID3_TAG_EXTENDEDFLAG_CRCDATAPRESENT) {
+ ehsize += id3_render_int(ptr, 5, 1);
+
+ if (ptr)
+ crc_ptr = *ptr;
+
+ ehsize += id3_render_syncsafe(ptr, 0, 5);
+ }
+
+ if (extendedflags & ID3_TAG_EXTENDEDFLAG_TAGRESTRICTIONS) {
+ ehsize += id3_render_int(ptr, 1, 1);
+ ehsize += id3_render_int(ptr, tag->restrictions, 1);
+ }
+
+ if (ehsize_ptr)
+ id3_render_syncsafe(&ehsize_ptr, ehsize, 4);
+
+ size += ehsize;
+ }
+
+ /* frames */
+
+ if (ptr)
+ frames_ptr = *ptr;
+
+ for (i = 0; i < tag->nframes; ++i)
+ size += id3_frame_render(tag->frames[i], ptr, tag->options);
+
+ /* padding */
+
+ if (!(flags & ID3_TAG_FLAG_FOOTERPRESENT)) {
+ if (size < tag->paddedsize)
+ size += id3_render_padding(ptr, 0, tag->paddedsize - size);
+ else if (tag->options & ID3_TAG_OPTION_UNSYNCHRONISATION) {
+ if (ptr == 0)
+ size += 1;
+ else {
+ if ((*ptr)[-1] == 0xff)
+ size += id3_render_padding(ptr, 0, 1);
+ }
+ }
+ }
+
+ /* patch tag size and CRC */
+
+ if (tagsize_ptr)
+ id3_render_syncsafe(&tagsize_ptr, size - 10, 4);
+
+ if (crc_ptr) {
+ id3_render_syncsafe(&crc_ptr,
+ id3_crc_compute(frames_ptr, *ptr - frames_ptr), 5);
+ }
+
+ /* footer */
+
+ if (flags & ID3_TAG_FLAG_FOOTERPRESENT) {
+ size += id3_render_immediate(ptr, "3DI", 3);
+ size += id3_render_binary(ptr, header_ptr + 3, 7);
+ }
+
+ return size;
+}
+
+/*
* NAME: tag->render()
* DESCRIPTION: render a complete ID3 tag
*/
@@ -778,6 +927,9 @@
if (tag->options & ID3_TAG_OPTION_ID3V1)
return v1_render(tag, buffer);
+ if (tag->options & ID3_TAG_OPTION_ID3V2_3)
+ return v2_3_render(tag, buffer);
+
/* a tag must contain at least one (renderable) frame */
for (i = 0; i < tag->nframes; ++i) {
Index: frame.c
===================================================================
RCS file: /cvsroot/audacity/lib-src/libid3tag/frame.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- frame.c 8 Jun 2004 06:38:15 -0000 1.3
+++ frame.c 29 Apr 2007 05:10:24 -0000 1.4
@@ -539,8 +539,12 @@
if (flags & (ID3_FRAME_FLAG_FORMATFLAGS & ~ID3_FRAME_FLAG_KNOWNFLAGS)) {
size += id3_render_binary(ptr, frame->encoded, frame->encoded_length);
- if (size_ptr)
+ if (size_ptr) {
+ if (options & ID3_TAG_OPTION_ID3V2_3)
+ id3_render_int(&size_ptr, size - 10, 4);
+ else
id3_render_syncsafe(&size_ptr, size - 10, 4);
+ }
return size;
}
@@ -617,8 +621,12 @@
/* patch size and flags */
- if (size_ptr)
+ if (size_ptr) {
+ if (options & ID3_TAG_OPTION_ID3V2_3)
+ id3_render_int(&size_ptr, size - 10, 4);
+ else
id3_render_syncsafe(&size_ptr, size - 10, 4);
+ }
if (flags_ptr)
id3_render_int(&flags_ptr, flags, 2);
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs