From: <dg...@us...> - 2007-03-02 23:46:30
|
Update of /cvsroot/xine/xine-lib/src/demuxers In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12009 Modified Files: demux_flac.c Log Message: Simplify a lot the code for ID3v2 skip. Index: demux_flac.c =================================================================== RCS file: /cvsroot/xine/xine-lib/src/demuxers/demux_flac.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- demux_flac.c 20 Feb 2007 00:34:55 -0000 1.14 +++ demux_flac.c 2 Mar 2007 23:46:29 -0000 1.15 @@ -90,25 +90,17 @@ flac->seekpoints = NULL; /* fetch the file signature */ - if (_x_demux_read_header(flac->input, preamble, 4) != 4) + if ( flac->input->read(flac->input, preamble, 4) != 4 ) return 0; - /* validate signature */ - if ((preamble[0] != 'f') || - (preamble[1] != 'L') || - (preamble[2] != 'a') || - (preamble[3] != 'C')) { - + /* Unfortunately some FLAC files have an ID3 flag prefixed on them + * before the actual FLAC headers... these are barely legal, but + * 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' ) { uint32_t id3size; - /* Unfortunately some FLAC files have an ID3 flag prefixed on them - * before the actual FLAC headers... these are barely legal, but - * 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' ) - return 0; - /* First 3 bytes are the ID3 signature as above, then comes two bytes * encoding the major and minor version of ID3 used, that we can ignore * as long as we don't try to read the metadata; after those there's a @@ -121,19 +113,19 @@ if ( flac->input->read(flac->input, preamble, 4) != 4 ) return 0; - id3size = (preamble[0] << 7*3) + (preamble[1] << 7*2) + (preamble[2] << 7) + preamble[3]; - + id3size = (preamble[0] << 7*3) + (preamble[1] << 7*2) + + (preamble[2] << 7) + preamble[3]; + flac->input->seek(flac->input, id3size, SEEK_CUR); if ( flac->input->read(flac->input, preamble, 4) != 4 ) return 0; - - if ( preamble[0] != 'f' || preamble[1] != 'L' || preamble[2] != 'a' || preamble[3] != 'C' ) + } + + /* validate signature */ + if ((preamble[0] != 'f') || (preamble[1] != 'L') || + (preamble[2] != 'a') || (preamble[3] != 'C')) return 0; - - } else - /* file is qualified; skip over the signature bytes in the stream */ - flac->input->seek(flac->input, 4, SEEK_SET); /* loop through the metadata blocks; use a do-while construct since there * will always be 1 metadata block */ |