From 4a546e25607aea02d99c2eab00d2230ab7e2cf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 2 Mar 2007 23:46:29 +0000 Subject: Simplify a lot the code for ID3v2 skip. CVS patchset: 8633 CVS date: 2007/03/02 23:46:29 --- src/demuxers/demux_flac.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c index ce6f30165..259f4d4e9 100644 --- a/src/demuxers/demux_flac.c +++ b/src/demuxers/demux_flac.c @@ -23,7 +23,7 @@ * For more information on the FLAC file format, visit: * http://flac.sourceforge.net/ * - * $Id: demux_flac.c,v 1.14 2007/02/20 00:34:55 dgp85 Exp $ + * $Id: demux_flac.c,v 1.15 2007/03/02 23:46:29 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -90,25 +90,17 @@ static int open_flac_file(demux_flac_t *flac) { 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 @@ static int open_flac_file(demux_flac_t *flac) { 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 */ -- cgit v1.2.3