Update of /cvsroot/xine/xine-lib/src/demuxers
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28354
Modified Files:
demux_aac.c demux_flac.c demux_mpgaudio.c id3.h
Log Message:
Add two extra functions (inline as they are just a return statement) that
checks if a preamble is of an ID3v2 tag, and that calculate the size of the tag
(to avoid repeating the same code over and over and over; the size of the
shared object is reduced. Also make demux_flac use the id3.c functions to parse
the eventual ID3 header.
Index: demux_aac.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/demux_aac.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- demux_aac.c 3 Mar 2007 00:58:52 -0000 1.16
+++ demux_aac.c 3 Mar 2007 01:41:16 -0000 1.17
@@ -83,8 +83,8 @@
return 0;
/* Check if there's an ID3v2 tag at the start */
- if ( peak[0] == 'I' && peak[1] == 'D' && peak[2] == '3' ) {
- id3size = (peak[6] << 7*3) + (peak[7] << 7*2) + (peak[8] << 7) + peak[9] +
10;
+ if ( id3v2_istag(peak) ) {
+ id3size = id3v2_tagsize(&peak[6]);
this->input->seek(this->input, 4, SEEK_SET);
Index: demux_flac.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/demux_flac.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- demux_flac.c 2 Mar 2007 23:46:29 -0000 1.15
+++ demux_flac.c 3 Mar 2007 01:41:16 -0000 1.16
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2004 the xine project
+ * Copyright (C) 2000-2007 the xine project
*
* This file is part of xine, a free video player.
*
@@ -49,6 +49,7 @@
#include "bswap.h"
#include "group_audio.h"
+#include "id3.h"
#include "flacutils.h"
typedef struct {
@@ -81,7 +82,7 @@
* It returns 1 if flac file was opened successfully. */
static int open_flac_file(demux_flac_t *flac) {
- unsigned char preamble[4];
+ unsigned char preamble[10];
unsigned int block_length;
unsigned char buffer[FLAC_SEEKPOINT_SIZE];
unsigned char *streaminfo = flac->streaminfo + sizeof(xine_waveformatex);
@@ -89,8 +90,9 @@
flac->seekpoints = NULL;
- /* fetch the file signature */
- if ( flac->input->read(flac->input, preamble, 4) != 4 )
+ /* fetch the file signature, get enough bytes so that id3 can also
+ be skipped and/or parsed */
+ if (_x_demux_read_header(flac->input, preamble, 10) != 10)
return 0;
/* Unfortunately some FLAC files have an ID3 flag prefixed on them
@@ -98,7 +100,7 @@
* users use them and want them working, so check and skip the ID3
* tag if present.
*/
- if ( preamble[0] == 'I' && preamble[1] == 'D' && preamble[2] == '3' ) {
+ if ( id3v2_istag(preamble) ) {
uint32_t id3size;
/* First 3 bytes are the ID3 signature as above, then comes two bytes
@@ -109,18 +111,16 @@
* is encoded as four bytes.. but only 7 out of 8 bits of every byte is
* used... don't ask.
*/
- flac->input->seek(flac->input, 6, SEEK_SET);
- if ( flac->input->read(flac->input, preamble, 4) != 4 )
- return 0;
+ id3size = id3v2_tagsize(&preamble[6]);
- id3size = (preamble[0] << 7*3) + (preamble[1] << 7*2) +
- (preamble[2] << 7) + preamble[3];
+ id3v2_parse_tag(flac->input, flac->stream, preamble);
- flac->input->seek(flac->input, id3size, SEEK_CUR);
+ flac->input->seek(flac->input, id3size, SEEK_SET);
if ( flac->input->read(flac->input, preamble, 4) != 4 )
return 0;
- }
+ } else
+ flac->input->seek(flac->input, 4, SEEK_SET);
/* validate signature */
if ((preamble[0] != 'f') || (preamble[1] != 'L') ||
Index: demux_mpgaudio.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/demux_mpgaudio.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -r1.150 -r1.151
--- demux_mpgaudio.c 3 Mar 2007 00:58:52 -0000 1.150
+++ demux_mpgaudio.c 3 Mar 2007 01:41:16 -0000 1.151
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2003 the xine project
+ * Copyright (C) 2000-2007 the xine project
*
* This file is part of xine, a free video player.
*
@@ -606,7 +606,7 @@
return parse_frame_payload(this, header_buf, decoder_flags);
- } else if ( header_buf[0] == 'I' && header_buf[1] == 'D' &&
header_buf[2] == '3' ) {
+ } else if ( id3v2_istag(header_buf) ) {
if (!id3v2_parse_tag(this->input, this->stream, header_buf)) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
LOG_MODULE ": ID3V2 tag parsing error\n");
@@ -693,10 +693,7 @@
* flac files can contain id3v2 tags
*/
uint8_t *ptr = &buf[6];
- uint32_t tag_size = ((uint32_t)ptr[0] << 21) +
- ((uint32_t)ptr[1] << 14) +
- ((uint32_t)ptr[2] << 7) +
- (uint32_t)ptr[3];
+ uint32_t tag_size = id3v2_tagsize(ptr);
lprintf("try to skip id3v2 tag (%d bytes)\n", tag_size);
if ((10 + tag_size) >= preview_len) {
lprintf("cannot skip id3v2 tag\n");
Index: id3.h
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/id3.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- id3.h 3 Mar 2007 00:58:52 -0000 1.5
+++ id3.h 3 Mar 2007 01:41:16 -0000 1.6
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2003 the xine project
+ * Copyright (C) 2000-2007 the xine project
*
* This file is part of xine, a free video player.
*
@@ -170,4 +170,19 @@
xine_stream_t *stream,
int8_t *mp3_frame_header);
+static inline int id3v2_istag(uint8_t *ptr) {
+ return
+ (ptr[0] == 'I') &&
+ (ptr[1] == 'D') &&
+ (ptr[2] == '3');
+}
+
+static inline uint32_t id3v2_tagsize(uint8_t *ptr) {
+ return
+ ((uint32_t)ptr[0] << 21) +
+ ((uint32_t)ptr[1] << 14) +
+ ((uint32_t)ptr[2] << 7) +
+ (uint32_t)ptr[3];
+}
+
#endif /* ID3_H */
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog