From: <sv...@op...> - 2025-02-15 17:54:24
|
Author: manx Date: Sat Feb 15 18:54:09 2025 New Revision: 22921 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22921 Log: [Var] FLAC: Update to v1.5.0 (2025-02-11). Modified: trunk/OpenMPT/build/premake/ext-flac.lua trunk/OpenMPT/include/flac/AUTHORS trunk/OpenMPT/include/flac/COPYING.Xiph trunk/OpenMPT/include/flac/OpenMPT.txt trunk/OpenMPT/include/flac/include/FLAC/all.h trunk/OpenMPT/include/flac/include/FLAC/assert.h trunk/OpenMPT/include/flac/include/FLAC/callback.h trunk/OpenMPT/include/flac/include/FLAC/export.h trunk/OpenMPT/include/flac/include/FLAC/format.h trunk/OpenMPT/include/flac/include/FLAC/metadata.h trunk/OpenMPT/include/flac/include/FLAC/ordinals.h trunk/OpenMPT/include/flac/include/FLAC/stream_decoder.h trunk/OpenMPT/include/flac/include/FLAC/stream_encoder.h trunk/OpenMPT/include/flac/include/share/alloc.h trunk/OpenMPT/include/flac/include/share/compat.h trunk/OpenMPT/include/flac/include/share/endswap.h trunk/OpenMPT/include/flac/include/share/macros.h trunk/OpenMPT/include/flac/include/share/private.h trunk/OpenMPT/include/flac/include/share/safe_str.h trunk/OpenMPT/include/flac/include/share/win_utf8_io.h trunk/OpenMPT/include/flac/src/libFLAC/bitmath.c trunk/OpenMPT/include/flac/src/libFLAC/bitreader.c trunk/OpenMPT/include/flac/src/libFLAC/bitwriter.c trunk/OpenMPT/include/flac/src/libFLAC/cpu.c trunk/OpenMPT/include/flac/src/libFLAC/crc.c trunk/OpenMPT/include/flac/src/libFLAC/fixed.c trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_avx2.c trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_sse2.c trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_sse42.c trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_ssse3.c trunk/OpenMPT/include/flac/src/libFLAC/float.c trunk/OpenMPT/include/flac/src/libFLAC/format.c trunk/OpenMPT/include/flac/src/libFLAC/include/private/all.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/bitmath.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/bitreader.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/bitwriter.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/cpu.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/crc.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/fixed.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/float.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/format.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/lpc.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/macros.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/memory.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/metadata.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/ogg_decoder_aspect.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/ogg_encoder_aspect.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/ogg_helper.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/ogg_mapping.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/stream_encoder.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/stream_encoder_framing.h trunk/OpenMPT/include/flac/src/libFLAC/include/private/window.h trunk/OpenMPT/include/flac/src/libFLAC/include/protected/all.h trunk/OpenMPT/include/flac/src/libFLAC/include/protected/stream_decoder.h trunk/OpenMPT/include/flac/src/libFLAC/include/protected/stream_encoder.h trunk/OpenMPT/include/flac/src/libFLAC/lpc.c trunk/OpenMPT/include/flac/src/libFLAC/lpc_intrin_avx2.c trunk/OpenMPT/include/flac/src/libFLAC/lpc_intrin_fma.c trunk/OpenMPT/include/flac/src/libFLAC/lpc_intrin_neon.c trunk/OpenMPT/include/flac/src/libFLAC/lpc_intrin_sse2.c trunk/OpenMPT/include/flac/src/libFLAC/lpc_intrin_sse41.c trunk/OpenMPT/include/flac/src/libFLAC/md5.c trunk/OpenMPT/include/flac/src/libFLAC/memory.c trunk/OpenMPT/include/flac/src/libFLAC/metadata_iterators.c trunk/OpenMPT/include/flac/src/libFLAC/metadata_object.c trunk/OpenMPT/include/flac/src/libFLAC/ogg_decoder_aspect.c trunk/OpenMPT/include/flac/src/libFLAC/ogg_encoder_aspect.c trunk/OpenMPT/include/flac/src/libFLAC/ogg_helper.c trunk/OpenMPT/include/flac/src/libFLAC/ogg_mapping.c trunk/OpenMPT/include/flac/src/libFLAC/stream_decoder.c trunk/OpenMPT/include/flac/src/libFLAC/stream_encoder.c trunk/OpenMPT/include/flac/src/libFLAC/stream_encoder_framing.c trunk/OpenMPT/include/flac/src/libFLAC/stream_encoder_intrin_avx2.c trunk/OpenMPT/include/flac/src/libFLAC/stream_encoder_intrin_sse2.c trunk/OpenMPT/include/flac/src/libFLAC/stream_encoder_intrin_ssse3.c trunk/OpenMPT/include/flac/src/libFLAC/version.rc trunk/OpenMPT/include/flac/src/libFLAC/window.c trunk/OpenMPT/include/flac/src/share/win_utf8_io/win_utf8_io.c Modified: trunk/OpenMPT/build/premake/ext-flac.lua ============================================================================== --- trunk/OpenMPT/build/premake/ext-flac.lua Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/build/premake/ext-flac.lua Sat Feb 15 18:54:09 2025 (r22921) @@ -115,7 +115,7 @@ filter {} defines { "FLAC__HAS_OGG=1" } links { "ogg" } - defines { "PACKAGE_VERSION=\"1.4.3\"" } + defines { "PACKAGE_VERSION=\"1.5.0\"" } filter {} filter { "kind:StaticLib" } defines { "FLAC__NO_DLL" } Modified: trunk/OpenMPT/include/flac/AUTHORS ============================================================================== --- trunk/OpenMPT/include/flac/AUTHORS Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/AUTHORS Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* FLAC - Free Lossless Audio Codec * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * This file is part the FLAC project. FLAC is comprised of several * components distributed under different licenses. The codec libraries Modified: trunk/OpenMPT/include/flac/COPYING.Xiph ============================================================================== --- trunk/OpenMPT/include/flac/COPYING.Xiph Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/COPYING.Xiph Sat Feb 15 18:54:09 2025 (r22921) @@ -1,5 +1,5 @@ Copyright (C) 2000-2009 Josh Coalson -Copyright (C) 2011-2023 Xiph.Org Foundation +Copyright (C) 2011-2025 Xiph.Org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/OpenMPT.txt ============================================================================== --- trunk/OpenMPT/include/flac/OpenMPT.txt Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/OpenMPT.txt Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,5 @@ -flac 1.4.3. +flac 1.5.0 (2025-02-11). The FLAC package has been left pretty much untouched, except for a few changes: - * https://github.com/xiph/flac/pull/638 has been applied. * In `include/share/compat.h`, the Windows XP compatibility warning has been disabled. * All modifications have been marked with "/* OpenMPT */". Modified: trunk/OpenMPT/include/flac/include/FLAC/all.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/all.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/all.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -436,6 +436,56 @@ * */ +/** \defgroup porting_1_4_3_to_1_5_0 Porting from FLAC 1.4.3 to 1.5.0 + * \ingroup porting + * + * \brief + * This module describes porting from FLAC 1.4.3 to FLAC 1.5.0. + * + * \section porting_1_4_3_to_1_5_0_summary Summary + * + * Between FLAC 1.4.3 and FLAC 1.5.0, there have been changes to + * existing C functions and enums: + * - the functions FLAC__metadata_get_streaminfo, + * FLAC__metadata_get_tags and FLAC__metadata_get_cuesheet can now + * read from Ogg FLAC files + * - when encoding Ogg FLAC files, the 'samples' argument of the + * write callback no longer always returns 0. + * - two error statuses have been added to the + * FLAC__StreamDecoderErrorStatus enum + * - one status is added to FLAC__StreamDecoderState, which is only + * used when the new decoding of chained streams functionality is + * enabled + * - one status is added to FLAC__StreamDecoderReadStatus, which is + * only used when the new decoding of chained streams functionality + * is enabled + * - the function + * FLAC__metadata_chain_write_with_callbacks_and_tempfile can now + * be used regardless of whether a tempfile is actually needed, + * which is useful when writing to a new file is desired anyway + * + * Furthermore, there have been the following additions: + * - the functions FLAC__stream_decoder_set_decode_chained_stream, + * FLAC__stream_decoder_get_decode_chained_stream, + * FLAC__stream_decoder_finish_link, + * FLAC__stream_decoder_skip_single_link, + * FLAC__stream_decoder_process_until_end_of_link and + * FLAC__stream_decoder_get_link_lengths have been added + * to support decoding of chained streams + * - the function FLAC__metadata_chain_write_new_file has been added, + * which is useful to combine copying of a file with changing its + * metadata + * - the function FLAC__stream_decoder_find_total_samples was added, + * which seeks to the end of a file to find the total number of + * samples + * - the function FLAC__stream_encoder_set_num_threads and + * FLAC__stream_encoder_get_num_threads have been added, which + * can be used to enable multithreading in the encoder + * + * For the C++ API, changes are the same, but in C++ nomenclature + * + */ + /** \defgroup flac FLAC C API * * The FLAC C API is the interface to libFLAC, a set of structures Modified: trunk/OpenMPT/include/flac/include/FLAC/assert.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/assert.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/assert.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/FLAC/callback.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/callback.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/callback.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/FLAC/export.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/export.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/export.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -95,9 +95,9 @@ /** These \#defines will mirror the libtool-based library version number, see * http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning */ -#define FLAC_API_VERSION_CURRENT 13 +#define FLAC_API_VERSION_CURRENT 14 #define FLAC_API_VERSION_REVISION 0 /**< see above */ -#define FLAC_API_VERSION_AGE 1 /**< see above */ +#define FLAC_API_VERSION_AGE 0 /**< see above */ #ifdef __cplusplus extern "C" { Modified: trunk/OpenMPT/include/flac/include/FLAC/format.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/format.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/format.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/FLAC/metadata.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/metadata.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/metadata.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,9 +62,9 @@ * This module provides functions for creating and manipulating FLAC * metadata blocks in memory, and three progressively more powerful * interfaces for traversing and editing metadata in native FLAC files. - * Note that currently only the Chain interface (level 2) supports Ogg - * FLAC files, and it is read-only i.e. no writing back changed - * metadata to file. + * Note that currently only the Chain interface (level 2) and some + * functions in level 0 supports Ogg FLAC files, and they are + * read-only i.e. no writing back changed metadata to file. * * There are three metadata interfaces of increasing complexity: * @@ -144,10 +144,11 @@ * \{ */ -/** Read the STREAMINFO metadata block of the given FLAC file. This function - * will try to skip any ID3v2 tag at the head of the file. +/** Read the STREAMINFO metadata block of the given FLAC or Ogg FLAC + * file. This function will try to skip any ID3v2 tag at the head + * of the file. * - * \param filename The path to the FLAC file to read. + * \param filename The path to the FLAC or Ogg FLAC file to read. * \param streaminfo A pointer to space for the STREAMINFO block. Since * FLAC__StreamMetadata is a simple structure with no * memory allocation involved, you pass the address of @@ -163,10 +164,11 @@ */ FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo); -/** Read the VORBIS_COMMENT metadata block of the given FLAC file. This - * function will try to skip any ID3v2 tag at the head of the file. +/** Read the VORBIS_COMMENT metadata block of the given FLAC or Ogg FLAC + * file. This function will try to skip any ID3v2 tag at the head + * of the file. * - * \param filename The path to the FLAC file to read. + * \param filename The path to the FLAC or Ogg FLAC file to read. * \param tags The address where the returned pointer will be * stored. The \a tags object must be deleted by * the caller using FLAC__metadata_object_delete(). @@ -182,10 +184,11 @@ */ FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags); -/** Read the CUESHEET metadata block of the given FLAC file. This - * function will try to skip any ID3v2 tag at the head of the file. +/** Read the CUESHEET metadata block of the given FLAC or Ogg FLAC + * file. This function will try to skip any ID3v2 tag at the head + * of the file. * - * \param filename The path to the FLAC file to read. + * \param filename The path to the FLAC or Ogg FLAC file to read. * \param cuesheet The address where the returned pointer will be * stored. The \a cuesheet object must be deleted by * the caller using FLAC__metadata_object_delete(). @@ -207,7 +210,8 @@ * function takes a number of parameters that act as constraints to * the search. The PICTURE block with the largest area matching all * the constraints will be returned, or \a *picture will be set to - * \c NULL if there was no such block. + * \c NULL if there was no such block. This function does not + * currently support reading from Ogg FLAC files. * * \param filename The path to the FLAC file to read. * \param picture The address where the returned pointer will be @@ -784,9 +788,6 @@ /**< FLAC__metadata_chain_write_with_callbacks() was called when the * chain write requires a tempfile; use * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead. - * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was - * called when the chain write does not require a tempfile; use - * FLAC__metadata_chain_write_with_callbacks() instead. * Always check FLAC__metadata_chain_check_if_tempfile_needed() * before writing via callbacks. */ @@ -923,11 +924,11 @@ * edited metadata back to the FLAC file does not require rewriting the * entire file. If rewriting is required, then a temporary workfile is * required. When writing metadata using callbacks, you must check - * this function to know whether to call - * FLAC__metadata_chain_write_with_callbacks() or - * FLAC__metadata_chain_write_with_callbacks_and_tempfile(). When - * writing with FLAC__metadata_chain_write(), the temporary file is - * handled internally. + * this function to know whether + * FLAC__metadata_chain_write_with_callbacks() can be used or + * FLAC__metadata_chain_write_with_callbacks_and_tempfile() is + * necessary. When writing with FLAC__metadata_chain_write(), the + * temporary file is handled internally. * * \param chain A pointer to an existing chain. * \param use_padding @@ -990,6 +991,28 @@ */ FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats); +/** Write all metadata out to a new FLAC file. + * + * This function works similar to FLAC__metadata_chain_write(), but is + * useful if writing to a new file is desired. This is more efficient + * than copying the file before changing it. + * + * For this write function to be used, the chain must have been read with + * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(), not + * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(). + * See also FLAC__metadata_chain_write_with_callbacks_and_tempfile() + * + * \param chain A pointer to an existing chain. + * \param use_padding See FLAC__metadata_chain_write() + * \param filename The filename of the new file. + * \assert + * \code chain != NULL \endcode + * \retval FLAC__bool + * \c true if the write succeeded, else \c false. On failure, + * check the status with FLAC__metadata_chain_status(). + */ +FLAC_API FLAC__bool FLAC__metadata_chain_write_new_file(FLAC__Metadata_Chain *chain, const char *filename, FLAC__bool use_padding); + /** Write all metadata out to a FLAC stream via callbacks. * * (See FLAC__metadata_chain_write() for the details on how padding is @@ -1031,7 +1054,8 @@ * FLAC file to edit, and a temporary handle to which the new FLAC * file will be written. It is the caller's job to move this temporary * FLAC file on top of the original FLAC file to complete the metadata - * edit. + * edit. This version of the write-with-callbacks function can also be + * used if writing to a new file is desired anyway. * * The \a handle must be open for reading and be seekable. The * equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" @@ -1046,8 +1070,6 @@ * For this write function to be used, the chain must have been read with * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). - * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned - * \c true. * * \param chain A pointer to an existing chain. * \param use_padding See FLAC__metadata_chain_write() Modified: trunk/OpenMPT/include/flac/include/FLAC/ordinals.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/ordinals.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/ordinals.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/FLAC/stream_decoder.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/stream_decoder.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/stream_decoder.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -235,12 +235,20 @@ * state and can no longer be used. */ - FLAC__STREAM_DECODER_UNINITIALIZED + FLAC__STREAM_DECODER_UNINITIALIZED, /**< The decoder is in the uninitialized state; one of the * FLAC__stream_decoder_init_*() functions must be called before samples * can be processed. */ + FLAC__STREAM_DECODER_END_OF_LINK + /**< The decoder has reached the end of an Ogg FLAC chain link and a new + * link follows; FLAC__stream_decoder_finish_link() has to be called to + * progress. This state is only returned when decoding of chained + * streams is enabled with + * FLAC__stream_decoder_set_decode_chained_stream() + */ + } FLAC__StreamDecoderState; /** Maps a FLAC__StreamDecoderState to a C string. @@ -307,9 +315,14 @@ * of \c 0. */ - FLAC__STREAM_DECODER_READ_STATUS_ABORT + FLAC__STREAM_DECODER_READ_STATUS_ABORT, /**< An unrecoverable error occurred. The decoder will return from the process call. */ + FLAC__STREAM_DECODER_READ_STATUS_END_OF_LINK + /**< The read was attempted while at the end of the link. The semantics + * are the same as for FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM. + */ + } FLAC__StreamDecoderReadStatus; /** Maps a FLAC__StreamDecoderReadStatus to a C string. @@ -442,9 +455,21 @@ FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM, /**< The decoder encountered reserved fields in use in the stream. */ - FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA + FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA, /**< The decoder encountered a corrupted metadata block. */ + FLAC__STREAM_DECODER_ERROR_STATUS_OUT_OF_BOUNDS, + /**< The decoder encountered a otherwise valid frame in which + * the decoded samples exceeded the range offered by the stated + * bit depth. */ + + FLAC__STREAM_DECODER_ERROR_STATUS_MISSING_FRAME + /**< Two adjacent frames had frame numbers increasing by more than + * 1 or sample numbers increasing by more than the blocksize, + * indicating that one or more frame/frames was missing between + * them. The decoder will sent out one or more ´fake' constant + * subframes to fill up the gap. */ + } FLAC__StreamDecoderErrorStatus; /** Maps a FLAC__StreamDecoderErrorStatus to a C string. @@ -782,6 +807,33 @@ */ FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number); +/** Set the "decode chained stream" flag. If set to \c false, the + * decoder will stop decoding when it encounters the end-of-stream + * of the first link in the chain. If set to \c true, decoding will + * continue: at the start of each link, FLAC__stream_decoder_get_state + * will return FLAC__STREAM_DECODER_SEARCH_FOR_METADATA. + * + * This function was made to decode chained Ogg streams, but it should + * be possible to chain regular FLAC files through the read callback + * by using FLAC__STREAM_DECODER_READ_STATUS_END_OF_LINK + * appropriately. + * + * Note that when this flag is set to true, the serial number set + * with FLAC__stream_decoder_set_ogg_serial_number is ignored. + * + * \note + * This function has no effect with native FLAC decoding. + * + * \default \c false + * \param decoder A decoder instance to set. + * \param allow Whether to allow chained streams. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if the decoder is already initialized, else \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_set_decode_chained_stream(FLAC__StreamDecoder* decoder, FLAC__bool value); + /** Set the "MD5 signature checking" flag. If \c true, the decoder will * compute the MD5 signature of the unencoded audio data while decoding * and compare it to the signature from the STREAMINFO block, if it @@ -814,7 +866,7 @@ * \code decoder != NULL \endcode * \a type is valid * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. + * \c false if type is invalid, else \c true. */ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type); @@ -829,7 +881,7 @@ * \code decoder != NULL \endcode * \code id != NULL \endcode * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. + * \c false when memory allocation fails, else \c true. */ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]); @@ -841,7 +893,7 @@ * \assert * \code decoder != NULL \endcode * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. + * \c always \c true. */ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder); @@ -855,7 +907,7 @@ * \code decoder != NULL \endcode * \a type is valid * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. + * \c false if type is invalid, else \c true. */ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type); @@ -870,7 +922,7 @@ * \code decoder != NULL \endcode * \code id != NULL \endcode * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. + * \c false if memory allocation fails, else \c true. */ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]); @@ -882,7 +934,7 @@ * \assert * \code decoder != NULL \endcode * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. + * \c always \c true. */ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder); @@ -906,6 +958,17 @@ */ FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder); +/** Get the "decode chained stream" flag as described in + * \code FLAC__stream_decoder_set_decode_chained_stream \endcode. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * See above. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_chained_stream(const FLAC__StreamDecoder* decoder); + /** Get the "MD5 signature checking" flag. * This is the value of the setting, not whether or not the decoder is * currently checking the MD5 (remember, it can be turned off automatically @@ -932,6 +995,32 @@ */ FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder); +/** Seek to the end of the file being decoded to find the total number + * of samples. This will return a number of samples even if + * FLAC__stream_decoder_get_total_samples() returns 0. It can also + * be used to find the total number of samples of a chained stream, + * as it returns the total number of samples in all chain links + * combined. See FLAC__stream_decoder_set_decode_chained_stream() + * + * For this function to work, the stream must be seekable. Also, as + * seeking can fail, this function returns 0 when it was unable to + * find the total number of samples. Use + * FLAC__stream_decoder_get_state() in that case to find out whether + * the decoder is still valid. + * + * The state in which the decoder is left after calling this function + * is undefined and might change in the future. Use + * FLAC__stream_decoder_reset() to return the decoder to a defined + * state. + * + * \param decoder A decoder instance to query. + * \assert + * \code decoder != NULL \endcode + * \retval uint32_t + * See above. + */ +FLAC_API FLAC__uint64 FLAC__stream_decoder_find_total_samples(FLAC__StreamDecoder *decoder); + /** Get the current number of channels in the stream being decoded. * Will only be valid after decoding has started and will contain the * value from the most recently decoded frame header. @@ -1023,6 +1112,43 @@ */ FLAC_API const void *FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder); +#define FLAC__STREAM_DECODER_GET_LINK_LENGTHS_INVALID -1 +#define FLAC__STREAM_DECODER_GET_LINK_LENGTHS_NOT_INDEXED -2 +#define FLAC__STREAM_DECODER_GET_LINK_LENGTHS_MEMORY_ALLOCATION_ERROR -3 + +/** Get the link lengths in samples in a chained stream + * + * After either processing the whole file or using + * FLAC__stream_decoder_find_total_samples, this function + * returns an array with link lengths in samples. If it fails, + * it returns a negative number as error code, currently either + * FLAC__STREAM_DECODER_GET_LINK_LENGTHS_INVALID if the current + * decoder is not in a valid state or not processing a chained + * stream, FLAC__STREAM_DECODER_GET_LINK_LENGTHS_NOT_INDEXED if + * the stream hasn't been indexed yet, and + * FLAC__STREAM_DECODER_GET_LINK_LENGTHS_MEMORY_ALLOCATION_ERROR + * if allocating memory failed. + * + * If the function succeeds, the return value is the number of + * links. The link_lengths parameter is a FLAC__uint64 pointer + * which is allocated by the call, and must be freed by the user. + * If a null pointer is passed, the function only returns the + * number of links, not their lengths. The length of the returned + * array is equal to the number of links and thus to the return + * value of the function. + * + * \param decoder A decoder instance to query. + * \param link_lengths Address at which to return the link lengths + * array. + * \assert + * \code decoder != NULL \endcode + * \retval int32_t + * \c the number of links if successful, zero or a negative + * number if unsuccessful + */ + +FLAC_API int32_t FLAC__stream_decoder_get_link_lengths(FLAC__StreamDecoder *decoder, FLAC__uint64 **link_lengths); + /** Initialize the decoder instance to decode native FLAC streams. * * This flavor of initialization sets up the decoder to decode from a @@ -1394,6 +1520,23 @@ */ FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder); +/** Finish the decoding process of the current link. + * Checks MD5 for current link and start processing of the next link. This + * function should only be used when the decoder state is + * FLAC__STREAM_DECODER_END_OF_LINK. After calling this function, the state + * is set to FLAC__STREAM_DECODER_SEARCH_FOR_METADATA. + * + * \param decoder An uninitialized decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if MD5 checking is on AND a STREAMINFO block was available + * AND the MD5 signature in the STREAMINFO block was non-zero AND the + * signature does not match the one computed by the decoder; else + * \c true. + */ +FLAC_API FLAC__bool FLAC__stream_decoder_finish_link(FLAC__StreamDecoder *decoder); + /** Flush the stream input. * The decoder's input buffer will be cleared and the state set to * \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC. This will also turn @@ -1495,6 +1638,31 @@ */ FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder); +/** Decode until the end of the Ogg chain link. + * This version instructs the decoder to decode from the current + * position and continue until the end of link or until the + * callbacks return a fatal error. This function should not be + * used without enabling decoding of chained streams with + * FLAC__stream_decoder_set_decode_chained_stream() + * + * To start processing the next link after calling this function, + * call FLAC__stream_decoder_finish_link() + * + * As the decoder needs more input it will call the read callback. + * As each metadata block and frame is decoded, the metadata or write + * callback will be called with the decoded metadata or frame. + * + * \param decoder An initialized decoder instance. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if any fatal read, write, or memory allocation error + * occurred (meaning decoding must stop), else \c true; for more + * information about the decoder, check the decoder state with + * FLAC__stream_decoder_get_state(). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_link(FLAC__StreamDecoder *decoder); + /** Decode until the end of the stream. * This version instructs the decoder to decode from the current position * and continue until the end of stream (the read callback returns @@ -1557,6 +1725,34 @@ */ FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder); +/** Skip one Ogg chain link. + * This version instructs the decoder to 'skip' the current ogg chain + * link. This function should not be used without enabling decoding + * of chained streams with + * FLAC__stream_decoder_set_decode_chained_stream() + * + * When the location ot the next link is already known (for example, + * because there has already been a seek in the stream) this function + * will seek to the end of the link and start processing, but when it + * is not, it will do various seeks (when possible) to find the end + * of the link. If seeking is not possible (or the tell and length + * callback do not work) it will simply read forward instead of + * seeking, much like a muted (but faster) version of + * FLAC__stream_decoder_process_until_end_of_link(). + * + * \param decoder An initialized decoder instance not in a metadata + * state. + * \assert + * \code decoder != NULL \endcode + * \retval FLAC__bool + * \c false if any fatal read, write, or memory allocation error + * occurred (meaning decoding must stop), or when decoding a format + * that does not support chaining, else \c true; for more + * information about the decoder, check the decoder state with + * FLAC__stream_decoder_get_state(). + */ +FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_link(FLAC__StreamDecoder *decoder); + /** Flush the input and seek to an absolute sample. * Decoding will resume at the given sample. Note that because of * this, the next write callback may contain a partial block. The @@ -1566,6 +1762,14 @@ * with FLAC__stream_decoder_flush() or reset with * FLAC__stream_decoder_reset() before decoding can continue. * + * When seeking in a chained stream with decoding of such streams + * enabled with FLAC__stream_decoder_set_decode_chained_stream(), + * this function seeks in the whole stream, over all links. When + * a seek to another link is performed, the decoder will also + * return metadata blocks of that link. If this is not desired, + * use FLAC__stream_decoder_set_metadata_ignore_all() before + * seeking. + * * \param decoder A decoder instance. * \param sample The target sample number to seek to. * \assert Modified: trunk/OpenMPT/include/flac/include/FLAC/stream_encoder.h ============================================================================== --- trunk/OpenMPT/include/flac/include/FLAC/stream_encoder.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/FLAC/stream_encoder.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -288,6 +288,11 @@ extern FLAC_API const char * const FLAC__StreamEncoderStateString[]; +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK 0 +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_NOT_COMPILED_WITH_MULTITHREADING_ENABLED 1 +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_ALREADY_INITIALIZED 2 +#define FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS 3 + /** Possible return values for the FLAC__stream_encoder_init_*() functions. */ typedef enum { @@ -533,11 +538,17 @@ * callback is being called to write metadata. * * \note - * Unlike when writing to native FLAC, when writing to Ogg FLAC the - * write callback will be called twice when writing each audio - * frame; once for the page header, and once for the page body. - * When writing the page header, the \a samples argument to the - * write callback will be \c 0. + * Unlike when writing to native FLAC, when writing to Ogg FLAC the write + * callback will be called at least twice when writing each audio frame; once + * for the page header and once for the page body, possibly repeating this + * pair of calls several times in a batch with the same value of + * \a current_frame. When writing the page header, as well as in all but the + * first page body write of the batch, the \a samples argument to the write + * callback will be \c 0. For the write callback call containing the first + * page body, the \a samples argument is the number of samples contained in + * all newly added complete packets (not pages). This means that in case a + * packet is split over two pages, they are counted in the samples argument + * of the page on which the packet is completed. * * \note In general, FLAC__StreamEncoder functions which change the * state should not be called on the \a encoder while in the callback. @@ -1102,6 +1113,52 @@ */ FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value); +/** Set the maximum number of threads to use during encoding. + * Set to a value different than 1 to enable multithreaded encoding. + * + * Note that enabling multithreading encoding (i.e., setting a value + * different than 1) results in the behaviour of + * FLAC__stream_encoder_finish(), FLAC__stream_encoder_process(), + * FLAC__stream_encoder_process_interleaved() subtly changing. + * For example, calling one of the process functions with enough + * samples to fill a block might not always result in a call to + * the write callback with a frame coding these samples. Instead, + * blocks with samples are distributed among worker threads, + * meaning that the first few calls to those functions will + * return very quickly, while later calls might block if all + * threads are occupied. Also, certain calls to the process + * functions will results in several calls to the write callback, + * while subsequent calls might again return very quickly with no + * calls to the write callback. + * + * Also, a call to FLAC__stream_encoder_finish() blocks while + * waiting for all threads to finish, and therefore might take much + * longer than when not multithreading and result in multiple calls + * to the write callback. + * + * Calls to the write callback are guaranteed to be in the correct + * order. + * + * Currently, passing a value of 0 is synonymous with a value of 1, + * but this might change in the future. + * + * \default \c 1 + * \param encoder An encoder instance to set. + * \param value See above. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK if the number of threads was set correctly, + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_NOT_COMPILED_WITH_MULTITHREADING_ENABLED when + * multithreading was not enabled at compilation, + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_ALREADY_INITIALIZED when the encoder was + * already initialized, + * - \c FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS when + * the number of threads was larger than the maximum allowed number of threads (currently + * 128). + */ +FLAC_API uint32_t FLAC__stream_encoder_set_num_threads(FLAC__StreamEncoder *encoder, uint32_t value); + /** Deprecated. Setting this value has no effect. * * \default \c 0 @@ -1435,6 +1492,16 @@ */ FLAC_API uint32_t FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder); +/** Get maximum number of threads setting. + * + * \param encoder An encoder instance to query. + * \assert + * \code encoder != NULL \endcode + * \retval uint32_t + * See FLAC__stream_encoder_set_num_threads(). + */ +FLAC_API uint32_t FLAC__stream_encoder_get_num_threads(const FLAC__StreamEncoder *encoder); + /** Get the Rice parameter search distance setting. * * \param encoder An encoder instance to query. Modified: trunk/OpenMPT/include/flac/include/share/alloc.h ============================================================================== --- trunk/OpenMPT/include/flac/include/share/alloc.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/share/alloc.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* alloc - Convenience routines for safely allocating memory * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -64,15 +64,19 @@ #endif #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -extern int alloc_check_threshold, alloc_check_counter; -static inline int alloc_check() { +extern int alloc_check_threshold, alloc_check_counter, alloc_check_keep_failing; + +static inline int alloc_check(void) { if(alloc_check_threshold == INT32_MAX) return 0; else if(alloc_check_counter++ == alloc_check_threshold) return 1; - else + else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold)) + return 1; + else { return 0; + } } #endif Modified: trunk/OpenMPT/include/flac/include/share/compat.h ============================================================================== --- trunk/OpenMPT/include/flac/include/share/compat.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/share/compat.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2023 Xiph.Org Foundation + * Copyright (C) 2012-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -63,8 +63,15 @@ #endif #endif #else +#ifndef HAVE_FSEEKO +#define fseeko fseek +#define ftello ftell +#define FLAC__off_t long +#define FLAC__OFF_T_MAX LONG_MAX +#else #define FLAC__off_t off_t -#define FLAC__OFF_T_MAX OFF_T_MAX +#define FLAC__OFF_T_MAX (sizeof(off_t) == sizeof(int64_t) ? INT64_MAX : sizeof(off_t) == sizeof(int32_t) ? INT32_MAX : -999999) +#endif #endif Modified: trunk/OpenMPT/include/flac/include/share/endswap.h ============================================================================== --- trunk/OpenMPT/include/flac/include/share/endswap.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/share/endswap.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2023 Xiph.Org Foundation + * Copyright (C) 2012-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/share/macros.h ============================================================================== --- trunk/OpenMPT/include/flac/include/share/macros.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/share/macros.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation + * Copyright (C) 2013-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/share/private.h ============================================================================== --- trunk/OpenMPT/include/flac/include/share/private.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/share/private.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation + * Copyright (C) 2013-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/share/safe_str.h ============================================================================== --- trunk/OpenMPT/include/flac/include/share/safe_str.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/share/safe_str.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation + * Copyright (C) 2013-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/include/share/win_utf8_io.h ============================================================================== --- trunk/OpenMPT/include/flac/include/share/win_utf8_io.h Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/include/share/win_utf8_io.h Sat Feb 15 18:54:09 2025 (r22921) @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation + * Copyright (C) 2013-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/src/libFLAC/bitmath.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/bitmath.c Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/src/libFLAC/bitmath.c Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -71,3 +71,45 @@ v = (v < 0) ? (-(v+1)) : v; return FLAC__bitmath_ilog2_wide(v)+2; } + +/* An example of what FLAC__bitmath_extra_mulbits_unsigned() computes: + * + * extra_mulbits_unsigned( 0) = 0 + * extra_mulbits_unsigned( 1) = 0 + * extra_mulbits_unsigned( 2) = 1 + * extra_mulbits_unsigned( 3) = 2 + * extra_mulbits_unsigned( 4) = 2 + * extra_mulbits_unsigned( 5) = 3 + * extra_mulbits_unsigned( 6) = 3 + * extra_mulbits_unsigned( 7) = 3 + * extra_mulbits_unsigned( 8) = 3 + * extra_mulbits_unsigned( 9) = 4 + * extra_mulbits_unsigned(10) = 4 + * extra_mulbits_unsigned(11) = 4 + * extra_mulbits_unsigned(12) = 4 + * extra_mulbits_unsigned(13) = 4 + * extra_mulbits_unsigned(14) = 4 + * extra_mulbits_unsigned(15) = 4 + * extra_mulbits_unsigned(16) = 4 + * extra_mulbits_unsigned(17) = 5 + * extra_mulbits_unsigned(18) = 5 + * + * The intent of this is to calculate how many extra bits multiplication + * by a certain number requires. So, if a signal fits in a certain number + * of bits (for example 16) than multiplying by a number (for example 1024) + * grows that storage requirement (to 26 in this example). In effect this is + * is the log2 rounded up. + */ +uint32_t FLAC__bitmath_extra_mulbits_unsigned(FLAC__uint32 v) +{ + uint32_t ilog2; + if(v == 0) + return 0; + ilog2 = FLAC__bitmath_ilog2(v); + if(((v >> ilog2) << ilog2) == v) + /* v is power of 2 */ + return ilog2; + else + /* v is not a power of 2, return one higher */ + return ilog2 + 1; +} Modified: trunk/OpenMPT/include/flac/src/libFLAC/bitreader.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/bitreader.c Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/src/libFLAC/bitreader.c Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -939,23 +939,23 @@ v = x; i = 0; } - else if(x & 0xC0 && !(x & 0x20)) { /* 110xxxxx */ + else if((x & 0xE0) == 0xC0) { /* 110xxxxx */ v = x & 0x1F; i = 1; } - else if(x & 0xE0 && !(x & 0x10)) { /* 1110xxxx */ + else if((x & 0xF0) == 0xE0) { /* 1110xxxx */ v = x & 0x0F; i = 2; } - else if(x & 0xF0 && !(x & 0x08)) { /* 11110xxx */ + else if((x & 0xF8) == 0xF0) { /* 11110xxx */ v = x & 0x07; i = 3; } - else if(x & 0xF8 && !(x & 0x04)) { /* 111110xx */ + else if((x & 0xFC) == 0xF8) { /* 111110xx */ v = x & 0x03; i = 4; } - else if(x & 0xFC && !(x & 0x02)) { /* 1111110x */ + else if((x & 0xFE) == 0xFC) { /* 1111110x */ v = x & 0x01; i = 5; } @@ -994,27 +994,27 @@ v = x; i = 0; } - else if(x & 0xC0 && !(x & 0x20)) { /* 110xxxxx */ + else if((x & 0xE0) == 0xC0) { /* 110xxxxx */ v = x & 0x1F; i = 1; } - else if(x & 0xE0 && !(x & 0x10)) { /* 1110xxxx */ + else if((x & 0xF0) == 0xE0) { /* 1110xxxx */ v = x & 0x0F; i = 2; } - else if(x & 0xF0 && !(x & 0x08)) { /* 11110xxx */ + else if((x & 0xF8) == 0xF0) { /* 11110xxx */ v = x & 0x07; i = 3; } - else if(x & 0xF8 && !(x & 0x04)) { /* 111110xx */ + else if((x & 0xFC) == 0xF8) { /* 111110xx */ v = x & 0x03; i = 4; } - else if(x & 0xFC && !(x & 0x02)) { /* 1111110x */ + else if((x & 0xFE) == 0xFC) { /* 1111110x */ v = x & 0x01; i = 5; } - else if(x & 0xFE && !(x & 0x01)) { /* 11111110 */ + else if(x == 0xFE) { /* 11111110 */ v = 0; i = 6; } Modified: trunk/OpenMPT/include/flac/src/libFLAC/bitwriter.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/bitwriter.c Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/src/libFLAC/bitwriter.c Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -89,8 +89,8 @@ * next one. */ static const uint32_t FLAC__BITWRITER_DEFAULT_CAPACITY = 32768u / sizeof(bwword); /* size in words */ -/* When growing, increment 4K at a time */ -static const uint32_t FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(bwword); /* size in words */ +/* When growing, increment with 1/4th at a time */ +static const uint32_t FLAC__BITWRITER_DEFAULT_GROW_FRACTION = 2; /* means grow by >> 2 (1/4th) of current size */ #define FLAC__WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD) #define FLAC__TOTAL_BITS(bw) (FLAC__WORDS_TO_BITS((bw)->words) + (bw)->bits) @@ -131,11 +131,11 @@ * To prevent chrashing, give up */ return false; - /* round up capacity increase to the nearest FLAC__BITWRITER_DEFAULT_INCREMENT */ - if((new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT) - new_capacity += FLAC__BITWRITER_DEFAULT_INCREMENT - ((new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT); + /* As reallocation can be quite expensive, grow exponentially */ + if((new_capacity - bw->capacity) < (bw->capacity >> FLAC__BITWRITER_DEFAULT_GROW_FRACTION)) + new_capacity = bw->capacity + (bw->capacity >> FLAC__BITWRITER_DEFAULT_GROW_FRACTION); + /* make sure we got everything right */ - FLAC__ASSERT(0 == (new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT); FLAC__ASSERT(new_capacity > bw->capacity); FLAC__ASSERT(new_capacity >= bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD)); Modified: trunk/OpenMPT/include/flac/src/libFLAC/cpu.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/cpu.c Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/src/libFLAC/cpu.c Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -45,14 +45,6 @@ #include <cpuid.h> /* for __get_cpuid() and __get_cpuid_max() */ #endif -#ifndef NDEBUG -#include <stdio.h> -#define dfprintf fprintf -#else -/* This is bad practice, it should be a static void empty function */ -#define dfprintf(file, format, ...) -#endif - #if defined(HAVE_SYS_AUXV_H) #include <sys/auxv.h> #endif @@ -190,36 +182,12 @@ info->x86.bmi2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_BMI2 ) ? true : false; } -#if defined FLAC__CPU_IA32 - dfprintf(stderr, "CPU info (IA-32):\n"); -#else - dfprintf(stderr, "CPU info (x86-64):\n"); -#endif - dfprintf(stderr, " CMOV ....... %c\n", info->x86.cmov ? 'Y' : 'n'); - dfprintf(stderr, " MMX ........ %c\n", info->x86.mmx ? 'Y' : 'n'); - dfprintf(stderr, " SSE ........ %c\n", info->x86.sse ? 'Y' : 'n'); - dfprintf(stderr, " SSE2 ....... %c\n", info->x86.sse2 ? 'Y' : 'n'); - dfprintf(stderr, " SSE3 ....... %c\n", info->x86.sse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSSE3 ...... %c\n", info->x86.ssse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSE41 ...... %c\n", info->x86.sse41 ? 'Y' : 'n'); - dfprintf(stderr, " SSE42 ...... %c\n", info->x86.sse42 ? 'Y' : 'n'); - - if (FLAC__AVX_SUPPORTED) { - dfprintf(stderr, " AVX ........ %c\n", info->x86.avx ? 'Y' : 'n'); - dfprintf(stderr, " FMA ........ %c\n", info->x86.fma ? 'Y' : 'n'); - dfprintf(stderr, " AVX2 ....... %c\n", info->x86.avx2 ? 'Y' : 'n'); - dfprintf(stderr, " BMI2 ....... %c\n", info->x86.bmi2 ? 'Y' : 'n'); - } - /* * now have to check for OS support of AVX instructions */ if (FLAC__AVX_SUPPORTED && info->x86.avx && x86_osxsave && (cpu_xgetbv_x86() & 0x6) == 0x6) { os_avx = true; } - if (os_avx) { - dfprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n'); - } if (!os_avx) { /* no OS AVX support */ info->x86.avx = false; Modified: trunk/OpenMPT/include/flac/src/libFLAC/crc.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/crc.c Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/src/libFLAC/crc.c Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/OpenMPT/include/flac/src/libFLAC/fixed.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/fixed.c Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/src/libFLAC/fixed.c Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -357,7 +357,7 @@ if(order_##macro_order##_is_valid && total_error_##macro_order < smallest_error) { \ order = macro_order; \ smallest_error = total_error_##macro_order ; \ - residual_bits_per_sample[ macro_order ] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); \ + residual_bits_per_sample[ macro_order ] = (float)((total_error_##macro_order > 0) ? log(M_LN2 * (double)total_error_##macro_order / (double)data_len) / M_LN2 : 0.0); \ } \ else \ residual_bits_per_sample[ macro_order ] = 34.0f; Modified: trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_avx2.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_avx2.c Sat Feb 15 18:31:44 2025 (r22920) +++ trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_avx2.c Sat Feb 15 18:54:09 2025 (r22921) @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation + * Copyright (C) 2011-2025 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -178,7 +178,7 @@ order = macro_order; \ smallest_error = total_error_##macro_order ; \ } \ - residual_bits_per_sample[ macro_order ] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); \ + residual_bits_per_sample[ macro_order ] = (float)((total_error_##macro_order > 0) ? log(M_LN2 * (double)total_error_##macro_order / (double)data_len) / M_LN2 : 0.0); \ } \ else \ residual_bits_per_sample[ macro_order ] = 34.0f; Modified: trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_sse2.c ============================================================================== --- trunk/OpenMPT/include/flac/src/libFLAC/fixed_intrin_sse2.c Sat Feb 15 18:31:44 2025 (r2292... [truncated message content] |