|
From: John M M. <jo...@us...> - 2002-06-01 05:24:02
|
Update of /cvsroot/squeak/squeak/platforms/Cross/plugins/Mpeg3Plugin/libmpeg
In directory usw-pr-cvs1:/tmp/cvs-serv31644/squeak/platforms/Cross/plugins/Mpeg3Plugin/libmpeg
Modified Files:
mpeg3io.c
Log Message:
1.4 Jason Dufair <ja...@du...> support for ID3v2 stuff
Index: mpeg3io.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/Cross/plugins/Mpeg3Plugin/libmpeg/mpeg3io.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** mpeg3io.c 5 May 2002 01:26:04 -0000 1.3
--- mpeg3io.c 1 Jun 2002 05:24:00 -0000 1.4
***************
*** 31,34 ****
--- 31,39 ----
/* Changed Sept 15th by John M McIntosh to support Macintosh & Squeak
*/
+ /* Changed May 23 by Jason Dufair to handle mp3 files with ID3v2 tags
+ (specifically ones with binary data in them)
+ - Added mpeg3io_get_id3v2_size
+ - modified all fseek's to use the id3v2 offset
+ */
#include "mpeg3private.h"
#include "mpeg3protos.h"
***************
*** 78,88 ****
fseek(fs->fd, 0, SEEK_END);
! fs->total_bytes = ftell(fs->fd);
! fseek(fs->fd, 0, SEEK_SET);
return fs->total_bytes;
}
int mpeg3io_open_file(mpeg3_fs_t *fs)
{
/* Need to perform authentication before reading a single byte. */
mpeg3_get_keys(fs->css, fs->path);
--- 83,105 ----
fseek(fs->fd, 0, SEEK_END);
! fs->total_bytes = ftell(fs->fd) - fs->id3v2_offset;
! fseek(fs->fd, fs->id3v2_offset, SEEK_SET);
return fs->total_bytes;
}
+ int mpeg3io_get_id3v2_size(mpeg3_fs_t *fs)
+ {
+ unsigned long synchsafe_size = 0;
+
+ fseek(fs->fd, 6, SEEK_SET);
+
+ synchsafe_size = mpeg3io_read_int32(fs);
+
+ return ((synchsafe_size & 0xff) | (synchsafe_size & 0xff00) >> 1 | (synchsafe_size & 0xff0000) >> 2 | (synchsafe_size & 0xff000000) >> 3) + 10;
+ }
+
int mpeg3io_open_file(mpeg3_fs_t *fs)
{
+ unsigned int bits;
/* Need to perform authentication before reading a single byte. */
mpeg3_get_keys(fs->css, fs->path);
***************
*** 94,97 ****
--- 111,125 ----
}
+ bits = mpeg3io_read_int32(fs);
+
+ if ((bits >> 8) == MPEG3_ID3_PREFIX)
+ {
+ fs->id3v2_offset = mpeg3io_get_id3v2_size(fs);
+ } else {
+ fs->id3v2_offset = 0;
+ }
+
+ mpeg3io_seek(fs, 0);
+
fs->total_bytes = mpeg3io_get_total_bytes(fs);
***************
*** 154,158 ****
{
fs->current_byte = byte;
! return fseek(fs->fd, byte, SEEK_SET);
}
--- 182,186 ----
{
fs->current_byte = byte;
! return fseek(fs->fd, byte + fs->id3v2_offset, SEEK_SET);
}
***************
*** 160,164 ****
{
fs->current_byte += bytes;
! return fseek(fs->fd, fs->current_byte, SEEK_SET);
}
--- 188,192 ----
{
fs->current_byte += bytes;
! return fseek(fs->fd, fs->current_byte + fs->id3v2_offset, SEEK_SET);
}
|