diff --git a/ChangeLog b/ChangeLog index 1cde2982..1e0a1c79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-07-25 Erik de Castro Lopo + + * src/FLAC + Merge from FLAC upstream sources. + 2007-07-15 Erik de Castro Lopo * src/flac.c diff --git a/src/FLAC/src/libFLAC/bitreader.c b/src/FLAC/src/libFLAC/bitreader.c index e3f85b85..12169811 100644 --- a/src/FLAC/src/libFLAC/bitreader.c +++ b/src/FLAC/src/libFLAC/bitreader.c @@ -793,6 +793,7 @@ FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsig /* this is by far the most heavily used reader call. it ain't pretty but it's fast */ /* a lot of the logic is copied, then adapted, from FLAC__bitreader_read_unary_unsigned() and FLAC__bitreader_read_raw_uint32() */ FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter) +/* OPT: possibly faster version for use with MSVC */ #ifdef _MSC_VER { unsigned i; diff --git a/src/FLAC/src/libFLAC/bitwriter.c b/src/FLAC/src/libFLAC/bitwriter.c index 5764cd18..848ed4d6 100644 --- a/src/FLAC/src/libFLAC/bitwriter.c +++ b/src/FLAC/src/libFLAC/bitwriter.c @@ -544,7 +544,7 @@ FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FL msbits = uval >> parameter; -#if 1 /* OPT: can remove this special case if it doesn't make up for the extra compare */ +#if 0 /* OPT: can remove this special case if it doesn't make up for the extra compare (doesn't make a statistically significant difference with msvc or gcc/x86) */ if(bw->bits && bw->bits + msbits + lsbits <= FLAC__BITS_PER_WORD) { /* i.e. if the whole thing fits in the current bwword */ /* ^^^ if bw->bits is 0 then we may have filled the buffer and have no free bwword to work in */ bw->bits = bw->bits + msbits + lsbits; @@ -565,7 +565,7 @@ FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FL } } else { -#elif 0 /*@@@@@@ OPT: try this version with MSVC6 to see if better, not much difference for gcc-4 */ +#elif 1 /*@@@@@@ OPT: try this version with MSVC6 to see if better, not much difference for gcc-4 */ if(bw->bits && bw->bits + msbits + lsbits < FLAC__BITS_PER_WORD) { /* i.e. if the whole thing fits in the current bwword */ /* ^^^ if bw->bits is 0 then we may have filled the buffer and have no free bwword to work in */ bw->bits = bw->bits + msbits + lsbits; diff --git a/src/FLAC/src/libFLAC/format.c b/src/FLAC/src/libFLAC/format.c index 79338c55..25d69372 100644 --- a/src/FLAC/src/libFLAC/format.c +++ b/src/FLAC/src/libFLAC/format.c @@ -61,9 +61,9 @@ FLAC_API const char *FLAC__VERSION_STRING = "1.2.0"; #if defined _MSC_VER || defined __BORLANDC__ || defined __MINW32__ /* yet one more hack because of MSVC6: */ -FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.2.0 20070707"; +FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.2.0 20070715"; #else -FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC CVS 1.2.0 20070707"; +FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC CVS 1.2.0 20070715"; #endif FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' }; diff --git a/src/FLAC/src/libFLAC/metadata_iterators.c b/src/FLAC/src/libFLAC/metadata_iterators.c index d06d195e..a36540ff 100644 --- a/src/FLAC/src/libFLAC/metadata_iterators.c +++ b/src/FLAC/src/libFLAC/metadata_iterators.c @@ -1198,8 +1198,7 @@ static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle han return true; } -static -FLAC__StreamDecoderReadStatus chain_read_ogg_read_cb_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) +static FLAC__StreamDecoderReadStatus chain_read_ogg_read_cb_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) { FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; (void)decoder; @@ -2319,8 +2318,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__ return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; } -static -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cstring_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__byte **data, FLAC__uint32 *length, FLAC__uint32 length_len) +static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cstring_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__byte **data, FLAC__uint32 *length, FLAC__uint32 length_len) { FLAC__byte buffer[sizeof(FLAC__uint32)]; diff --git a/src/FLAC/src/libFLAC/stream_decoder.c b/src/FLAC/src/libFLAC/stream_decoder.c index 69335d82..864f6800 100644 --- a/src/FLAC/src/libFLAC/stream_decoder.c +++ b/src/FLAC/src/libFLAC/stream_decoder.c @@ -420,8 +420,10 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_( #ifdef FLAC__CPU_IA32 FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32); #ifdef FLAC__HAS_NASM +#if 1 /*@@@@@@ OPT: not clearly faster, needs more testing */ if(decoder->private_->cpuinfo.data.ia32.bswap) decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap; +#endif if(decoder->private_->cpuinfo.data.ia32.mmx) { decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32; decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32_mmx; diff --git a/src/FLAC/src/share/utf8/iconvert.c b/src/FLAC/src/share/utf8/iconvert.c index b72ad863..37f16a89 100644 --- a/src/FLAC/src/share/utf8/iconvert.c +++ b/src/FLAC/src/share/utf8/iconvert.c @@ -28,6 +28,8 @@ #include #include +#include "iconvert.h" + /* * Convert data from one encoding to another. Return: * diff --git a/src/FLAC/src/share/utf8/iconvert.h b/src/FLAC/src/share/utf8/iconvert.h new file mode 100644 index 00000000..1a1a06a1 --- /dev/null +++ b/src/FLAC/src/share/utf8/iconvert.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2001 Edmund Grimley Evans + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#if HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_ICONV + +/* + * Convert data from one encoding to another. Return: + * + * -2 : memory allocation failed + * -1 : unknown encoding + * 0 : data was converted exactly + * 1 : data was converted inexactly + * 2 : data was invalid (but still converted) + * + * We convert in two steps, via UTF-8, as this is the only + * reliable way of distinguishing between invalid input + * and valid input which iconv refuses to transliterate. + * We convert from UTF-8 twice, because we have no way of + * knowing whether the conversion was exact if iconv returns + * E2BIG (due to a bug in the specification of iconv). + * An alternative approach is to assume that the output of + * iconv is never more than 4 times as long as the input, + * but I prefer to avoid that assumption if possible. + */ + +int iconvert(const char *fromcode, const char *tocode, + const char *from, size_t fromlen, + char **to, size_t *tolen) ; + +#endif /* HAVE_ICONV */ diff --git a/src/FLAC/src/share/utf8/utf8.c b/src/FLAC/src/share/utf8/utf8.c index fc2c69bc..f2bf5704 100644 --- a/src/FLAC/src/share/utf8/utf8.c +++ b/src/FLAC/src/share/utf8/utf8.c @@ -227,9 +227,7 @@ int utf8_decode(const char *from, char **to) #include #endif -int iconvert(const char *fromcode, const char *tocode, - const char *from, size_t fromlen, - char **to, size_t *tolen); +#include "iconvert.h" static const char *current_charset(void) { diff --git a/src/FLAC/src/test_libFLAC/metadata.h b/src/FLAC/src/test_libFLAC/metadata.h index 5ebdea19..05515640 100644 --- a/src/FLAC/src/test_libFLAC/metadata.h +++ b/src/FLAC/src/test_libFLAC/metadata.h @@ -23,6 +23,6 @@ FLAC__bool test_metadata(void); FLAC__bool test_metadata_file_manipulation(void); -FLAC__bool test_metadata_object(void) ; +FLAC__bool test_metadata_object(void); #endif diff --git a/src/FLAC/src/test_libFLAC/metadata_manip.c b/src/FLAC/src/test_libFLAC/metadata_manip.c index 2647d37b..5f00b8cc 100644 --- a/src/FLAC/src/test_libFLAC/metadata_manip.c +++ b/src/FLAC/src/test_libFLAC/metadata_manip.c @@ -185,8 +185,7 @@ static void delete_from_our_metadata_(unsigned position) * This wad of functions supports filename- and callback-based chain reading/writing. * Everything up to set_file_stats_() is copied from libFLAC/metadata_iterators.c */ -static -FLAC__bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) +static FLAC__bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) { static const char *tempfile_suffix = ".metadata_edit"; @@ -201,8 +200,7 @@ FLAC__bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfile return true; } -static -void cleanup_tempfile_(FILE **tempfile, char **tempfilename) +static void cleanup_tempfile_(FILE **tempfile, char **tempfilename) { if(0 != *tempfile) { (void)fclose(*tempfile); @@ -216,8 +214,7 @@ void cleanup_tempfile_(FILE **tempfile, char **tempfilename) } } -static -FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) +static FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) { FLAC__ASSERT(0 != filename); FLAC__ASSERT(0 != tempfile); @@ -247,16 +244,14 @@ FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tem return true; } -static -FLAC__bool get_file_stats_(const char *filename, struct stat *stats) +static FLAC__bool get_file_stats_(const char *filename, struct stat *stats) { FLAC__ASSERT(0 != filename); FLAC__ASSERT(0 != stats); return (0 == stat(filename, stats)); } -static -void set_file_stats_(const char *filename, struct stat *stats) +static void set_file_stats_(const char *filename, struct stat *stats) { struct utimbuf srctime;