diff options
author | Sadaf Ebrahimi <sadafebrahimi@google.com> | 2023-06-28 23:51:46 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-06-28 23:51:46 +0000 |
commit | 3faa2331dc99704bf8d8a05d94857df1bee64e4d (patch) | |
tree | ec75d4b0c3a5b307805085e3b8161a6c56324ebb | |
parent | a8fafe062c9496be3b051a78cad527e56d66b97b (diff) | |
parent | fffd3c26bcbc1d717517d5db4fedd6a81124601c (diff) | |
download | flac-3faa2331dc99704bf8d8a05d94857df1bee64e4d.tar.gz |
Merge "Upgrade flac to 1.4.3" am: 2db585c02a am: e92429d55c am: 35ddd43d52 am: fffd3c26bc
Original change: https://android-review.googlesource.com/c/platform/external/flac/+/2641839
Change-Id: I851735d80e3950f9dcd1e7874116c18505eb1bdf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
281 files changed, 2196 insertions, 1163 deletions
diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 1dc51157..c8bdbff8 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -3,37 +3,12 @@ name: GitHub Actions on: push: pull_request: - schedule: - - cron: '0 0 1 * *' jobs: build: strategy: matrix: - name: - [ - ubuntu-latest-gcc-autotools, - ubuntu-latest-clang-autotools, - ubuntu-latest-gcc-cmake, - ubuntu-latest-clang-cmake, - macos-latest-clang-autotools, - macos-latest-clang-cmake, - windows-latest-cmake, - ubuntu-latest-gcc-autotools-64-bit-words, - ubuntu-latest-clang-autotools-64-bit-words, - ubuntu-latest-gcc-cmake-64-bit-words, - ubuntu-latest-clang-cmake-64-bit-words, - macos-latest-clang-autotools-64-bit-words, - macos-latest-clang-cmake-64-bit-words - ] include: - - name: ubuntu-latest-gcc-autotools - os: ubuntu-latest - cc: gcc - cxx: g++ - build-system: autotools - configure-opts: '' - - name: ubuntu-latest-clang-autotools os: ubuntu-latest cc: clang @@ -79,48 +54,6 @@ jobs: build-system: cmake configure-opts: '-DBUILD_SHARED_LIBS=ON' - - name: ubuntu-latest-gcc-autotools-64-bit-words - os: ubuntu-latest - cc: gcc - cxx: g++ - build-system: autotools - configure-opts: --enable-64-bit-words - - - name: ubuntu-latest-clang-autotools-64-bit-words - os: ubuntu-latest - cc: clang - cxx: clang++ - build-system: autotools - configure-opts: --enable-64-bit-words - - - name: ubuntu-latest-gcc-cmake-64-bit-words - os: ubuntu-latest - cc: gcc - cxx: g++ - build-system: cmake - configure-opts: -DENABLE_64_BIT_WORDS=ON - - - name: ubuntu-latest-clang-cmake-64-bit-words - os: ubuntu-latest - cc: clang - cxx: clang++ - build-system: cmake - configure-opts: -DENABLE_64_BIT_WORDS=ON - - - name: macos-latest-clang-autotools-64-bit-words - os: macos-latest - cc: clang - cxx: clang++ - build-system: autotools - configure-opts: --enable-64-bit-words - - - name: macos-latest-clang-cmake-64-bit-words - os: macos-latest - cc: clang - cxx: clang++ - build-system: cmake - configure-opts: -DENABLE_64_BIT_WORDS=ON - runs-on: ${{ matrix.os }} steps: @@ -196,4 +129,6 @@ jobs: if: failure() with: name: flac-${{ github.sha }}-${{ github.run_id }}-logs - path: ./**/*.log + path: | + ./**/*.log + ./**/out*.meta diff --git a/.github/workflows/distcheck.yml b/.github/workflows/distcheck.yml index ec47f248..90daba2d 100644 --- a/.github/workflows/distcheck.yml +++ b/.github/workflows/distcheck.yml @@ -13,6 +13,11 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: ietf-wg-cellar/flac-test-files + path: ./test-files + - name: Install Linux dependencies run: | sudo apt-get update @@ -31,8 +36,18 @@ jobs: make unxz --keep test/abi/abi-libFLAC-1.4.0.dump.xz unxz --keep test/abi/abi-libFLAC++-1.4.0.dump.xz - abi-compliance-checker -l flac -old test/abi/abi-libFLAC-1.4.0.dump -new test/abi/abi-descriptor-libFLAC-1.4.0.xml - abi-compliance-checker -l flac++ -old test/abi/abi-libFLAC++-1.4.0.dump -new test/abi/abi-descriptor-libFLAC++-1.4.0.xml + abi-compliance-checker -l flac -old test/abi/abi-libFLAC-1.4.0.dump -new test/abi/abi-descriptor-libFLAC-1.4.3.xml + abi-compliance-checker -l flac++ -old test/abi/abi-libFLAC++-1.4.0.dump -new test/abi/abi-descriptor-libFLAC++-1.4.3.xml + + - name: Check with flac test files + run: ./src/flac/flac -t test-files/subset/*.flac test-files/uncommon/0[5-9]*.flac test-files/uncommon/10*.flac + + - name: Upload ABI compliance reports + uses: actions/upload-artifact@v3 + with: + name: flac-${{ github.sha }}-${{ github.run_id }}-compat + path: | + ./compat_reports - name: Upload logs on failure uses: actions/upload-artifact@v3 @@ -41,4 +56,3 @@ jobs: name: flac-${{ github.sha }}-${{ github.run_id }}-logs path: | ./flac-**/**/*.log - ./compat_reports diff --git a/.github/workflows/options.yml b/.github/workflows/options.yml new file mode 100644 index 00000000..d2c8673e --- /dev/null +++ b/.github/workflows/options.yml @@ -0,0 +1,50 @@ +name: GitHub Actions for specific options + +on: + push: + pull_request: + +jobs: + build: + strategy: + matrix: + include: + - name: 32-bit-words + cppflags: '' + configure-opts: --disable-64-bit-words + + - name: integer-only-library + cppflags: '-DFLAC__INTEGER_ONLY_LIBRARY' + configure-opts: '' + + - name: no-asm + cppflags: '' + configure-opts: --disable-asm-optimizations + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libtool-bin libogg-dev + + - name: Build and run tests + env: + CPPFLAGS: ${{ matrix.cppflags }} + run: | + ./autogen.sh + ./configure --disable-thorough-tests ${{ matrix.configure-opts }} + make + make check + + - name: Upload logs on failure + uses: actions/upload-artifact@v2 + if: failure() + with: + name: flac-${{ github.sha }}-${{ github.run_id }}-logs + path: | + ./**/*.log + ./**/out*.meta @@ -81,6 +81,7 @@ oss-fuzz/fuzzer_encoder oss-fuzz/fuzzer_encoder_v2 oss-fuzz/fuzzer_reencoder oss-fuzz/fuzzer_tool_flac +oss-fuzz/fuzzer_tool_metaflac /*[Bb]uild*/ /out/ diff --git a/.travis.yml b/.travis.yml index f635bad3..a4de8301 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ jobs: dist: focal arch: arm64 compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DENABLE_64_BIT_WORDS=ON + env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DENABLE_64_BIT_WORDS=OFF - os: linux dist: focal arch: ppc64le @@ -51,7 +51,7 @@ jobs: dist: focal arch: ppc64le compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DENABLE_64_BIT_WORDS=ON + env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DENABLE_64_BIT_WORDS=OFF install: - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -y install libtool-bin libogg-dev; fi @@ -1,6 +1,6 @@ /* FLAC - Free Lossless Audio Codec * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This file is part the FLAC project. FLAC is comprised of several * components distributed under different licenses. The codec libraries @@ -27,6 +27,7 @@ https://gitlab.xiph.org/xiph/flac/commits Original author: Josh Coalson <jcoalson@users.sourceforge.net> Maintainer 2012-2020: Erik de Castro Lopo <erikd@mega-nerd.com> +Maintainer from 2022: Martijn van Beurden <mvanb1@gmail.com> Website : https://www.xiph.org/flac/ @@ -57,8 +58,3 @@ Other major contributors and their contributions: "Matt Zimmerman" <mdz@debian.org> * Libtool/autoconf/automake make system, flac man page - -"Martijn van Beurden" <mvanb1@gmail.com> -* Compression improvements -* Fuzzer improvements and fixes for fuzz findings -* Implementation of 32 bps encoder and decoder diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0aa0b7..71467a5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,48 @@ This changelog is not exhaustive, review [the git commit log](https://github.com/xiph/flac/commits) for an exhaustive list of changes. +## FLAC 1.4.3 (23-Jun-2023) + +As there have been additions to the libFLAC interfaces, the libFLAC version number is incremented to 13. The libFLAC++ version number stays at 10. + +* General + * All PowerPC-specific code has been removed, as it turned out those improvements didn't actually improve anything + * Large improvements in encoder speed for all presets. The largest change is for the fastest presets and for 24-bit and 32-bit inputs. + * Small improvement in decoder speed for BMI2-capable CPUs + * Various documentation fixes and cleanups (Mark Grassi, Jake Schmidt) + * Various fixes (Ozkan Sezer, Zhipeng Xue, orbea, Sam James, Harish Mahendrakar) + * Fix building on Universal Windows Platform (Dmitry Kostjučenko) +* flac + * A lot of small fixes for bugs found by fuzzing + * Various improvements to the --keep-foreign-metadata and --keep-foreign-metadata-if-present options on decoding + * The output format (WAV/AIFF/RF64 etc.) is now automatically selected based on what kind of foreign metadata is stored + * Decoded file is checked afterwards, to see whether stored foreign format data agrees with FLAC audio properties + * AIFF-C sowt data can now be restored + * Add --force-legacy-wave-format option, to decode to WAV with WAVEFORMATPCM where WAVE_FORMAT_EXTENSIBLE would be more appropriate + * Add --force-aiff-c-none-format and --force-aiff-c-sowt-format to decode to AIFF-C + * The storage of WAVEFORMATEXTENSIBLE_CHANNEL_MASK is no longer restricted to known channel orderings + * Throw an error when WAV or AIFF files are over 4GiB in length and the --ignore-chunk-sizes option is not set + * Warn on testing files when ID3v2 tags are found + * Warn when data trails the audio data of a WAV/AIFF/RF64/W64 file + * Fix output file not being deleted after error on Windows + * Removal of the --sector--align option +* metaflac + * A lot of small fixes for bugs found by fuzzing + * Added options --append and --data-format, which makes it possible to copy metadata blocks from one FLAC file to another + * Added option --remove-all-tags-except + * Added option --show-all-tags (harridu, Martijn van Beurden) +* libFLAC + * No longer write seektables to Ogg, even when specifically asked for. Seektables in Ogg are not defined + * Add functions FLAC__metadata_object_set_raw and FLAC__metadata_object_get_raw to convert between blob and FLAC__StreamMetadata +* Build system + * Autoconf (configure) + * The option --enable-64-bit-words is now on by default + * CMake + * The option ENABLE_64_BIT_WORDS is now on by default +* Testing/validation + * Fuzzers were added for the flac and metaflac command line tools + * Fuzzer coverage was improved + ## FLAC 1.4.2 (22-Oct-2022) Once again, this release only has a few changes. A problem with FLAC playback in GStreamer (and possibly other libFLAC users) was the reason for the short time since the last release diff --git a/CMakeLists.txt b/CMakeLists.txt index e6a381f9..fb23b7d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES OR DEFINED ENV{CFLAGS} OR set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo") endif() -project(FLAC VERSION 1.4.2) # HOMEPAGE_URL "https://www.xiph.org/flac/") +project(FLAC VERSION 1.4.3) # HOMEPAGE_URL "https://www.xiph.org/flac/") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/COPYING.Xiph b/COPYING.Xiph index edd24f71..86629af1 100644 --- a/COPYING.Xiph +++ b/COPYING.Xiph @@ -1,5 +1,5 @@ Copyright (C) 2000-2009 Josh Coalson -Copyright (C) 2011-2022 Xiph.Org Foundation +Copyright (C) 2011-2023 Xiph.Org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -13,12 +13,12 @@ third_party { type: GIT value: "https://github.com/xiph/flac.git" } - version: "9c83e6e434143afba6eee8550aa8dcc9160fccf7" + version: "1.4.3" license_type: BY_EXCEPTION_ONLY license_note: "Would be RESTRICTED save for GFDL in: README, COPYING.FDL, and doc/html/flac.css" last_upgrade_date { year: 2023 - month: 3 - day: 11 + month: 6 + day: 27 } } diff --git a/Makefile.am b/Makefile.am index 36d823a8..3bb523e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries @@ -1,7 +1,7 @@ <!--- /* FLAC - Free Lossless Audio Codec * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This file is part the FLAC project. FLAC is comprised of several * components distributed under different licenses. The codec libraries @@ -10,36 +10,33 @@ /* Target processor is little endian. */ #define CPU_IS_LITTLE_ENDIAN 1 -/* Set FLAC__BYTES_PER_WORD to 8 (4 is the default) */ -#define ENABLE_64_BIT_WORDS 0 +/* Set FLAC__BYTES_PER_WORD to 8 (this is the default) */ +#define ENABLE_64_BIT_WORDS 1 /* define to align allocated memory on 32-byte boundaries */ #define FLAC__ALIGN_MALLOC_DATA 1 +/* define if building for ARM */ +/* #undef FLAC__CPU_ARM64 */ + /* define if building for ia32/i386 */ /* #undef FLAC__CPU_IA32 */ -/* define if building for PowerPC */ -/* #undef FLAC__CPU_PPC */ - -/* define if building for PowerPC with SPE ABI */ -/* #undef FLAC__CPU_PPC_SPE */ - -/* define if building for SPARC */ -/* #undef FLAC__CPU_SPARC */ - /* define if building for x86_64 */ /* #undef FLAC__CPU_X86_64 */ -/* define if you have docbook-to-man or docbook2man */ -/* #undef FLAC__HAS_DOCBOOK_TO_MAN */ +/* Set to 1 if <arm_neon.h> has A64 instructions. */ +/* #undef FLAC__HAS_A64NEONINTRIN */ -/* define if you are compiling for x86 and have the NASM assembler */ -/* #undef FLAC__HAS_NASM */ +/* Set to 1 if <arm_neon.h> is available. */ +#define FLAC__HAS_NEONINTRIN 0 /* define if you have the ogg library */ #define FLAC__HAS_OGG 0 +/* define if you have pandoc */ +/* #undef FLAC__HAS_PANDOC */ + /* Set to 1 if <x86intrin.h> is available. */ #define FLAC__HAS_X86INTRIN 1 @@ -52,12 +49,21 @@ /* define if building for Linux */ #define FLAC__SYS_LINUX 1 -/* define to enable use of Altivec instructions */ -/* #define FLAC__USE_ALTIVEC 1 */ - /* define to enable use of AVX instructions */ /* #define FLAC__USE_AVX 1 */ +/* "Define to the commit date of the current git HEAD" */ +#define GIT_COMMIT_DATE "20230627" + +/* "Define to the short hash of the current git HEAD" */ +#define GIT_COMMIT_HASH "4ff7e0f6" + +/* "Define to the tag of the current git HEAD" */ +/* #undef GIT_COMMIT_TAG */ + +/* Define to 1 if you have the <arm_neon.h> header file. */ +/* #undef HAVE_ARM_NEON_H */ + /* Compiler has the __builtin_bswap16 intrinsic */ #define HAVE_BSWAP16 1 @@ -73,18 +79,15 @@ /* Define to 1 if you have the <cpuid.h> header file. */ /* #undef HAVE_CPUID_H */ -/* Define to 1 if C++ supports variable-length arrays. */ -#define HAVE_CXX_VARARRAYS 1 - -/* Define to 1 if C supports variable-length arrays. */ -#define HAVE_C_VARARRAYS 1 - /* Define to 1 if you have the <dlfcn.h> header file. */ #define HAVE_DLFCN_H 1 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #define HAVE_FSEEKO 1 +/* Define to 1 if you have the `getauxval' function. */ +#define HAVE_GETAUXVAL 1 + /* Define to 1 if you have the `getopt_long' function. */ #define HAVE_GETOPT_LONG 1 @@ -100,11 +103,8 @@ /* lround support */ #define HAVE_LROUND 1 -/* Define to 1 if you have the <memory.h> header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if the system has the type `socklen_t'. */ -#define HAVE_SOCKLEN_T 1 +/* Define to 1 if you have the <stdbool.h> header file. */ +#define HAVE_STDBOOL_H 1 /* Define to 1 if you have the <stdint.h> header file. */ #define HAVE_STDINT_H 1 @@ -118,6 +118,9 @@ /* Define to 1 if you have the <string.h> header file. */ #define HAVE_STRING_H 1 +/* Define to 1 if you have the <sys/auxv.h> header file. */ +#define HAVE_SYS_AUXV_H 1 + /* Define to 1 if you have the <sys/ioctl.h> header file. */ #define HAVE_SYS_IOCTL_H 1 @@ -158,7 +161,7 @@ #define PACKAGE_NAME "flac" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "flac 1.3.2" +#define PACKAGE_STRING "flac 1.4.3" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "flac" @@ -167,7 +170,7 @@ #define PACKAGE_URL "https://www.xiph.org/flac/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.3.2" +#define PACKAGE_VERSION "1.4.3" /* The size of `off_t', as computed by sizeof. */ #if __LP64__ @@ -183,18 +186,24 @@ #define SIZEOF_VOIDP 4 #endif -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #define STDC_HEADERS 1 /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # define _ALL_SOURCE 1 #endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif -/* Enable threading extensions on Solaris. */ +/* Enable POSIX-compatible threading on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # define _POSIX_PTHREAD_SEMANTICS 1 #endif @@ -202,14 +211,10 @@ #ifndef _TANDEM_SOURCE # define _TANDEM_SOURCE 1 #endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 -#endif /* Version number of package */ -#define VERSION "1.3.2" +#define VERSION "1.4.3" /* Target processor is big endian. */ #define WORDS_BIGENDIAN 0 @@ -228,16 +233,6 @@ /* Define for large files, on AIX-style hosts. */ /* #undef _LARGE_FILES */ -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ - /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus diff --git a/configure.ac b/configure.ac index 6842b8ff..418677c7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries @@ -20,7 +20,7 @@ # instead of FLAC__ since autoconf triggers off 'AC_' in strings AC_PREREQ(2.60) -AC_INIT([flac],[1.4.2],[flac-dev@xiph.org],[flac],[https://www.xiph.org/flac/]) +AC_INIT([flac],[1.4.3],[flac-dev@xiph.org],[flac],[https://www.xiph.org/flac/]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([src/flac/main.c]) AC_CONFIG_MACRO_DIR([m4]) @@ -176,10 +176,12 @@ os_is_windows=no case "$host" in *mingw*) os_is_windows=yes + AC_CHECK_TOOL(RC,[windres],[:]) ;; esac AM_CONDITIONAL(OS_IS_WINDOWS, test "x$os_is_windows" = xyes) +AM_CONDITIONAL(HAVE_WINDRES, test "x$RC" != "x:") case "$host" in *-linux-*) @@ -265,12 +267,12 @@ esac AC_ARG_ENABLE(64-bit-words, - AS_HELP_STRING([--enable-64-bit-words],[Set FLAC__BYTES_PER_WORD to 8 (4 is the default)])) -if test "x$enable_64_bit_words" = xyes ; then - AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],1,[Set FLAC__BYTES_PER_WORD to 8 (4 is the default)]) + AS_HELP_STRING([--disable-64-bit-words],[Set FLAC__BYTES_PER_WORD to 4 (8 is the default)])) +if test "x$enable_64_bit_words" = xno ; then + AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],0,[Set FLAC__BYTES_PER_WORD to 8 (this is the default)]) else - AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],0) - fi + AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],1) +fi AC_SUBST(ENABLE_64_BIT_WORDS) AC_ARG_ENABLE(valgrind-testing, diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 0b4864c9..8133ea34 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -32,7 +32,7 @@ PROJECT_NAME = FLAC # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.4.2 +PROJECT_NUMBER = 1.4.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/doc/Makefile.am b/doc/Makefile.am index 20e291e3..55395ca7 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,6 @@ # flac - Command-line FLAC encoder/decoder # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/doc/doxygen.footer.html b/doc/doxygen.footer.html index 224734d3..e395c610 100644 --- a/doc/doxygen.footer.html +++ b/doc/doxygen.footer.html @@ -2,10 +2,10 @@ <hr size="1"/> Copyright (c) 2000-2009 Josh Coalson -Copyright (c) 2011-2022 Xiph.Org Foundation +Copyright (c) 2011-2023 Xiph.Org Foundation <!-- Copyright (c) 2000-2009 Josh Coalson --> -<!-- Copyright (c) 2011-2022 Xiph.Org Foundation --> +<!-- Copyright (c) 2011-2023 Xiph.Org Foundation --> <!-- Permission is granted to copy, distribute and/or modify this document --> <!-- under the terms of the GNU Free Documentation License, Version 1.1 --> <!-- or any later version published by the Free Software Foundation; --> diff --git a/doc/images/Makefile.am b/doc/images/Makefile.am index 19a4bef7..1e30a5c3 100644 --- a/doc/images/Makefile.am +++ b/doc/images/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/doc/release_checklist.md b/doc/release_checklist.md index 914d792c..3a5a59d7 100644 --- a/doc/release_checklist.md +++ b/doc/release_checklist.md @@ -11,7 +11,9 @@ 1. Update changelog 1. Check copyright year and update if applicable 1. Check libFLAC and libFLAC++ for interface changes and update - version numbers in include/FLAC/export.h and include/FLAC++/export.h + version numbers in include/FLAC/export.h, include/FLAC++/export.h, + src/libFLAC/Makefile.am, src/libFLAC++/Makefile.am, + src/libFLAC/CMakeLists.txt and src/libFLAC++/CMakeLists.txt 1. Prepare and check release tarball by running `git clean -ffxd && ./autogen.sh && ./configure && make distcheck` 1. Check whether release tarball contains api documentation and diff --git a/examples/Makefile.am b/examples/Makefile.am index a26b3eee..18b844fa 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/examples/c/Makefile.am b/examples/c/Makefile.am index 94a72e3f..ced8f8ed 100644 --- a/examples/c/Makefile.am +++ b/examples/c/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/examples/c/decode/Makefile.am b/examples/c/decode/Makefile.am index 0255a9e2..3c9499cb 100644 --- a/examples/c/decode/Makefile.am +++ b/examples/c/decode/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/examples/c/decode/file/Makefile.am b/examples/c/decode/file/Makefile.am index 13d37ba1..b74a782b 100644 --- a/examples/c/decode/file/Makefile.am +++ b/examples/c/decode/file/Makefile.am @@ -1,6 +1,6 @@ # example_c_decode_file - Simple FLAC file decoder using libFLAC # Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/examples/c/decode/file/main.c b/examples/c/decode/file/main.c index 93514d4f..009b0d72 100644 --- a/examples/c/decode/file/main.c +++ b/examples/c/decode/file/main.c @@ -1,6 +1,6 @@ /* example_c_decode_file - Simple FLAC file decoder using libFLAC * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/examples/c/encode/Makefile.am b/examples/c/encode/Makefile.am index 0255a9e2..3c9499cb 100644 --- a/examples/c/encode/Makefile.am +++ b/examples/c/encode/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/examples/c/encode/file/Makefile.am b/examples/c/encode/file/Makefile.am index ddf454a0..1771f7c1 100644 --- a/examples/c/encode/file/Makefile.am +++ b/examples/c/encode/file/Makefile.am @@ -1,6 +1,6 @@ # example_c_encode_file - Simple FLAC file encoder using libFLAC # Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/examples/c/encode/file/main.c b/examples/c/encode/file/main.c index 6414a142..22532aba 100644 --- a/examples/c/encode/file/main.c +++ b/examples/c/encode/file/main.c @@ -1,6 +1,6 @@ /* example_c_encode_file - Simple FLAC file encoder using libFLAC * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/examples/cpp/Makefile.am b/examples/cpp/Makefile.am index 94a72e3f..ced8f8ed 100644 --- a/examples/cpp/Makefile.am +++ b/examples/cpp/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/examples/cpp/decode/Makefile.am b/examples/cpp/decode/Makefile.am index 0255a9e2..3c9499cb 100644 --- a/examples/cpp/decode/Makefile.am +++ b/examples/cpp/decode/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/examples/cpp/decode/file/Makefile.am b/examples/cpp/decode/file/Makefile.am index aa44a94d..ff608530 100644 --- a/examples/cpp/decode/file/Makefile.am +++ b/examples/cpp/decode/file/Makefile.am @@ -1,6 +1,6 @@ # example_cpp_decode_file - Simple FLAC file decoder using libFLAC # Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/examples/cpp/decode/file/main.cpp b/examples/cpp/decode/file/main.cpp index bea4b7c5..d1c29958 100644 --- a/examples/cpp/decode/file/main.cpp +++ b/examples/cpp/decode/file/main.cpp @@ -1,6 +1,6 @@ /* example_cpp_decode_file - Simple FLAC file decoder using libFLAC * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/examples/cpp/encode/Makefile.am b/examples/cpp/encode/Makefile.am index 0255a9e2..3c9499cb 100644 --- a/examples/cpp/encode/Makefile.am +++ b/examples/cpp/encode/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/examples/cpp/encode/file/Makefile.am b/examples/cpp/encode/file/Makefile.am index 3e3e6a8a..f293d615 100644 --- a/examples/cpp/encode/file/Makefile.am +++ b/examples/cpp/encode/file/Makefile.am @@ -1,6 +1,6 @@ # example_cpp_encode_file - Simple FLAC file encoder using libFLAC # Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/examples/cpp/encode/file/main.cpp b/examples/cpp/encode/file/main.cpp index 5c62853b..c420d230 100644 --- a/examples/cpp/encode/file/main.cpp +++ b/examples/cpp/encode/file/main.cpp @@ -1,6 +1,6 @@ /* example_cpp_encode_file - Simple FLAC file encoder using libFLAC * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/include/FLAC++/Makefile.am b/include/FLAC++/Makefile.am index f9e24b9e..ba5daa5b 100644 --- a/include/FLAC++/Makefile.am +++ b/include/FLAC++/Makefile.am @@ -1,6 +1,6 @@ # libFLAC++ - Free Lossless Audio Codec library # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/include/FLAC++/all.h b/include/FLAC++/all.h index 47a06715..fa5bd416 100644 --- a/include/FLAC++/all.h +++ b/include/FLAC++/all.h @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC++/decoder.h b/include/FLAC++/decoder.h index fee6a3b0..6f0bda99 100644 --- a/include/FLAC++/decoder.h +++ b/include/FLAC++/decoder.h @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC++/encoder.h b/include/FLAC++/encoder.h index acd5230c..2400823d 100644 --- a/include/FLAC++/encoder.h +++ b/include/FLAC++/encoder.h @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC++/export.h b/include/FLAC++/export.h index 19370fab..21d9d8b0 100644 --- a/include/FLAC++/export.h +++ b/include/FLAC++/export.h @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -92,7 +92,7 @@ * http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning */ #define FLACPP_API_VERSION_CURRENT 10 -#define FLACPP_API_VERSION_REVISION 0 /**< see above */ +#define FLACPP_API_VERSION_REVISION 1 /**< see above */ #define FLACPP_API_VERSION_AGE 0 /**< see above */ /* \} */ diff --git a/include/FLAC++/metadata.h b/include/FLAC++/metadata.h index 1599ec45..26bc4765 100644 --- a/include/FLAC++/metadata.h +++ b/include/FLAC++/metadata.h @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC/Makefile.am b/include/FLAC/Makefile.am index c12c22d4..80ded619 100644 --- a/include/FLAC/Makefile.am +++ b/include/FLAC/Makefile.am @@ -1,6 +1,6 @@ # libFLAC - Free Lossless Audio Codec library # Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/include/FLAC/all.h b/include/FLAC/all.h index a6a012fc..277dcbc5 100644 --- a/include/FLAC/all.h +++ b/include/FLAC/all.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC/assert.h b/include/FLAC/assert.h index 7d458264..ee3ee080 100644 --- a/include/FLAC/assert.h +++ b/include/FLAC/assert.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC/callback.h b/include/FLAC/callback.h index d00878b6..4babcd32 100644 --- a/include/FLAC/callback.h +++ b/include/FLAC/callback.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -90,7 +90,9 @@ typedef void* FLAC__IOHandle; /** Signature for the read callback. * The signature and semantics match POSIX fread() implementations - * and can generally be used interchangeably. + * and can generally be used interchangeably. Note that the global + * variable errno from errno.h is read by some libFLAC functions to + * detect read errors. * * \param ptr The address of the read buffer. * \param size The size of the records to be read. @@ -166,6 +168,9 @@ typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle); * * If the seek requirement for an interface is optional, you can signify that * a data source is not seekable by setting the \a seek field to \c NULL. + * + * See the detailed documentation for callbacks in the + * \link flac_callbacks callbacks \endlink module. */ typedef struct { FLAC__IOCallback_Read read; /**< See FLAC__IOCallbacks */ diff --git a/include/FLAC/export.h b/include/FLAC/export.h index 983f13b1..d14728a5 100644 --- a/include/FLAC/export.h +++ b/include/FLAC/export.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 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 12 +#define FLAC_API_VERSION_CURRENT 13 #define FLAC_API_VERSION_REVISION 0 /**< see above */ -#define FLAC_API_VERSION_AGE 0 /**< see above */ +#define FLAC_API_VERSION_AGE 1 /**< see above */ #ifdef __cplusplus extern "C" { diff --git a/include/FLAC/format.h b/include/FLAC/format.h index 2d548437..ef7c8b21 100644 --- a/include/FLAC/format.h +++ b/include/FLAC/format.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC/metadata.h b/include/FLAC/metadata.h index 651b7405..4747a5f3 100644 --- a/include/FLAC/metadata.h +++ b/include/FLAC/metadata.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -2197,6 +2197,34 @@ FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata */ FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation); + +/** Get the raw (binary) representation of a FLAC__StreamMetadata objeect. + * After use, free() the returned buffer. The length of the buffer is + * the length of the input metadata object plus 4 bytes for the header. + * + * \param object A pointer to metadata block to be converted. + * \assert + * \code object != NULL \endcode + * \retval FLAC__byte* + * \c NULL if there was an error, else a pointer to a buffer holding + * the requested data. + */ +FLAC_API FLAC__byte * FLAC__metadata_object_get_raw(const FLAC__StreamMetadata *object); + + +/** Turn a raw (binary) representation into a FLAC__StreamMetadata objeect. + * The returned object must be deleted with FLAC__metadata_object_delete() + * after use. + * + * \param buffer A pointer to a buffer containing a binary representation + * to be converted to a FLAC__StreamMetadata object + * \param length The length of the supplied buffer + * \retval FLAC__StreamMetadata* + * \c NULL if there was an error, else a pointer to a FLAC__StreamMetadata + * holding the requested data. + */ + +FLAC_API FLAC__StreamMetadata * FLAC__metadata_object_set_raw(FLAC__byte *buffer, FLAC__uint32 length); /* \} */ #ifdef __cplusplus diff --git a/include/FLAC/ordinals.h b/include/FLAC/ordinals.h index 494cc01f..d61aac57 100644 --- a/include/FLAC/ordinals.h +++ b/include/FLAC/ordinals.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC/stream_decoder.h b/include/FLAC/stream_decoder.h index f4e16488..2272bcac 100644 --- a/include/FLAC/stream_decoder.h +++ b/include/FLAC/stream_decoder.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/FLAC/stream_encoder.h b/include/FLAC/stream_encoder.h index 4ab4dce4..a0d02639 100644 --- a/include/FLAC/stream_encoder.h +++ b/include/FLAC/stream_encoder.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -850,7 +850,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *en * <tr> <td><b>5</b></td> <td>true</td> <td>false</td> <td>tukey(0.5)</td> <td>8</td> <td>0</td> <td>false</td> <td>false</td> <td>false</td> <td>0</td> <td>5</td> <td>0</td> </tr> * <tr> <td><b>6</b></td> <td>true</td> <td>false</td> <td>subdivide_tukey(2)</td> <td>8</td> <td>0</td> <td>false</td> <td>false</td> <td>false</td> <td>0</td> <td>6</td> <td>0</td> </tr> * <tr> <td><b>7</b></td> <td>true</td> <td>false</td> <td>subdivide_tukey(2)</td> <td>12</td> <td>0</td> <td>false</td> <td>false</td> <td>false</td> <td>0</td> <td>6</td> <td>0</td> </tr> - * <tr> <td><b>8</b></td> <td>true</td> <td>false</td> <td>subdivide_tukey(2)</td> <td>12</td> <td>0</td> <td>false</td> <td>false</td> <td>false</td> <td>0</td> <td>6</td> <td>0</td> </tr> + * <tr> <td><b>8</b></td> <td>true</td> <td>false</td> <td>subdivide_tukey(3)</td> <td>12</td> <td>0</td> <td>false</td> <td>false</td> <td>false</td> <td>0</td> <td>6</td> <td>0</td> </tr> * </table> * * \default \c 5 diff --git a/include/Makefile.am b/include/Makefile.am index efcb6cc8..01c5c9b6 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/include/share/alloc.h b/include/share/alloc.h index 02bdb300..b0da6941 100644 --- a/include/share/alloc.h +++ b/include/share/alloc.h @@ -1,6 +1,6 @@ /* alloc - Convenience routines for safely allocating memory * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/share/compat.h b/include/share/compat.h index 7388dc85..2d8d3e8e 100644 --- a/include/share/compat.h +++ b/include/share/compat.h @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2022 Xiph.Org Foundation + * Copyright (C) 2012-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -52,6 +52,7 @@ #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ #include <sys/types.h> /* for off_t */ #define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ +#define FLAC__OFF_T_MAX INT64_MAX #if !defined __MINGW32__ #define fseeko _fseeki64 #define ftello _ftelli64 @@ -63,8 +64,11 @@ #endif #else #define FLAC__off_t off_t +#define FLAC__OFF_T_MAX OFF_T_MAX #endif + + #ifdef HAVE_INTTYPES_H #include <inttypes.h> #endif diff --git a/include/share/endswap.h b/include/share/endswap.h index 35ffc62e..8687b9d7 100644 --- a/include/share/endswap.h +++ b/include/share/endswap.h @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2022 Xiph.Org Foundation + * Copyright (C) 2012-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/share/grabbag.h b/include/share/grabbag.h index fe88aa1b..6424fa97 100644 --- a/include/share/grabbag.h +++ b/include/share/grabbag.h @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/include/share/grabbag/cuesheet.h b/include/share/grabbag/cuesheet.h index 73a44037..d0eb94d4 100644 --- a/include/share/grabbag/cuesheet.h +++ b/include/share/grabbag/cuesheet.h @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/include/share/grabbag/file.h b/include/share/grabbag/file.h index abc758f4..9a2e086a 100644 --- a/include/share/grabbag/file.h +++ b/include/share/grabbag/file.h @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/include/share/grabbag/picture.h b/include/share/grabbag/picture.h index 05e1cb84..6bc4c391 100644 --- a/include/share/grabbag/picture.h +++ b/include/share/grabbag/picture.h @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/include/share/grabbag/replaygain.h b/include/share/grabbag/replaygain.h index c5180dd0..90e7a8c9 100644 --- a/include/share/grabbag/replaygain.h +++ b/include/share/grabbag/replaygain.h @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/include/share/grabbag/seektable.h b/include/share/grabbag/seektable.h index b48cfa16..751995be 100644 --- a/include/share/grabbag/seektable.h +++ b/include/share/grabbag/seektable.h @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/include/share/macros.h b/include/share/macros.h index d7f88feb..3e7ee554 100644 --- a/include/share/macros.h +++ b/include/share/macros.h @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2022 Xiph.Org Foundation + * Copyright (C) 2013-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/share/private.h b/include/share/private.h index 653c415d..5340d401 100644 --- a/include/share/private.h +++ b/include/share/private.h @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2022 Xiph.Org Foundation + * Copyright (C) 2013-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,7 +36,7 @@ * Unpublished debug routines from libFLAC. This should not be used from any * client code other than code shipped with the FLAC sources. */ -FLAC_API FLAC__bool FLAC__stream_encoder_disable_instruction_set(FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC_API FLAC__bool FLAC__stream_encoder_disable_instruction_set(FLAC__StreamEncoder *encoder, int value); FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); diff --git a/include/share/replaygain_synthesis.h b/include/share/replaygain_synthesis.h index c7661e56..1701995d 100644 --- a/include/share/replaygain_synthesis.h +++ b/include/share/replaygain_synthesis.h @@ -1,6 +1,6 @@ /* replaygain_synthesis - Routines for applying ReplayGain to a signal * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/include/share/safe_str.h b/include/share/safe_str.h index f52472ea..85ecbdaf 100644 --- a/include/share/safe_str.h +++ b/include/share/safe_str.h @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2022 Xiph.Org Foundation + * Copyright (C) 2013-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/share/win_utf8_io.h b/include/share/win_utf8_io.h index 61b8ca3f..ed07386f 100644 --- a/include/share/win_utf8_io.h +++ b/include/share/win_utf8_io.h @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2022 Xiph.Org Foundation + * Copyright (C) 2013-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/test_libs_common/file_utils_flac.h b/include/test_libs_common/file_utils_flac.h index b8487074..5c59c98b 100644 --- a/include/test_libs_common/file_utils_flac.h +++ b/include/test_libs_common/file_utils_flac.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/include/test_libs_common/metadata_utils.h b/include/test_libs_common/metadata_utils.h index 235ba128..1ed923a6 100644 --- a/include/test_libs_common/metadata_utils.h +++ b/include/test_libs_common/metadata_utils.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/m4/Makefile.am b/m4/Makefile.am index c888fc59..1a25b7a9 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/m4/bswap.m4 b/m4/bswap.m4 index 54bb8f0b..b1abae95 100644 --- a/m4/bswap.m4 +++ b/m4/bswap.m4 @@ -1,4 +1,4 @@ -dnl Copyright (C) 2012-2022 Xiph.Org Foundation +dnl Copyright (C) 2012-2023 Xiph.Org Foundation dnl dnl Redistribution and use in source and binary forms, with or without dnl modification, are permitted provided that the following conditions diff --git a/m4/endian.m4 b/m4/endian.m4 index 22e1c4c3..28fbf321 100644 --- a/m4/endian.m4 +++ b/m4/endian.m4 @@ -1,4 +1,4 @@ -dnl Copyright (C) 2012-2022 Xiph.Org Foundation +dnl Copyright (C) 2012-2023 Xiph.Org Foundation dnl dnl Redistribution and use in source and binary forms, with or without dnl modification, are permitted provided that the following conditions diff --git a/m4/stack_protect.m4 b/m4/stack_protect.m4 index 1a66aa26..cf8af664 100644 --- a/m4/stack_protect.m4 +++ b/m4/stack_protect.m4 @@ -1,4 +1,4 @@ -dnl Copyright (C) 2013-2022 Xiph.Org Foundation +dnl Copyright (C) 2013-2023 Xiph.Org Foundation dnl dnl Redistribution and use in source and binary forms, with or without dnl modification, are permitted provided that the following conditions diff --git a/man/Makefile.am b/man/Makefile.am index 2e8afe3f..50bacae9 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,6 +1,6 @@ # flac - Command-line FLAC encoder/decoder # Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/man/flac.md b/man/flac.md index a01c6c90..b51ac698 100644 --- a/man/flac.md +++ b/man/flac.md @@ -1,4 +1,4 @@ -% flac(1) Version 1.4.2 | Free Lossless Audio Codec conversion tool +% flac(1) Version 1.4.3 | Free Lossless Audio Codec conversion tool # NAME @@ -384,11 +384,6 @@ the HTML documentation. FILENAME is just shorthand for "\|\|\|\|FILENAME". For the format of SPECIFICATION, see the section **picture specification**. -**\--sector-align** -: Align encoding of multiple CD format files on sector boundaries. See the - HTML documentation for more information. This option is DEPRECATED and - may not exist in future versions of flac. - **\--ignore-chunk-sizes** : When encoding to flac, ignore the file size headers in WAV and AIFF files to attempt to work around problems with over-sized or malformed @@ -587,7 +582,6 @@ the HTML documentation. **\--no-replay-gain** **\--no-residual-gnuplot** **\--no-residual-text** -**\--no-sector-align** **\--no-seektable** **\--no-silent** **\--no-verify** diff --git a/man/metaflac.md b/man/metaflac.md index d15c36d0..8c049d74 100644 --- a/man/metaflac.md +++ b/man/metaflac.md @@ -1,4 +1,4 @@ -% metaflac(1) Version 1.4.2 | Free Lossless Audio Codec metadata tool +% metaflac(1) Version 1.4.3 | Free Lossless Audio Codec metadata tool # NAME @@ -58,7 +58,8 @@ modification time is set to the current time): **\--with-filename** : Prefix each output line with the FLAC file name (the default if more - than one FLAC file is specified). + than one FLAC file is specified). This option has no effect for + options exporting to a file, like --export-tags-to. **\--no-filename** : Do not prefix each output line with the FLAC file name (the default @@ -261,6 +262,26 @@ modification time is set to the current time): application data contents instead using \--application-data-format=hexdump. +**\--data-format=binary\|binary-headerless\|text** +: For use with --list. By default a human-readable text + representation of the data is isplayed. You may specify + --data-format=binary to dump the raw binary form of each metadata + block. Specify --data-format=binary-headerless to omit output of + metadata block headers, including the id of APPLICATION metadata + blocks. + +**\--append** +: Insert a metadata block from a file. This must be a binary block as + exported with --list --data-format=binary. The insertion point is + defined with --block-number=#. The new block will be added after the + given block number. This prevents the illegal insertion of a block + before the first STREAMINFO block. You may not --append another + STREAMINFO block. It is possible to copy a metadata block from one + file to another with this option. For example use + `metaflac --list --data-format=binary --block-number=6 file.flac > block` + to export the block, and then import it with + `metaflac --append anotherfile.flac < block` + **\--remove-all** : Remove all metadata blocks (except the STREAMINFO block) from the metadata. Unless \--dont-use-padding is specified, the blocks will be diff --git a/microbench/Makefile.am b/microbench/Makefile.am index ea20c73e..81de3adb 100644 --- a/microbench/Makefile.am +++ b/microbench/Makefile.am @@ -1,5 +1,5 @@ # FLAC - Free Lossless Audio Codec -# Copyright (C) 2015-2022 Xiph.Org Foundation +# Copyright (C) 2015-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/microbench/benchmark_residual.c b/microbench/benchmark_residual.c index 4621461a..d9b19d7b 100644 --- a/microbench/benchmark_residual.c +++ b/microbench/benchmark_residual.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/microbench/util.c b/microbench/util.c index 31859f6d..2ecd4a35 100644 --- a/microbench/util.c +++ b/microbench/util.c @@ -1,5 +1,5 @@ /* FLAC - Free Lossless Audio Codec - * Copyright (C) 2015-2022 Xiph.Org Foundation + * Copyright (C) 2015-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/microbench/util.h b/microbench/util.h index 77984805..1fba4466 100644 --- a/microbench/util.h +++ b/microbench/util.h @@ -1,5 +1,5 @@ /* FLAC - Free Lossless Audio Codec - * Copyright (C) 2015-2022 Xiph.Org Foundation + * Copyright (C) 2015-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/oss-fuzz/Makefile.am b/oss-fuzz/Makefile.am index 4494a437..bf669aa3 100644 --- a/oss-fuzz/Makefile.am +++ b/oss-fuzz/Makefile.am @@ -1,5 +1,5 @@ # FLAC - Free Lossless Audio Codec -# Copyright (C) 2019-2022 Xiph.Org Foundation +# Copyright (C) 2019-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries @@ -35,7 +35,7 @@ EXTRA_DIST = \ noinst_PROGRAMS = if USE_OSSFUZZERS -noinst_PROGRAMS += fuzzer_encoder fuzzer_encoder_v2 fuzzer_decoder fuzzer_seek fuzzer_metadata fuzzer_reencoder fuzzer_tool_flac +noinst_PROGRAMS += fuzzer_encoder fuzzer_encoder_v2 fuzzer_decoder fuzzer_seek fuzzer_metadata fuzzer_reencoder fuzzer_tool_flac fuzzer_tool_metaflac endif fuzzer_encoder_SOURCES = encoder.cc @@ -54,6 +54,16 @@ fuzzer_tool_flac_LDADD = \ $(top_builddir)/src/libFLAC/libFLAC.la \ @LTLIBICONV@ \ -lm +fuzzer_tool_metaflac_SOURCES = ${metaflac_SOURCES} empty.cc tool_metaflac.c # empty.cc is to force use of C++ linker, which is mandated by oss-fuzz +fuzzer_tool_metaflac_LDADD = \ + $(top_builddir)/src/share/utf8/libutf8.la \ + $(top_builddir)/src/share/grabbag/libgrabbag.la \ + $(top_builddir)/src/share/getopt/libgetopt.la \ + $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ + $(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \ + $(top_builddir)/src/libFLAC/libFLAC.la \ + @LTLIBICONV@ \ + -lm flac_libs = \ $(top_builddir)/src/libFLAC/libFLAC-static.la \ @@ -76,3 +86,19 @@ flac_SOURCES = \ ${top_builddir}/src/flac/local_string_utils.h \ ${top_builddir}/src/flac/utils.h \ ${top_builddir}/src/flac/vorbiscomment.h + +metaflac_SOURCES = \ + ${top_builddir}/src/metaflac/operations.c \ + ${top_builddir}/src/metaflac/operations_shorthand_cuesheet.c \ + ${top_builddir}/src/metaflac/operations_shorthand_picture.c \ + ${top_builddir}/src/metaflac/operations_shorthand_seektable.c \ + ${top_builddir}/src/metaflac/operations_shorthand_streaminfo.c \ + ${top_builddir}/src/metaflac/operations_shorthand_vorbiscomment.c \ + ${top_builddir}/src/metaflac/options.c \ + ${top_builddir}/src/metaflac/usage.c \ + ${top_builddir}/src/metaflac/utils.c \ + ${top_builddir}/src/metaflac/operations.h \ + ${top_builddir}/src/metaflac/operations_shorthand.h \ + ${top_builddir}/src/metaflac/options.h \ + ${top_builddir}/src/metaflac/usage.h \ + ${top_builddir}/src/metaflac/utils.h diff --git a/oss-fuzz/encoder_v2.cc b/oss-fuzz/encoder_v2.cc index 3e8d07e1..64483461 100644 --- a/oss-fuzz/encoder_v2.cc +++ b/oss-fuzz/encoder_v2.cc @@ -1,5 +1,5 @@ /* fuzzer_encoder_v2 - * Copyright (C) 2022 Xiph.Org Foundation + * Copyright (C) 2022-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/oss-fuzz/fuzzer_tool_flac.dict b/oss-fuzz/fuzzer_tool_flac.dict new file mode 100644 index 00000000..3ef9be51 --- /dev/null +++ b/oss-fuzz/fuzzer_tool_flac.dict @@ -0,0 +1,19 @@ +"--keep-foreign-metadata-if-present" +"--replay-gain" +"--apply-replaygain-which-is-not-lossless" + +"--force-raw-format" +"--force-aiff-format" +"--force-rf64-format" +"--force-wave64-format" +"--force-aiff-c-sowt-format" +"--force-aiff-c-none-format" +"--force-legacy-wave-format" +"--force-extensible-wave-format" + +"--endian=big" +"--sample-rate=1" +"--channels=1" +"--bps=32" +"--sign=unsigned" + diff --git a/oss-fuzz/metadata.cc b/oss-fuzz/metadata.cc index d03d6dbf..ad27fe95 100644 --- a/oss-fuzz/metadata.cc +++ b/oss-fuzz/metadata.cc @@ -1,5 +1,5 @@ /* fuzzer_metadata - * Copyright (C) 2022 Xiph.Org Foundation + * Copyright (C) 2022-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/oss-fuzz/seedcorpus/fuzzer_tool_flac/aiff-with-foreign-metadata-8bps.fuzz b/oss-fuzz/seedcorpus/fuzzer_tool_flac/aiff-with-foreign-metadata-8bps.fuzz Binary files differnew file mode 100644 index 00000000..944c775a --- /dev/null +++ b/oss-fuzz/seedcorpus/fuzzer_tool_flac/aiff-with-foreign-metadata-8bps.fuzz diff --git a/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-aiff-8bps.fuzz b/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-aiff-8bps.fuzz Binary files differnew file mode 100644 index 00000000..36fe91b5 --- /dev/null +++ b/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-aiff-8bps.fuzz diff --git a/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-wav-8bps.fuzz b/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-wav-8bps.fuzz Binary files differnew file mode 100644 index 00000000..6f4ed9c5 --- /dev/null +++ b/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-wav-8bps.fuzz diff --git a/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless-ogg.fuzz b/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless-ogg.fuzz Binary files differnew file mode 100644 index 00000000..e211fc6e --- /dev/null +++ b/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless-ogg.fuzz diff --git a/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless.fuzz b/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless.fuzz Binary files differnew file mode 100644 index 00000000..9d97430b --- /dev/null +++ b/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless.fuzz diff --git a/oss-fuzz/seedcorpus/fuzzer_tool_flac/wav-with-foreign-metadata-8bps.fuzz b/oss-fuzz/seedcorpus/fuzzer_tool_flac/wav-with-foreign-metadata-8bps.fuzz Binary files differnew file mode 100644 index 00000000..d708a3cb --- /dev/null +++ b/oss-fuzz/seedcorpus/fuzzer_tool_flac/wav-with-foreign-metadata-8bps.fuzz diff --git a/oss-fuzz/seek.cc b/oss-fuzz/seek.cc index 33339030..d3ccbe88 100644 --- a/oss-fuzz/seek.cc +++ b/oss-fuzz/seek.cc @@ -1,5 +1,5 @@ /* fuzzer_seek - * Copyright (C) 2022 Xiph.Org Foundation + * Copyright (C) 2022-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/oss-fuzz/tool_flac.c b/oss-fuzz/tool_flac.c index 3cceae6a..ce10a072 100644 --- a/oss-fuzz/tool_flac.c +++ b/oss-fuzz/tool_flac.c @@ -46,19 +46,22 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) char * argv[67]; char exename[] = "flac"; char filename[] = "/tmp/fuzzXXXXXX"; - int numarg = 0, maxarg, pad; + int numarg = 0, maxarg; int file_to_fuzz; + int tmp_stdout, tmp_stdin; + fpos_t pos_stdout; + bool use_stdin = false; + /* reset global vars */ flac__utils_verbosity_ = 0; share__opterr = 0; share__optind = 0; - if(size < 2) return 0; maxarg = data[0] & 63; - pad = data[0] & 64; + use_stdin = data[0] & 64; size_left--; argv[0] = exename; @@ -75,14 +78,38 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) if (file_to_fuzz < 0) abort(); write(file_to_fuzz,data+(size-size_left),size_left); - if(pad) - write(file_to_fuzz,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",12); close(file_to_fuzz); - argv[numarg++] = filename; + /* redirect stdout */ + fflush(stdout); + fgetpos(stdout,&pos_stdout); + tmp_stdout = dup(fileno(stdout)); + freopen("/dev/null","w",stdout); + + /* redirect stdin */ + tmp_stdin = dup(fileno(stdin)); + + if(use_stdin) + freopen(filename,"r",stdin); + else { + freopen("/dev/null","r",stdin); + argv[numarg++] = filename; + } main_to_fuzz(numarg,argv); + /* restore stdout */ + fflush(stdout); + dup2(tmp_stdout, fileno(stdout)); + close(tmp_stdout); + clearerr(stdout); + fsetpos(stdout,&pos_stdout); + + /* restore stdin */ + dup2(tmp_stdin, fileno(stdin)); + close(tmp_stdin); + clearerr(stdin); + unlink(filename); return 0; diff --git a/oss-fuzz/tool_metaflac.c b/oss-fuzz/tool_metaflac.c new file mode 100644 index 00000000..a6fafa26 --- /dev/null +++ b/oss-fuzz/tool_metaflac.c @@ -0,0 +1,136 @@ +/* fuzzer_tool_flac + * Copyright (C) 2023 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> /* for memcpy */ +#define FUZZ_TOOL_METAFLAC +#define fprintf(...) +#define printf(...) +#include "../src/metaflac/main.c" +#include "common.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + size_t size_left = size; + size_t arglen; + char * argv[64]; + char exename[] = "metaflac"; + char filename[] = "/tmp/fuzzXXXXXX"; + char filename_stdin[] = "/tmp/fuzzXXXXXX"; + int numarg = 0, maxarg; + int file_to_fuzz; + int tmp_stdout, tmp_stdin; + fpos_t pos_stdout; + bool use_stdin = false; + + share__opterr = 0; + share__optind = 0; + + + if(size < 2) + return 0; + + maxarg = data[0] & 15; + use_stdin = data[0] & 16; + size_left--; + + argv[0] = exename; + numarg++; + + /* Check whether input is zero delimited */ + while((arglen = strnlen((char *)data+(size-size_left),size_left)) < size_left && numarg < maxarg) { + argv[numarg++] = (char *)data+(size-size_left); + size_left -= arglen + 1; + } + + /* Create file to feed directly */ + file_to_fuzz = mkstemp(filename); + if (file_to_fuzz < 0) + abort(); + if(use_stdin) { + write(file_to_fuzz,data+(size-size_left),size_left/2); + size_left -= size_left/2; + } + else + write(file_to_fuzz,data+(size-size_left),size_left); + close(file_to_fuzz); + + argv[numarg++] = filename; + + /* Create file to feed to stdin */ + if(use_stdin) { + file_to_fuzz = mkstemp(filename_stdin); + if (file_to_fuzz < 0) + abort(); + write(file_to_fuzz,data+(size-size_left),size_left); + close(file_to_fuzz); + } + + /* redirect stdout */ + fflush(stdout); + fgetpos(stdout,&pos_stdout); + tmp_stdout = dup(fileno(stdout)); + freopen("/dev/null","w",stdout); + + /* redirect stdin */ + tmp_stdin = dup(fileno(stdin)); + if(use_stdin) + freopen(filename_stdin,"r",stdin); + else { + freopen("/dev/null","r",stdin); + argv[numarg++] = filename; + } + + main_to_fuzz(numarg,argv); + + /* restore stdout */ + fflush(stdout); + dup2(tmp_stdout, fileno(stdout)); + close(tmp_stdout); + clearerr(stdout); + fsetpos(stdout,&pos_stdout); + + /* restore stdin */ + dup2(tmp_stdin, fileno(stdin)); + close(tmp_stdin); + clearerr(stdin); + + unlink(filename); + + if(use_stdin) + unlink(filename_stdin); + + return 0; +} + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97e397aa..262feead 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.11) -option(ENABLE_64_BIT_WORDS "Set FLAC__BYTES_PER_WORD to 8 (4 is the default)" OFF) +option(ENABLE_64_BIT_WORDS "Set FLAC__BYTES_PER_WORD to 8, for 64-bit machines. For 32-bit machines, turning this off might give a tiny speed improvement" ON) option(BUILD_UTILS "Build utils" OFF) add_subdirectory("libFLAC") diff --git a/src/Makefile.am b/src/Makefile.am index c46a94fc..e9d60a9b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/src/flac/CMakeLists.txt b/src/flac/CMakeLists.txt index 40034502..da7ce8de 100644 --- a/src/flac/CMakeLists.txt +++ b/src/flac/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(flacapp local_string_utils.c utils.c vorbiscomment.c + version.rc $<$<BOOL:${WIN32}>:../../include/share/win_utf8_io.h> $<$<BOOL:${WIN32}>:../share/win_utf8_io/win_utf8_io.c>) set_property(TARGET flacapp PROPERTY RUNTIME_OUTPUT_NAME flac) diff --git a/src/flac/Makefile.am b/src/flac/Makefile.am index 5fc34386..279a7cb9 100644 --- a/src/flac/Makefile.am +++ b/src/flac/Makefile.am @@ -1,6 +1,6 @@ # flac - Command-line FLAC encoder/decoder # Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -16,13 +16,22 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +if HAVE_WINDRES +flac_DEPENDENCIES = version.o +windows_resource_link = -Wl,version.o +endif +endif + bin_PROGRAMS = flac AM_CFLAGS = @OGG_CFLAGS@ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include EXTRA_DIST = \ CMakeLists.txt \ - iffscan.c + iffscan.c \ + version.rc flac_SOURCES = \ analyze.c \ @@ -41,10 +50,6 @@ flac_SOURCES = \ utils.h \ vorbiscomment.h -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -endif - flac_LDADD = \ $(top_builddir)/src/share/utf8/libutf8.la \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ @@ -56,4 +61,9 @@ flac_LDADD = \ @LTLIBICONV@ \ -lm +flac_LDFLAGS = $(AM_LDFLAGS) $(windows_resource_link) + CLEANFILES = flac.exe + +.rc.o: + $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/src/flac/analyze.c b/src/flac/analyze.c index ff1b170d..0a85565e 100644 --- a/src/flac/analyze.c +++ b/src/flac/analyze.c @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -245,5 +245,8 @@ FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename) fprintf(outfile, "pause -1 'waiting...'\n"); fclose(outfile); +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + unlink(filename); +#endif return true; } diff --git a/src/flac/analyze.h b/src/flac/analyze.h index fbdec29e..ce07b145 100644 --- a/src/flac/analyze.h +++ b/src/flac/analyze.h @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/flac/decode.c b/src/flac/decode.c index c9c74546..90f7a6c8 100644 --- a/src/flac/decode.c +++ b/src/flac/decode.c @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -242,7 +242,7 @@ FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__ d->has_md5sum = false; d->bps = 0; d->channels = 0; - d->sample_rate = 0; + d->sample_rate = UINT32_MAX; d->channel_mask = 0; d->decode_position = 0; @@ -297,7 +297,11 @@ void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred) } #endif fclose(d->fout); + +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Always delete output file when fuzzing */ if(error_occurred) +#endif flac_unlink(d->outfilename); } } @@ -586,7 +590,10 @@ int DecoderSession_finish_error(DecoderSession *d) FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) { /* convert from mm:ss.sss to sample number if necessary */ - flac__utils_canonicalize_skip_until_specification(spec, sample_rate); + if(!flac__utils_canonicalize_skip_until_specification(spec, sample_rate)) { + flac__utils_printf(stderr, 1, "%s: ERROR, value of --until is too large\n", inbasefilename); + return false; + } /* special case: if "--until=-0", use the special value '0' to mean "end-of-stream" */ if(spec->is_relative && spec->value.samples == 0) { @@ -707,7 +714,7 @@ FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uin else if(format == FORMAT_AIFF) iff_size = 46 + foreign_metadata_size + aligned_data_size; else /* AIFF-C */ - iff_size = 16 + foreign_metadata_size + aligned_data_size + fm->aifc_comm_length; + iff_size = 16 + foreign_metadata_size + aligned_data_size + (fm?fm->aifc_comm_length:0); if(format != FORMAT_WAVE64 && format != FORMAT_RF64 && iff_size >= 0xFFFFFFF4) { flac__utils_printf(stderr, 1, "%s: ERROR: stream is too big to fit in a single %s file\n", decoder_session->inbasefilename, fmt_desc); @@ -1095,7 +1102,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder DecoderSession *decoder_session = (DecoderSession*)client_data; FILE *fout = decoder_session->fout; const uint32_t bps = frame->header.bits_per_sample, channels = frame->header.channels; - const uint32_t shift = (decoder_session->format != FORMAT_RAW && (bps%8))? 8-(bps%8): 0; + const uint32_t shift = (bps%8)? 8-(bps%8): 0; FLAC__bool is_big_endian = ( (decoder_session->format == FORMAT_AIFF || (decoder_session->format == FORMAT_AIFF_C && decoder_session->subformat == SUBFORMAT_AIFF_C_NONE)) ? true : ( decoder_session->format == FORMAT_WAVE || decoder_session->format == FORMAT_WAVE64 || decoder_session->format == FORMAT_RF64 || (decoder_session->format == FORMAT_AIFF_C && decoder_session->subformat == SUBFORMAT_AIFF_C_SOWT) ? false : @@ -1140,6 +1147,10 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder else { /* must not have gotten STREAMINFO, save the bps from the frame header */ FLAC__ASSERT(!decoder_session->got_stream_info); + if(decoder_session->format == FORMAT_RAW && ((decoder_session->bps % 8) != 0 || decoder_session->bps < 4)) { + flac__utils_printf(stderr, 1, "%s: ERROR: bits per sample is %u, must be 8/16/24/32 for raw format output\n", decoder_session->inbasefilename, decoder_session->bps); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } decoder_session->bps = bps; } @@ -1161,7 +1172,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder } /* sanity-check the sample rate */ - if(!decoder_session->got_stream_info) { + if(decoder_session->sample_rate < UINT32_MAX) { if(frame->header.sample_rate != decoder_session->sample_rate) { if(decoder_session->got_stream_info) flac__utils_printf(stderr, 1, "%s: ERROR, sample rate is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, frame->header.sample_rate, decoder_session->sample_rate); @@ -1172,15 +1183,16 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder } } else { + /* must not have gotten STREAMINFO, save the sample rate from the frame header */ + FLAC__ASSERT(!decoder_session->got_stream_info); decoder_session->sample_rate = frame->header.sample_rate; } /* * limit the number of samples to accept based on --until */ - FLAC__ASSERT(!decoder_session->skip_specification->is_relative); /* if we never got the total_samples from the metadata, the skip and until specs would never have been canonicalized, so protect against that: */ - if(decoder_session->skip_specification->is_relative) { + if(decoder_session->skip_specification->is_relative || !decoder_session->got_stream_info) { if(decoder_session->skip_specification->value.samples == 0) /* special case for when no --skip was given */ decoder_session->skip_specification->is_relative = false; /* convert to our meaning of beginning-of-stream */ else { @@ -1188,7 +1200,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } } - if(decoder_session->until_specification->is_relative) { + if(decoder_session->until_specification->is_relative || !decoder_session->got_stream_info) { if(decoder_session->until_specification->value.samples == 0) /* special case for when no --until was given */ decoder_session->until_specification->is_relative = false; /* convert to our meaning of end-of-stream */ else { @@ -1452,7 +1464,11 @@ void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMet decoder_session->channels = metadata->data.stream_info.channels; decoder_session->sample_rate = metadata->data.stream_info.sample_rate; - flac__utils_canonicalize_skip_until_specification(decoder_session->skip_specification, decoder_session->sample_rate); + if(!flac__utils_canonicalize_skip_until_specification(decoder_session->skip_specification, decoder_session->sample_rate)) { + flac__utils_printf(stderr, 1, "%s: ERROR, value of --skip is too large\n", decoder_session->inbasefilename); + decoder_session->abort_flag = true; + return; + } FLAC__ASSERT(decoder_session->skip_specification->value.samples >= 0); skip = (FLAC__uint64)decoder_session->skip_specification->value.samples; @@ -1529,6 +1545,13 @@ void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMet return; } } + else if(decoder_session->bps == 0) { + flac__utils_printf(stderr, 1, "%s: WARNING: can't apply ReplayGain, bit-per-sample value is invalid\n", decoder_session->inbasefilename); + if(decoder_session->treat_warnings_as_errors) { + decoder_session->abort_flag = true; + return; + } + } else { const char *ls[] = { "no", "peak", "hard" }; const char *ns[] = { "no", "low", "medium", "high" }; diff --git a/src/flac/decode.h b/src/flac/decode.h index 67bd3c04..24f5723d 100644 --- a/src/flac/decode.h +++ b/src/flac/decode.h @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/flac/encode.c b/src/flac/encode.c index bc71088d..a945b356 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -47,7 +47,6 @@ #endif #define max(x,y) ((x)>(y)?(x):(y)) -/* this MUST be >= 588 so that sector aligning can take place with one read */ /* this MUST be < 2^sizeof(size_t) / ( FLAC__MAX_CHANNELS * (FLAC__MAX_BITS_PER_SAMPLE/8) ) */ #define CHUNK_OF_SAMPLES 2048 @@ -143,7 +142,7 @@ static FLAC__int32 *input_[FLAC__MAX_CHANNELS]; */ static FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length); static void EncoderSession_destroy(EncoderSession *e); -static int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail); +static int EncoderSession_finish_ok(EncoderSession *e, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail); static int EncoderSession_finish_error(EncoderSession *e); static FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t options); static FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], uint32_t samples); @@ -327,7 +326,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio } data_bytes -= (16+8); } - if(data_bytes < 16) { + if(data_bytes < 16 || data_bytes > (UINT32_MAX-8)) { flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'fmt ' chunk has length = %u\n", e->inbasefilename, (uint32_t)data_bytes); return false; } @@ -482,7 +481,6 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio data_bytes = ds64_data_size; } if(options.ignore_chunk_sizes) { - FLAC__ASSERT(!options.sector_align); if(data_bytes) { flac__utils_printf(stderr, 1, "%s: WARNING: 'data' chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); if(e->treat_warnings_as_errors) @@ -717,7 +715,6 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio return false; data_bytes = xx; if(options.ignore_chunk_sizes) { - FLAC__ASSERT(!options.sector_align); if(data_bytes) { flac__utils_printf(stderr, 1, "%s: WARNING: 'SSND' chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); if(e->treat_warnings_as_errors) @@ -864,7 +861,6 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena { EncoderSession encoder_session; size_t channel_map[FLAC__MAX_CHANNELS]; - int info_align_carry = -1, info_align_zero = -1; if(!EncoderSession_construct(&encoder_session, options, infilesize, infile, infilename, outfilename, lookahead, lookahead_length)) return 1; @@ -946,34 +942,19 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena flac__utils_printf(stderr, 1, "%s: ERROR: unsupported bits-per-sample %u\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); return EncoderSession_finish_error(&encoder_session); } - if(options.sector_align) { - if(encoder_session.info.channels != 2) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.channels); - return EncoderSession_finish_error(&encoder_session); - } - if(encoder_session.info.sample_rate != 44100) { - flac__utils_printf(stderr, 1, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.sample_rate); - return EncoderSession_finish_error(&encoder_session); - } - if(encoder_session.info.bits_per_sample-encoder_session.info.shift != 16) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has %u bits-per-sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); - return EncoderSession_finish_error(&encoder_session); - } - } { FLAC__uint64 total_samples_in_input; /* WATCHOUT: may be 0 to mean "unknown" */ FLAC__uint64 skip; FLAC__uint64 until; /* a value of 0 mean end-of-stream (i.e. --until=-0) */ uint32_t consecutive_eos_count = 0; - uint32_t align_remainder = 0; switch(options.format) { case FORMAT_RAW: if(infilesize < 0) total_samples_in_input = 0; else - total_samples_in_input = (FLAC__uint64)infilesize / encoder_session.info.bytes_per_wide_sample + *options.align_reservoir_samples; + total_samples_in_input = (FLAC__uint64)infilesize / encoder_session.info.bytes_per_wide_sample; break; case FORMAT_WAVE: case FORMAT_WAVE64: @@ -981,7 +962,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena case FORMAT_AIFF: case FORMAT_AIFF_C: /* truncation in the division removes any padding byte that was counted in encoder_session.fmt.iff.data_bytes */ - total_samples_in_input = encoder_session.fmt.iff.data_bytes / encoder_session.info.bytes_per_wide_sample + *options.align_reservoir_samples; + total_samples_in_input = encoder_session.fmt.iff.data_bytes / encoder_session.info.bytes_per_wide_sample; /* check for chunks trailing the audio data */ if(!options.ignore_chunk_sizes && !options.format_options.iff.foreign_metadata @@ -1004,7 +985,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena break; case FORMAT_FLAC: case FORMAT_OGGFLAC: - total_samples_in_input = encoder_session.fmt.flac.client_data.metadata_blocks[0]->data.stream_info.total_samples + *options.align_reservoir_samples; + total_samples_in_input = encoder_session.fmt.flac.client_data.metadata_blocks[0]->data.stream_info.total_samples; break; default: FLAC__ASSERT(0); @@ -1016,12 +997,12 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena * now that we know the sample rate, canonicalize the * --skip string to an absolute sample number: */ - flac__utils_canonicalize_skip_until_specification(&options.skip_specification, encoder_session.info.sample_rate); + if(!flac__utils_canonicalize_skip_until_specification(&options.skip_specification, encoder_session.info.sample_rate)) { + flac__utils_printf(stderr, 1, "%s: ERROR: value of --skip is too large\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); + return EncoderSession_finish_error(&encoder_session); + } FLAC__ASSERT(options.skip_specification.value.samples >= 0); skip = (FLAC__uint64)options.skip_specification.value.samples; - FLAC__ASSERT(!options.sector_align || (options.format != FORMAT_FLAC && options.format != FORMAT_OGGFLAC && skip == 0)); - /* *options.align_reservoir_samples will be 0 unless --sector-align is used */ - FLAC__ASSERT(options.sector_align || *options.align_reservoir_samples == 0); /* * now that we possibly know the input size, canonicalize the @@ -1030,11 +1011,15 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena if(!canonicalize_until_specification(&options.until_specification, encoder_session.inbasefilename, encoder_session.info.sample_rate, skip, total_samples_in_input)) return EncoderSession_finish_error(&encoder_session); until = (FLAC__uint64)options.until_specification.value.samples; - FLAC__ASSERT(!options.sector_align || until == 0); /* adjust encoding parameters based on skip and until values */ switch(options.format) { case FORMAT_RAW: + FLAC__ASSERT(sizeof(FLAC__off_t) == 8); + if(skip >= INT64_MAX / encoder_session.info.bytes_per_wide_sample) { + flac__utils_printf(stderr, 1, "%s: ERROR: value of --skip is too large\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); + return EncoderSession_finish_error(&encoder_session); + } infilesize -= (FLAC__off_t)skip * encoder_session.info.bytes_per_wide_sample; encoder_session.total_samples_to_encode = total_samples_in_input - skip; break; @@ -1043,6 +1028,11 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena case FORMAT_RF64: case FORMAT_AIFF: case FORMAT_AIFF_C: + FLAC__ASSERT(sizeof(FLAC__off_t) == 8); + if(skip >= INT64_MAX / encoder_session.info.bytes_per_wide_sample) { + flac__utils_printf(stderr, 1, "%s: ERROR: value of --skip is too large\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); + return EncoderSession_finish_error(&encoder_session); + } encoder_session.fmt.iff.data_bytes -= skip * encoder_session.info.bytes_per_wide_sample; if(options.ignore_chunk_sizes) { encoder_session.total_samples_to_encode = 0; @@ -1064,21 +1054,12 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena if(until > 0) { const FLAC__uint64 trim = total_samples_in_input - until; FLAC__ASSERT(total_samples_in_input > 0); - FLAC__ASSERT(!options.sector_align); if(options.format == FORMAT_RAW) infilesize -= (FLAC__off_t)trim * encoder_session.info.bytes_per_wide_sample; else if(EncoderSession_format_is_iff(&encoder_session)) encoder_session.fmt.iff.data_bytes -= trim * encoder_session.info.bytes_per_wide_sample; encoder_session.total_samples_to_encode -= trim; } - if(options.sector_align && (options.format != FORMAT_RAW || infilesize >=0)) { /* for RAW, need to know the filesize */ - FLAC__ASSERT(skip == 0); /* asserted above too, but lest we forget */ - align_remainder = (uint32_t)(encoder_session.total_samples_to_encode % 588); - if(options.is_last_file) - encoder_session.total_samples_to_encode += (588-align_remainder); /* will pad with zeroes */ - else - encoder_session.total_samples_to_encode -= align_remainder; /* will stop short and carry over to next file */ - } switch(options.format) { case FORMAT_RAW: encoder_session.unencoded_size = encoder_session.total_samples_to_encode * encoder_session.info.bytes_per_wide_sample; @@ -1183,36 +1164,6 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena } /* - * first do any samples in the reservoir - */ - if(options.sector_align && *options.align_reservoir_samples > 0) { - FLAC__ASSERT(options.format != FORMAT_FLAC && options.format != FORMAT_OGGFLAC); /* check again */ - if(!EncoderSession_process(&encoder_session, (const FLAC__int32 * const *)options.align_reservoir, *options.align_reservoir_samples)) { - print_error_with_state(&encoder_session, "ERROR during encoding"); - return EncoderSession_finish_error(&encoder_session); - } - } - - /* - * decrement infilesize or the data_bytes counter if we need to align the file - */ - if(options.sector_align) { - if(options.is_last_file) { - *options.align_reservoir_samples = 0; - } - else { - *options.align_reservoir_samples = align_remainder; - if(options.format == FORMAT_RAW) { - FLAC__ASSERT(infilesize >= 0); - infilesize -= (FLAC__off_t)((*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample); - FLAC__ASSERT(infilesize >= 0); - } - else if(EncoderSession_format_is_iff(&encoder_session)) - encoder_session.fmt.iff.data_bytes -= (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample; - } - } - - /* * now do samples from the file */ switch(options.format) { @@ -1265,10 +1216,18 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena wanted = (size_t) min((FLAC__uint64)wanted, max_input_bytes - total_input_bytes_read); if(lookahead_length > 0) { - FLAC__ASSERT(lookahead_length <= wanted); - memcpy(ubuffer.u8, lookahead, lookahead_length); - wanted -= lookahead_length; - bytes_read = lookahead_length; + if(lookahead_length <= wanted) { + memcpy(ubuffer.u8, lookahead, lookahead_length); + wanted -= lookahead_length; + bytes_read = lookahead_length; + } + else { + /* This happens when --until is used on a very short file */ + FLAC__ASSERT(lookahead_length < CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample); + memcpy(ubuffer.u8, lookahead, wanted); + wanted = 0; + bytes_read = wanted; + } if(wanted > 0) { bytes_read += fread(ubuffer.u8+lookahead_length, sizeof(uint8_t), wanted, infile); if(ferror(infile)) { @@ -1382,7 +1341,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena break; } - if(!FLAC__stream_decoder_process_single(encoder_session.fmt.flac.decoder)) { + if(decoder_state == FLAC__STREAM_DECODER_ABORTED || !FLAC__stream_decoder_process_single(encoder_session.fmt.flac.decoder)) { flac__utils_printf(stderr, 1, "%s: ERROR: while decoding FLAC input, state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); return EncoderSession_finish_error(&encoder_session); } @@ -1398,53 +1357,10 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena return EncoderSession_finish_error(&encoder_session); } - /* - * now read unaligned samples into reservoir or pad with zeroes if necessary - */ - if(options.sector_align) { - if(options.is_last_file) { - uint32_t wide_samples = 588 - align_remainder; - if(wide_samples < 588) { - uint32_t channel; - - info_align_zero = wide_samples; - for(channel = 0; channel < encoder_session.info.channels; channel++) - memset(input_[channel], 0, sizeof(input_[0][0]) * wide_samples); - - if(!EncoderSession_process(&encoder_session, (const FLAC__int32 * const *)input_, wide_samples)) { - print_error_with_state(&encoder_session, "ERROR during encoding"); - return EncoderSession_finish_error(&encoder_session); - } - } - } - else { - if(*options.align_reservoir_samples > 0) { - size_t bytes_read; - FLAC__ASSERT(CHUNK_OF_SAMPLES >= 588); - bytes_read = fread(ubuffer.u8, sizeof(uint8_t), (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample, infile); - if(bytes_read == 0 && ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - else if(bytes_read != (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample) { - flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %" PRIu64 " bytes; expected %" PRIu64 " samples, got %" PRIu64 " samples\n", encoder_session.inbasefilename, bytes_read, encoder_session.total_samples_to_encode, encoder_session.samples_written); - if(encoder_session.treat_warnings_as_errors) - return EncoderSession_finish_error(&encoder_session); - } - else { - info_align_carry = *options.align_reservoir_samples; - if(!format_input(options.align_reservoir, *options.align_reservoir_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map)) - return EncoderSession_finish_error(&encoder_session); - } - } - } - } } return EncoderSession_finish_ok( &encoder_session, - info_align_carry, - info_align_zero, EncoderSession_format_is_iff(&encoder_session)? options.format_options.iff.foreign_metadata : 0, options.error_on_compression_fail ); @@ -1520,7 +1436,9 @@ FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, e->fmt.flac.client_data.fatal_error = false; break; default: +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION FLAC__ASSERT(0); +#endif /* double protection */ return false; } @@ -1571,7 +1489,7 @@ void EncoderSession_destroy(EncoderSession *e) } } -int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail) +int EncoderSession_finish_ok(EncoderSession *e, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail) { FLAC__StreamEncoderState fse_state = FLAC__STREAM_ENCODER_OK; int ret = 0; @@ -1597,14 +1515,6 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a print_verify_error(e); ret = 1; } - else { - if(info_align_carry >= 0) { - flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d samples to be carried over\n", e->inbasefilename, info_align_carry); - } - if(info_align_zero >= 0) { - flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d zero samples to be appended\n", e->inbasefilename, info_align_zero); - } - } /*@@@@@@ should this go here or somewhere else? */ if(ret == 0 && foreign_metadata) { @@ -1626,6 +1536,11 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a ret = 1; } +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Always delete output file when fuzzing */ + flac_unlink(e->outfilename); +#endif + EncoderSession_destroy(e); return ret; @@ -1951,8 +1866,12 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio flac_decoder_data->num_metadata_blocks = j; if(options.padding > 0) p = options.padding; - if(p < 0) - p = e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8; + if(p < 0) { + if(sample_rate == 0) + p = FLAC_ENCODE__DEFAULT_PADDING; + else + p = e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8; + } if(p > 0) p += (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); p = min(p, (int)((1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1)); @@ -2015,7 +1934,10 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio if(options.padding != 0) { padding.is_last = false; /* the encoder will set this for us */ padding.type = FLAC__METADATA_TYPE_PADDING; - padding.length = (uint32_t)(options.padding>0? options.padding : (e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8)) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); + if(sample_rate == 0) + padding.length = (uint32_t)(options.padding>0? options.padding : FLAC_ENCODE__DEFAULT_PADDING) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); + else + padding.length = (uint32_t)(options.padding>0? options.padding : (e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8)) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); padding.length = min(padding.length, (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1); static_metadata_append(&static_metadata, &padding, /*needs_delete=*/false); } @@ -2065,19 +1987,25 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio } break; case CST_MAX_LPC_ORDER: +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION FLAC__stream_encoder_set_max_lpc_order(e->encoder, options.compression_settings[ic].value.t_unsigned); +#endif break; case CST_QLP_COEFF_PRECISION: FLAC__stream_encoder_set_qlp_coeff_precision(e->encoder, options.compression_settings[ic].value.t_unsigned); break; case CST_DO_QLP_COEFF_PREC_SEARCH: +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION FLAC__stream_encoder_set_do_qlp_coeff_prec_search(e->encoder, options.compression_settings[ic].value.t_bool); +#endif break; case CST_DO_ESCAPE_CODING: FLAC__stream_encoder_set_do_escape_coding(e->encoder, options.compression_settings[ic].value.t_bool); break; case CST_DO_EXHAUSTIVE_MODEL_SEARCH: +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION FLAC__stream_encoder_set_do_exhaustive_model_search(e->encoder, options.compression_settings[ic].value.t_bool); +#endif break; case CST_MIN_RESIDUAL_PARTITION_ORDER: FLAC__stream_encoder_set_min_residual_partition_order(e->encoder, options.compression_settings[ic].value.t_unsigned); @@ -2090,8 +2018,10 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio break; } } +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION if(*apodizations) FLAC__stream_encoder_set_apodization(e->encoder, apodizations); +#endif FLAC__stream_encoder_set_total_samples_estimate(e->encoder, e->total_samples_to_encode); FLAC__stream_encoder_set_metadata(e->encoder, (num_metadata > 0)? metadata : 0, num_metadata); FLAC__stream_encoder_set_limit_min_bitrate(e->encoder, options.limit_min_bitrate); @@ -2180,14 +2110,13 @@ FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int if(num_requested_seek_points == 0 && 0 == cuesheet) return true; - if(num_requested_seek_points < 0) { #if FLAC__HAS_OGG - /*@@@@@@ workaround ogg bug: too many seekpoints makes table not fit in one page */ - if(e->use_ogg && e->total_samples_to_encode > 0 && e->total_samples_to_encode / e->info.sample_rate / 10 > 230) - requested_seek_points = "230x;"; - else + if(e->use_ogg) + return true; #endif - requested_seek_points = "10s;"; + + if(num_requested_seek_points < 0) { + requested_seek_points = "10s;"; num_requested_seek_points = 1; } @@ -2226,7 +2155,10 @@ FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) { /* convert from mm:ss.sss to sample number if necessary */ - flac__utils_canonicalize_skip_until_specification(spec, sample_rate); + if(!flac__utils_canonicalize_skip_until_specification(spec, sample_rate)) { + flac__utils_printf(stderr, 1, "%s: ERROR, value of --until is too large\n", inbasefilename); + return false; + } /* special case: if "--until=-0", use the special value '0' to mean "end-of-stream" */ if(spec->is_relative && spec->value.samples == 0) { @@ -2390,7 +2322,7 @@ FLAC__bool format_input(FLAC__int32 *dest[], uint32_t wide_samples, FLAC__bool i uint32_t t; t = ubuffer.u8[b]; t |= (uint32_t)(ubuffer.u8[b+1]) << 8; - t |= (int32_t)(ubuffer.s8[b+2]) << 16; + t |= (uint32_t)((int32_t)(ubuffer.s8[b+2])) << 16; out[channel][wide_sample] = t; b += 3*channels; } @@ -2876,7 +2808,7 @@ FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, const char *fn) return false; e = ((FLAC__uint16)(buf[0])<<8 | (FLAC__uint16)(buf[1]))-0x3FFF; shift = 63-e; - if((buf[0]>>7)==1U || e<0 || e>63) { + if((buf[0]>>7)==1U || e<0 || e>=63) { flac__utils_printf(stderr, 1, "%s: ERROR: invalid floating-point value\n", fn); return false; } diff --git a/src/flac/encode.h b/src/flac/encode.h index 5cb2cb78..2d65c506 100644 --- a/src/flac/encode.h +++ b/src/flac/encode.h @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -76,14 +76,10 @@ typedef struct { FLAC__bool cued_seekpoints; FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */ - /* options related to --replay-gain and --sector-align */ FLAC__bool is_first_file; FLAC__bool is_last_file; - FLAC__int32 **align_reservoir; - unsigned *align_reservoir_samples; FLAC__bool replay_gain; FLAC__bool ignore_chunk_sizes; - FLAC__bool sector_align; FLAC__bool error_on_compression_fail; FLAC__bool limit_min_bitrate; FLAC__bool relaxed_foreign_metadata_handling; diff --git a/src/flac/foreign_metadata.c b/src/flac/foreign_metadata.c index 63f982cc..f63fc3e6 100644 --- a/src/flac/foreign_metadata.c +++ b/src/flac/foreign_metadata.c @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -99,7 +99,12 @@ static FLAC__bool compare_data_(FILE *fin, FILE *fout, size_t size, const char * static FLAC__bool append_block_(foreign_metadata_t *fm, FLAC__off_t offset, FLAC__uint32 size, const char **error) { - foreign_block_t *fb = safe_realloc_nofree_muladd2_(fm->blocks, sizeof(foreign_block_t), /*times (*/fm->num_blocks, /*+*/1/*)*/); + foreign_block_t *fb; + if(size >= ((1u << FLAC__STREAM_METADATA_LENGTH_LEN) - FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)) { + if(error) *error = "found foreign metadata chunk is too large (max is 16MiB per chunk)"; + return false; + } + fb = safe_realloc_nofree_muladd2_(fm->blocks, sizeof(foreign_block_t), /*times (*/fm->num_blocks, /*+*/1/*)*/); if(fb) { fb[fm->num_blocks].offset = offset; fb[fm->num_blocks].size = size; diff --git a/src/flac/foreign_metadata.h b/src/flac/foreign_metadata.h index 83d8e81f..fa68d46f 100644 --- a/src/flac/foreign_metadata.h +++ b/src/flac/foreign_metadata.h @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/flac/iffscan.c b/src/flac/iffscan.c index 5b868fd1..a5472e0c 100644 --- a/src/flac/iffscan.c +++ b/src/flac/iffscan.c @@ -1,6 +1,6 @@ /* iffscan - Simple AIFF/RIFF chunk scanner * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/flac/local_string_utils.h b/src/flac/local_string_utils.h index e869d701..01f891f7 100644 --- a/src/flac/local_string_utils.h +++ b/src/flac/local_string_utils.h @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/flac/main.c b/src/flac/main.c index 56c2dfc4..c22e602c 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -151,7 +151,6 @@ static struct share__option long_options_[] = { { "lax" , share__no_argument, 0, 0 }, { "replay-gain" , share__no_argument, 0, 0 }, { "ignore-chunk-sizes" , share__no_argument, 0, 0 }, - { "sector-align" , share__no_argument, 0, 0 }, /* DEPRECATED */ { "seekpoint" , share__required_argument, 0, 'S' }, { "padding" , share__required_argument, 0, 'P' }, #if FLAC__HAS_OGG @@ -194,7 +193,6 @@ static struct share__option long_options_[] = { { "no-keep-foreign-metadata" , share__no_argument, 0, 0 }, { "no-replay-gain" , share__no_argument, 0, 0 }, { "no-ignore-chunk-sizes" , share__no_argument, 0, 0 }, - { "no-sector-align" , share__no_argument, 0, 0 }, /* DEPRECATED */ { "no-utf8-convert" , share__no_argument, 0, 0 }, { "no-lax" , share__no_argument, 0, 0 }, #if FLAC__HAS_OGG @@ -257,7 +255,6 @@ static struct { FLAC__bool keep_foreign_metadata_if_present; FLAC__bool replay_gain; FLAC__bool ignore_chunk_sizes; - FLAC__bool sector_align; FLAC__bool utf8_convert; /* true by default, to convert tag strings from locale to utf-8, false if --no-utf8-convert used */ const char *cmdline_forced_outfilename; const char *output_prefix; @@ -302,10 +299,6 @@ static struct { * miscellaneous globals */ -static FLAC__int32 align_reservoir_0[588], align_reservoir_1[588]; /* for carrying over samples from --sector-align */ /* DEPRECATED */ -static FLAC__int32 *align_reservoir[2] = { align_reservoir_0, align_reservoir_1 }; -static uint32_t align_reservoir_samples = 0; /* 0 .. 587 */ - #ifndef FUZZ_TOOL_FLAC int main(int argc, char *argv[]) @@ -441,8 +434,6 @@ int do_it(void) if(option_values.ignore_chunk_sizes) { if(option_values.mode_decode) return usage_error("ERROR: --ignore-chunk-sizes only allowed for encoding\n"); - if(0 != option_values.sector_align) - return usage_error("ERROR: --ignore-chunk-sizes not allowed with --sector-align\n"); if(0 != option_values.until_specification) return usage_error("ERROR: --ignore-chunk-sizes not allowed with --until\n"); if(0 != option_values.cue_specification) @@ -450,22 +441,6 @@ int do_it(void) if(0 != option_values.cuesheet_filename) return usage_error("ERROR: --ignore-chunk-sizes not allowed with --cuesheet\n"); } - if(option_values.sector_align) { - if(option_values.mode_decode) - return usage_error("ERROR: --sector-align only allowed for encoding\n"); - if(0 != option_values.skip_specification) - return usage_error("ERROR: --sector-align not allowed with --skip\n"); - if(0 != option_values.until_specification) - return usage_error("ERROR: --sector-align not allowed with --until\n"); - if(0 != option_values.cue_specification) - return usage_error("ERROR: --sector-align not allowed with --cue\n"); - if(option_values.format_channels >= 0 && option_values.format_channels != 2) - return usage_error("ERROR: --sector-align can only be done with stereo input\n"); - if(option_values.format_bps >= 0 && option_values.format_bps != 16) - return usage_error("ERROR: --sector-align can only be done with 16-bit samples\n"); - if(option_values.format_sample_rate >= 0 && option_values.format_sample_rate != 44100) - return usage_error("ERROR: --sector-align can only be done with a sample rate of 44100\n"); - } if(option_values.replay_gain) { if(option_values.force_to_stdout) return usage_error("ERROR: --replay-gain not allowed with -c/--stdout\n"); @@ -505,7 +480,7 @@ int do_it(void) flac__utils_printf(stderr, 2, "\n"); flac__utils_printf(stderr, 2, "flac %s\n", FLAC__VERSION_STRING); - flac__utils_printf(stderr, 2, "Copyright (C) 2000-2009 Josh Coalson, 2011-2022 Xiph.Org Foundation\n"); + flac__utils_printf(stderr, 2, "Copyright (C) 2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation\n"); flac__utils_printf(stderr, 2, "flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n"); flac__utils_printf(stderr, 2, "welcome to redistribute it under certain conditions. Type `flac' for details.\n\n"); @@ -543,8 +518,10 @@ int do_it(void) for(i = 0, retval = 0; i < option_values.num_files; i++) { if(0 == strcmp(option_values.filenames[i], "-") && !first) continue; - retval |= encode_file(option_values.filenames[i], first, i == (option_values.num_files-1)); - first = false; + if(encode_file(option_values.filenames[i], first, i == (option_values.num_files-1))) + retval = 1; + else + first = false; } if(option_values.replay_gain && retval == 0) { float album_gain, album_peak; @@ -571,6 +548,7 @@ FLAC__bool init_options(void) { option_values.show_help = false; option_values.show_explain = false; + option_values.show_version = false; option_values.mode_decode = false; option_values.verify = false; option_values.treat_warnings_as_errors = false; @@ -602,7 +580,6 @@ FLAC__bool init_options(void) option_values.keep_foreign_metadata_if_present = false; option_values.replay_gain = false; option_values.ignore_chunk_sizes = false; - option_values.sector_align = false; option_values.utf8_convert = true; option_values.cmdline_forced_outfilename = 0; option_values.output_prefix = 0; @@ -821,11 +798,6 @@ int parse_option(int short_option, const char *long_option, const char *option_a else if(0 == strcmp(long_option, "ignore-chunk-sizes")) { option_values.ignore_chunk_sizes = true; } - else if(0 == strcmp(long_option, "sector-align")) { - flac__utils_printf(stderr, 1, "WARNING: --sector-align is DEPRECATED and may not exist in future versions of flac.\n"); - flac__utils_printf(stderr, 1, " shntool provides similar functionality\n"); - option_values.sector_align = true; - } #if FLAC__HAS_OGG else if(0 == strcmp(long_option, "ogg")) { option_values.use_ogg = true; @@ -908,9 +880,6 @@ int parse_option(int short_option, const char *long_option, const char *option_a else if(0 == strcmp(long_option, "no-ignore-chunk-sizes")) { option_values.ignore_chunk_sizes = false; } - else if(0 == strcmp(long_option, "no-sector-align")) { - option_values.sector_align = false; - } else if(0 == strcmp(long_option, "no-utf8-convert")) { option_values.utf8_convert = false; } @@ -1243,7 +1212,7 @@ static void usage_header(void) printf("===============================================================================\n"); printf("flac - Command-line FLAC encoder/decoder version %s\n", FLAC__VERSION_STRING); printf("Copyright (C) 2000-2009 Josh Coalson\n"); - printf("Copyright (C) 2011-2022 Xiph.Org Foundation\n"); + printf("Copyright (C) 2011-2023 Xiph.Org Foundation\n"); printf("\n"); printf("This program is free software; you can redistribute it and/or\n"); printf("modify it under the terms of the GNU General Public License\n"); @@ -1337,7 +1306,6 @@ void show_help(void) printf(" -V, --verify Verify a correct encoding\n"); printf(" --lax Allow encoder to generate non-Subset files\n"); printf(" --ignore-chunk-sizes Ignore data chunk sizes in WAVE/AIFF files\n"); - printf(" --sector-align (DEPRECATED) Align multiple files on sector boundaries\n"); printf(" --replay-gain Calculate ReplayGain & store in FLAC tags\n"); printf(" --cuesheet=FILENAME Import cuesheet and store in CUESHEET block\n"); printf(" --picture=SPECIFICATION Import picture and store in PICTURE block\n"); @@ -1403,7 +1371,6 @@ void show_help(void) printf(" --no-residual-gnuplot\n"); printf(" --no-residual-text\n"); printf(" --no-ignore-chunk-sizes\n"); - printf(" --no-sector-align\n"); printf(" --no-seektable\n"); printf(" --no-silent\n"); printf(" --no-force\n"); @@ -1546,10 +1513,6 @@ void show_explain(void) printf(" --ignore-chunk-sizes Ignore data chunk sizes in WAVE/AIFF files;\n"); printf(" useful when piping data from programs which\n"); printf(" generate bogus data chunk sizes.\n"); - printf(" --sector-align Align encoding of multiple CD format WAVE files\n"); - printf(" on sector boundaries. This option is DEPRECATED\n"); - printf(" and may not exist in future versions of flac.\n"); - printf(" shntool offers similar functionality.\n"); printf(" --replay-gain Calculate ReplayGain values and store them as\n"); printf(" FLAC tags. Title gains/peaks will be computed\n"); printf(" for each file, and an album gain/peak will be\n"); @@ -1770,7 +1733,6 @@ void show_explain(void) printf(" --no-residual-gnuplot\n"); printf(" --no-residual-text\n"); printf(" --no-ignore-chunk-sizes\n"); - printf(" --no-sector-align\n"); printf(" --no-seektable\n"); printf(" --no-silent\n"); printf(" --no-force\n"); @@ -1803,13 +1765,11 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ return 1; } -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION if(0 == strcmp(infilename, "-")) { infilesize = (FLAC__off_t)(-1); encode_infile = grabbag__file_get_binary_stdin(); } else -#endif { infilesize = grabbag__file_get_filesize(infilename); if(0 == (encode_infile = flac_fopen(infilename, "rb"))) { @@ -1963,17 +1923,6 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ } } - if(option_values.sector_align && (input_format == FORMAT_FLAC || input_format == FORMAT_OGGFLAC)) { - flac__utils_printf(stderr, 1, "ERROR: can't use --sector-align when the input file is FLAC or Ogg FLAC\n"); - conditional_fclose(encode_infile); - return 1; - } - if(option_values.sector_align && input_format == FORMAT_RAW && infilesize < 0) { - flac__utils_printf(stderr, 1, "ERROR: can't use --sector-align when the input size is unknown\n"); - conditional_fclose(encode_infile); - return 1; - } - if(input_format == FORMAT_RAW) { if(option_values.format_is_big_endian < 0 || option_values.format_is_unsigned_samples < 0 || option_values.format_channels < 0 || option_values.format_bps < 0 || option_values.format_sample_rate < 0) { conditional_fclose(encode_infile); @@ -2035,11 +1984,8 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ encode_options.channel_map_none = option_values.channel_map_none; encode_options.is_first_file = is_first_file; encode_options.is_last_file = is_last_file; - encode_options.align_reservoir = align_reservoir; - encode_options.align_reservoir_samples = &align_reservoir_samples; encode_options.replay_gain = option_values.replay_gain; encode_options.ignore_chunk_sizes = option_values.ignore_chunk_sizes; - encode_options.sector_align = option_values.sector_align; encode_options.vorbis_comment = option_values.vorbis_comment; FLAC__ASSERT(sizeof(encode_options.pictures) >= sizeof(option_values.pictures)); memcpy(encode_options.pictures, option_values.pictures, sizeof(option_values.pictures)); @@ -2362,12 +2308,6 @@ int decode_file(const char *infilename) decode_options.channel_map_none = option_values.channel_map_none; decode_options.format = output_format; -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Can't fuzz from stdin */ - if(0 == strcmp(infilename, "-") || 0 == strcmp(outfilename, "-")) - return 1; -#endif - if(output_format == FORMAT_RAW) { decode_options.format_options.raw.is_big_endian = option_values.format_is_big_endian; decode_options.format_options.raw.is_unsigned_samples = option_values.format_is_unsigned_samples; diff --git a/src/flac/utils.c b/src/flac/utils.c index d236dc8e..446150d4 100644 --- a/src/flac/utils.c +++ b/src/flac/utils.c @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -56,8 +56,18 @@ static FLAC__bool local__parse_uint64_(const char *s, FLAC__uint64 *value) return false; while('\0' != (c = *s++)) - if(c >= '0' && c <= '9') - ret = ret * 10 + (c - '0'); + if(c >= '0' && c <= '9') { + if(ret > UINT64_MAX / 10) /* check for overflow */ + return false; + else if(ret == UINT64_MAX / 10) { + FLAC__uint64 tmp = ret; + ret = ret * 10 + (c - '0'); + if(ret < tmp) + return false; + } + else + ret = ret * 10 + (c - '0'); + } else return false; @@ -300,6 +310,8 @@ FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__Skip if(local__parse_uint64_(s, &val)) { spec->value_is_samples = true; + if(val > INT64_MAX) + return false; spec->value.samples = (FLAC__int64)val; if(is_negative) spec->value.samples = -(spec->value.samples); @@ -318,13 +330,17 @@ FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__Skip return true; } -void flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, uint32_t sample_rate) +FLAC__bool flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, uint32_t sample_rate) { FLAC__ASSERT(0 != spec); if(!spec->value_is_samples) { - spec->value.samples = (FLAC__int64)(spec->value.seconds * (double)sample_rate); + double samples = spec->value.seconds * (double)sample_rate; + if(samples >= (double)INT64_MAX || samples <= (double)INT64_MIN) + return false; + spec->value.samples = (FLAC__int64)(samples); spec->value_is_samples = true; } + return true; } FLAC__bool flac__utils_parse_cue_specification(const char *s, utils__CueSpecification *spec) diff --git a/src/flac/utils.h b/src/flac/utils.h index 2c1f1536..931b4a6e 100644 --- a/src/flac/utils.h +++ b/src/flac/utils.h @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -66,7 +66,7 @@ void stats_print_name(int level, const char *name); void stats_print_info(int level, const char *format, ...); FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__SkipUntilSpecification *spec); -void flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, uint32_t sample_rate); +FLAC__bool flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, uint32_t sample_rate); FLAC__bool flac__utils_parse_cue_specification(const char *s, utils__CueSpecification *spec); void flac__utils_canonicalize_cue_specification(const utils__CueSpecification *cue_spec, const FLAC__StreamMetadata_CueSheet *cuesheet, FLAC__uint64 total_samples, utils__SkipUntilSpecification *skip_spec, utils__SkipUntilSpecification *until_spec); diff --git a/src/flac/version.rc b/src/flac/version.rc new file mode 100644 index 00000000..00842b92 --- /dev/null +++ b/src/flac/version.rc @@ -0,0 +1,38 @@ +#include <winver.h> +#include "config.h" + +#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) +# ifdef GIT_COMMIT_TAG +# define VERSIONSTRING GIT_COMMIT_TAG +# else +# define VERSIONSTRING "git-" GIT_COMMIT_HASH +# endif +#else +# define VERSIONSTRING PACKAGE_VERSION +#endif + +#define xstr(s) str(s) +#define str(s) #s + +VS_VERSION_INFO VERSIONINFO +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "flac command line tool for Windows" + VALUE "ProductName", "Free Lossless Audio Codec" + VALUE "ProductVersion", VERSIONSTRING + VALUE "CompanyName", "Xiph.Org" + VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/src/flac/vorbiscomment.c b/src/flac/vorbiscomment.c index 434b5202..3941ec24 100644 --- a/src/flac/vorbiscomment.c +++ b/src/flac/vorbiscomment.c @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/flac/vorbiscomment.h b/src/flac/vorbiscomment.h index 6da6452d..a6dcb164 100644 --- a/src/flac/vorbiscomment.h +++ b/src/flac/vorbiscomment.h @@ -1,6 +1,6 @@ /* flac - Command-line FLAC encoder/decoder * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/libFLAC++/CMakeLists.txt b/src/libFLAC++/CMakeLists.txt index 81d466a4..3be43ba1 100644 --- a/src/libFLAC++/CMakeLists.txt +++ b/src/libFLAC++/CMakeLists.txt @@ -1,7 +1,8 @@ add_library(FLAC++ metadata.cpp stream_decoder.cpp - stream_encoder.cpp) + stream_encoder.cpp + version.rc) set_property(TARGET FLAC++ PROPERTY PROJECT_LABEL "libFLAC++") target_compile_definitions(FLAC++ PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLACPP_API_EXPORTS> @@ -15,7 +16,7 @@ target_include_directories(FLAC++ INTERFACE target_link_libraries(FLAC++ PUBLIC FLAC) if(BUILD_SHARED_LIBS) set_target_properties(FLAC++ PROPERTIES - VERSION 10.0.0 + VERSION 10.0.1 SOVERSION 10) if(NOT WIN32) set_target_properties(FLAC++ PROPERTIES CXX_VISIBILITY_PRESET hidden) diff --git a/src/libFLAC++/Makefile.am b/src/libFLAC++/Makefile.am index 77d2e6fd..0b2853b2 100644 --- a/src/libFLAC++/Makefile.am +++ b/src/libFLAC++/Makefile.am @@ -1,6 +1,6 @@ # libFLAC++ - Free Lossless Audio Codec library # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -41,17 +41,28 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include EXTRA_DIST = \ CMakeLists.txt \ flac++.pc.in \ - libFLAC++.m4 + libFLAC++.m4 \ + version.rc libFLAC___sources = \ metadata.cpp \ stream_decoder.cpp \ stream_encoder.cpp +if OS_IS_WINDOWS +if HAVE_WINDRES +libFLAC___la_DEPENDENCIES = version.o +windows_resource_link = -Wl,version.o +endif +endif + # see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention -libFLAC___la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 10:0:0 +libFLAC___la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 10:1:0 $(windows_resource_link) libFLAC___la_LIBADD = ../libFLAC/libFLAC.la libFLAC___la_SOURCES = $(libFLAC___sources) libFLAC___static_la_SOURCES = $(libFLAC___sources) libFLAC___static_la_LIBADD = ../libFLAC/libFLAC-static.la + +.rc.o: + $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/src/libFLAC++/metadata.cpp b/src/libFLAC++/metadata.cpp index c6dd9372..beab1109 100644 --- a/src/libFLAC++/metadata.cpp +++ b/src/libFLAC++/metadata.cpp @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC++/stream_decoder.cpp b/src/libFLAC++/stream_decoder.cpp index 7adb8107..6e351d94 100644 --- a/src/libFLAC++/stream_decoder.cpp +++ b/src/libFLAC++/stream_decoder.cpp @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC++/stream_encoder.cpp b/src/libFLAC++/stream_encoder.cpp index 43ec1afd..83771294 100644 --- a/src/libFLAC++/stream_encoder.cpp +++ b/src/libFLAC++/stream_encoder.cpp @@ -1,6 +1,6 @@ /* libFLAC++ - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC++/version.rc b/src/libFLAC++/version.rc new file mode 100644 index 00000000..14efba06 --- /dev/null +++ b/src/libFLAC++/version.rc @@ -0,0 +1,40 @@ +#include <winver.h> +#include "config.h" +#include "FLAC++/export.h" + +#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) +# ifdef GIT_COMMIT_TAG +# define VERSIONSTRING GIT_COMMIT_TAG +# else +# define VERSIONSTRING "git-" GIT_COMMIT_HASH +# endif +#else +# define VERSIONSTRING PACKAGE_VERSION +#endif + +#define xstr(s) str(s) +#define str(s) #s + +VS_VERSION_INFO VERSIONINFO +FILEVERSION FLACPP_API_VERSION_CURRENT,FLACPP_API_VERSION_REVISION,0,0 +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "libFLAC++ for Windows" + VALUE "ProductName", "Free Lossless Audio Codec" + VALUE "ProductVersion", VERSIONSTRING + VALUE "CompanyName", "Xiph.Org" + VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/src/libFLAC/CMakeLists.txt b/src/libFLAC/CMakeLists.txt index e6c20735..cf7368f6 100644 --- a/src/libFLAC/CMakeLists.txt +++ b/src/libFLAC/CMakeLists.txt @@ -63,6 +63,7 @@ add_library(FLAC stream_encoder_intrin_ssse3.c stream_encoder_intrin_avx2.c stream_encoder_framing.c + version.rc window.c $<$<BOOL:${WIN32}>:../../include/share/win_utf8_io.h> $<$<BOOL:${WIN32}>:../share/win_utf8_io/win_utf8_io.c> @@ -90,7 +91,7 @@ if(TARGET Ogg::ogg) endif() if(BUILD_SHARED_LIBS) set_target_properties(FLAC PROPERTIES - VERSION 12.0.0 + VERSION 12.1.0 SOVERSION 12) if(NOT WIN32) set_target_properties(FLAC PROPERTIES C_VISIBILITY_PRESET hidden) diff --git a/src/libFLAC/Makefile.am b/src/libFLAC/Makefile.am index 40e3308d..618939df 100644 --- a/src/libFLAC/Makefile.am +++ b/src/libFLAC/Makefile.am @@ -1,6 +1,6 @@ # libFLAC - Free Lossless Audio Codec library # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -56,12 +56,18 @@ EXTRA_DIST = \ CMakeLists.txt \ flac.pc.in \ libFLAC.m4 \ + version.rc \ + deduplication/bitreader_read_rice_signed_block.c \ deduplication/lpc_compute_autocorrelation_intrin.c \ deduplication/lpc_compute_autocorrelation_intrin_sse2.c \ deduplication/lpc_compute_autocorrelation_intrin_neon.c if OS_IS_WINDOWS windows_unicode_compat = ../share/win_utf8_io/win_utf8_io.c +if HAVE_WINDRES +libFLAC_la_DEPENDENCIES = version.o +windows_resource_link = -Wl,version.o +endif endif if FLaC__HAS_OGG @@ -73,7 +79,7 @@ extra_ogg_sources = \ endif # see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention -libFLAC_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 12:0:0 +libFLAC_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 13:0:1 $(windows_resource_link) libFLAC_sources = \ bitmath.c \ @@ -112,3 +118,6 @@ libFLAC_la_SOURCES = $(libFLAC_sources) # needed for test_libFLAC libFLAC_static_la_SOURCES = $(libFLAC_sources) + +.rc.o: + $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/src/libFLAC/bitmath.c b/src/libFLAC/bitmath.c index 7c73cc05..077486b6 100644 --- a/src/libFLAC/bitmath.c +++ b/src/libFLAC/bitmath.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/bitreader.c b/src/libFLAC/bitreader.c index 56f992e4..829b308e 100644 --- a/src/libFLAC/bitreader.c +++ b/src/libFLAC/bitreader.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,6 +39,7 @@ #include "private/bitmath.h" #include "private/bitreader.h" #include "private/crc.h" +#include "private/cpu.h" #include "private/macros.h" #include "FLAC/assert.h" #include "share/compat.h" @@ -163,11 +164,11 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br) brword preswap_backup; #endif - /* invalidate last seen framesync */ - br->last_seen_framesync = -1; - /* first shift the unconsumed buffer data toward the front as much as possible */ if(br->consumed_words > 0) { + /* invalidate last seen framesync */ + br->last_seen_framesync = -1; + crc16_update_block_(br); /* CRC consumed words */ start = br->consumed_words; @@ -831,149 +832,13 @@ FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint3 /* this is by far the most heavily used reader call. it ain't pretty but it's fast */ FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter) -{ - /* try and get br->consumed_words and br->consumed_bits into register; - * must remember to flush them back to *br before calling other - * bitreader functions that use them, and before returning */ - uint32_t cwords, words, lsbs, msbs, x, y, limit; - uint32_t ucbits; /* keep track of the number of unconsumed bits in word */ - brword b; - int *val, *end; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ - FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); - FLAC__ASSERT(parameter < 32); - /* the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it */ - - limit = UINT32_MAX >> parameter; /* Maximal msbs that can occur with residual bounded to int32_t */ - - val = vals; - end = vals + nvals; - - if(parameter == 0) { - while(val < end) { - /* read the unary MSBs and end bit */ - if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) - return false; - /* Checking limit here would be overzealous: coding UINT32_MAX - * with parameter == 0 would take 4GiB */ - *val++ = (int)(msbs >> 1) ^ -(int)(msbs & 1); - } - - return true; - } - - FLAC__ASSERT(parameter > 0); - - cwords = br->consumed_words; - words = br->words; - - /* if we've not consumed up to a partial tail word... */ - if(cwords >= words) { - x = 0; - goto process_tail; - } - - ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; - b = br->buffer[cwords] << br->consumed_bits; /* keep unconsumed bits aligned to left */ - - while(val < end) { - /* read the unary MSBs and end bit */ - x = y = COUNT_ZERO_MSBS2(b); - if(x == FLAC__BITS_PER_WORD) { - x = ucbits; - do { - /* didn't find stop bit yet, have to keep going... */ - cwords++; - if (cwords >= words) - goto incomplete_msbs; - b = br->buffer[cwords]; - y = COUNT_ZERO_MSBS2(b); - x += y; - } while(y == FLAC__BITS_PER_WORD); - } - b <<= y; - b <<= 1; /* account for stop bit */ - ucbits = (ucbits - x - 1) % FLAC__BITS_PER_WORD; - msbs = x; +#include "deduplication/bitreader_read_rice_signed_block.c" - if(x > limit) - return false; - - /* read the binary LSBs */ - x = (FLAC__uint32)(b >> (FLAC__BITS_PER_WORD - parameter)); /* parameter < 32, so we can cast to 32-bit uint32_t */ - if(parameter <= ucbits) { - ucbits -= parameter; - b <<= parameter; - } else { - /* there are still bits left to read, they will all be in the next word */ - cwords++; - if (cwords >= words) - goto incomplete_lsbs; - b = br->buffer[cwords]; - ucbits += FLAC__BITS_PER_WORD - parameter; - x |= (FLAC__uint32)(b >> ucbits); - b <<= FLAC__BITS_PER_WORD - ucbits; - } - lsbs = x; - - /* compose the value */ - x = (msbs << parameter) | lsbs; - *val++ = (int)(x >> 1) ^ -(int)(x & 1); - - continue; - - /* at this point we've eaten up all the whole words */ -process_tail: - do { - if(0) { -incomplete_msbs: - br->consumed_bits = 0; - br->consumed_words = cwords; - } - - /* read the unary MSBs and end bit */ - if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) - return false; - msbs += x; - x = ucbits = 0; - - if(0) { -incomplete_lsbs: - br->consumed_bits = 0; - br->consumed_words = cwords; - } - - /* read the binary LSBs */ - if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter - ucbits)) - return false; - lsbs = x | lsbs; - - /* compose the value */ - x = (msbs << parameter) | lsbs; - *val++ = (int)(x >> 1) ^ -(int)(x & 1); - x = 0; - - cwords = br->consumed_words; - words = br->words; - ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; - b = cwords < br->capacity ? br->buffer[cwords] << br->consumed_bits : 0; - } while(cwords >= words && val < end); - } - - if(ucbits == 0 && cwords < words) { - /* don't leave the head word with no unconsumed bits */ - cwords++; - ucbits = FLAC__BITS_PER_WORD; - } - - br->consumed_bits = FLAC__BITS_PER_WORD - ucbits; - br->consumed_words = cwords; - - return true; -} +#ifdef FLAC__BMI2_SUPPORTED +FLAC__SSE_TARGET("bmi2") +FLAC__bool FLAC__bitreader_read_rice_signed_block_bmi2(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter) +#include "deduplication/bitreader_read_rice_signed_block.c" +#endif #if 0 /* UNUSED */ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter) diff --git a/src/libFLAC/bitwriter.c b/src/libFLAC/bitwriter.c index 423faec8..1d7be808 100644 --- a/src/libFLAC/bitwriter.c +++ b/src/libFLAC/bitwriter.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/cpu.c b/src/libFLAC/cpu.c index 51f72ddf..d088e3c0 100644 --- a/src/libFLAC/cpu.c +++ b/src/libFLAC/cpu.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -76,6 +76,7 @@ static const uint32_t FLAC__CPUINFO_X86_CPUID_FMA = 0x00001000; /* these are flags in EBX of CPUID AX=00000007 */ static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX2 = 0x00000020; +static const uint32_t FLAC__CPUINFO_X86_CPUID_BMI2 = 0x00000100; static uint32_t cpu_xgetbv_x86(void) @@ -186,6 +187,7 @@ x86_cpu_info (FLAC__CPUInfo *info) info->x86.fma = (flags_ecx & FLAC__CPUINFO_X86_CPUID_FMA ) ? true : false; cpuinfo_x86(7, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx); info->x86.avx2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_AVX2 ) ? true : false; + info->x86.bmi2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_BMI2 ) ? true : false; } #if defined FLAC__CPU_IA32 @@ -206,6 +208,7 @@ x86_cpu_info (FLAC__CPUInfo *info) 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'); } /* diff --git a/src/libFLAC/crc.c b/src/libFLAC/crc.c index 4f47e986..9e488e9b 100644 --- a/src/libFLAC/crc.c +++ b/src/libFLAC/crc.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/deduplication/bitreader_read_rice_signed_block.c b/src/libFLAC/deduplication/bitreader_read_rice_signed_block.c new file mode 100644 index 00000000..75ed47f7 --- /dev/null +++ b/src/libFLAC/deduplication/bitreader_read_rice_signed_block.c @@ -0,0 +1,143 @@ +{ + /* try and get br->consumed_words and br->consumed_bits into register; + * must remember to flush them back to *br before calling other + * bitreader functions that use them, and before returning */ + uint32_t cwords, words, lsbs, msbs, x, y, limit; + uint32_t ucbits; /* keep track of the number of unconsumed bits in word */ + brword b; + int *val, *end; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ + FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); + FLAC__ASSERT(parameter < 32); + /* the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it */ + + limit = UINT32_MAX >> parameter; /* Maximal msbs that can occur with residual bounded to int32_t */ + + val = vals; + end = vals + nvals; + + if(parameter == 0) { + while(val < end) { + /* read the unary MSBs and end bit */ + if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; + /* Checking limit here would be overzealous: coding UINT32_MAX + * with parameter == 0 would take 4GiB */ + *val++ = (int)(msbs >> 1) ^ -(int)(msbs & 1); + } + + return true; + } + + FLAC__ASSERT(parameter > 0); + + cwords = br->consumed_words; + words = br->words; + + /* if we've not consumed up to a partial tail word... */ + if(cwords >= words) { + x = 0; + goto process_tail; + } + + ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; + b = br->buffer[cwords] << br->consumed_bits; /* keep unconsumed bits aligned to left */ + + while(val < end) { + /* read the unary MSBs and end bit */ + x = y = COUNT_ZERO_MSBS2(b); + if(x == FLAC__BITS_PER_WORD) { + x = ucbits; + do { + /* didn't find stop bit yet, have to keep going... */ + cwords++; + if (cwords >= words) + goto incomplete_msbs; + b = br->buffer[cwords]; + y = COUNT_ZERO_MSBS2(b); + x += y; + } while(y == FLAC__BITS_PER_WORD); + } + b <<= y; + b <<= 1; /* account for stop bit */ + ucbits = (ucbits - x - 1) % FLAC__BITS_PER_WORD; + msbs = x; + + if(x > limit) + return false; + + /* read the binary LSBs */ + x = (FLAC__uint32)(b >> (FLAC__BITS_PER_WORD - parameter)); /* parameter < 32, so we can cast to 32-bit uint32_t */ + if(parameter <= ucbits) { + ucbits -= parameter; + b <<= parameter; + } else { + /* there are still bits left to read, they will all be in the next word */ + cwords++; + if (cwords >= words) + goto incomplete_lsbs; + b = br->buffer[cwords]; + ucbits += FLAC__BITS_PER_WORD - parameter; + x |= (FLAC__uint32)(b >> ucbits); + b <<= FLAC__BITS_PER_WORD - ucbits; + } + lsbs = x; + + /* compose the value */ + x = (msbs << parameter) | lsbs; + *val++ = (int)(x >> 1) ^ -(int)(x & 1); + + continue; + + /* at this point we've eaten up all the whole words */ +process_tail: + do { + if(0) { +incomplete_msbs: + br->consumed_bits = 0; + br->consumed_words = cwords; + } + + /* read the unary MSBs and end bit */ + if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; + msbs += x; + x = ucbits = 0; + + if(0) { +incomplete_lsbs: + br->consumed_bits = 0; + br->consumed_words = cwords; + } + + /* read the binary LSBs */ + if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter - ucbits)) + return false; + lsbs = x | lsbs; + + /* compose the value */ + x = (msbs << parameter) | lsbs; + *val++ = (int)(x >> 1) ^ -(int)(x & 1); + x = 0; + + cwords = br->consumed_words; + words = br->words; + ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; + b = cwords < br->capacity ? br->buffer[cwords] << br->consumed_bits : 0; + } while(cwords >= words && val < end); + } + + if(ucbits == 0 && cwords < words) { + /* don't leave the head word with no unconsumed bits */ + cwords++; + ucbits = FLAC__BITS_PER_WORD; + } + + br->consumed_bits = FLAC__BITS_PER_WORD - ucbits; + br->consumed_words = cwords; + + return true; +} diff --git a/src/libFLAC/fixed.c b/src/libFLAC/fixed.c index ee883aac..04235ba0 100644 --- a/src/libFLAC/fixed.c +++ b/src/libFLAC/fixed.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/fixed_intrin_avx2.c b/src/libFLAC/fixed_intrin_avx2.c index 668e8d3e..85fc4a6d 100644 --- a/src/libFLAC/fixed_intrin_avx2.c +++ b/src/libFLAC/fixed_intrin_avx2.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -80,16 +80,16 @@ uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_avx2(const FLAC__int32 d prev_err2_scalar[i] = prev_err1_scalar[i] - (data[-2+i*(data_len_int/4)] - data[-3+i*(data_len_int/4)]); prev_err3_scalar[i] = prev_err2_scalar[i] - (data[-2+i*(data_len_int/4)] - 2*data[-3+i*(data_len_int/4)] + data[-4+i*(data_len_int/4)]); } - prev_err0 = _mm256_loadu_si256((const __m256i*)prev_err0_scalar); - prev_err1 = _mm256_loadu_si256((const __m256i*)prev_err1_scalar); - prev_err2 = _mm256_loadu_si256((const __m256i*)prev_err2_scalar); - prev_err3 = _mm256_loadu_si256((const __m256i*)prev_err3_scalar); + prev_err0 = _mm256_loadu_si256((const __m256i*)(void*)prev_err0_scalar); + prev_err1 = _mm256_loadu_si256((const __m256i*)(void*)prev_err1_scalar); + prev_err2 = _mm256_loadu_si256((const __m256i*)(void*)prev_err2_scalar); + prev_err3 = _mm256_loadu_si256((const __m256i*)(void*)prev_err3_scalar); for(i = 0; i < data_len_int / 4; i++){ data_scalar[0] = data[i]; data_scalar[1] = data[i+data_len/4]; data_scalar[2] = data[i+2*data_len/4]; data_scalar[3] = data[i+3*data_len/4]; - tempA = _mm256_loadu_si256((const __m256i*)data_scalar); + tempA = _mm256_loadu_si256((const __m256i*)(void*)data_scalar); /* Next three intrinsics calculate tempB as abs of tempA */ bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); tempB = _mm256_xor_si256(tempA, bitmask); @@ -124,15 +124,15 @@ uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_avx2(const FLAC__int32 d tempB = _mm256_sub_epi64(tempB, bitmask); total_err4 = _mm256_add_epi64(total_err4,tempB); } - _mm256_storeu_si256((__m256i*)data_scalar,total_err0); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err0); total_error_0 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err1); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err1); total_error_1 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err2); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err2); total_error_2 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err3); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err3); total_error_3 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err4); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err4); total_error_4 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; /* Ignore the remainder, we're ignore the first few samples too */ @@ -236,22 +236,22 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLA prev_err2_scalar[i] = prev_err1_scalar[i] - ((FLAC__int64)(data[-2+i*(data_len_int/4)]) - data[-3+i*(data_len_int/4)]); prev_err3_scalar[i] = prev_err2_scalar[i] - ((FLAC__int64)(data[-2+i*(data_len_int/4)]) - 2*(FLAC__int64)(data[-3+i*(data_len_int/4)]) + data[-4+i*(data_len_int/4)]); } - prev_err0 = _mm256_loadu_si256((const __m256i*)prev_err0_scalar); - prev_err1 = _mm256_loadu_si256((const __m256i*)prev_err1_scalar); - prev_err2 = _mm256_loadu_si256((const __m256i*)prev_err2_scalar); - prev_err3 = _mm256_loadu_si256((const __m256i*)prev_err3_scalar); + prev_err0 = _mm256_loadu_si256((const __m256i*)(void*)prev_err0_scalar); + prev_err1 = _mm256_loadu_si256((const __m256i*)(void*)prev_err1_scalar); + prev_err2 = _mm256_loadu_si256((const __m256i*)(void*)prev_err2_scalar); + prev_err3 = _mm256_loadu_si256((const __m256i*)(void*)prev_err3_scalar); for(i = 0; i < data_len_int / 4; i++){ data_scalar[0] = data[i]; data_scalar[1] = data[i+data_len/4]; data_scalar[2] = data[i+2*data_len/4]; data_scalar[3] = data[i+3*data_len/4]; - tempA = _mm256_loadu_si256((const __m256i*)data_scalar); + tempA = _mm256_loadu_si256((const __m256i*)(void*)data_scalar); /* Next three intrinsics calculate tempB as abs of tempA */ bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); tempB = _mm256_xor_si256(tempA, bitmask); tempB = _mm256_sub_epi64(tempB, bitmask); total_err0 = _mm256_add_epi64(total_err0,tempB); - shadow_err0 = _mm256_xor_si256(shadow_err0,tempB); + shadow_err0 = _mm256_or_si256(shadow_err0,tempB); tempB = _mm256_sub_epi64(tempA,prev_err0); prev_err0 = tempA; /* Next three intrinsics calculate tempA as abs of tempB */ @@ -259,7 +259,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLA tempA = _mm256_xor_si256(tempB, bitmask); tempA = _mm256_sub_epi64(tempA, bitmask); total_err1 = _mm256_add_epi64(total_err1,tempA); - shadow_err1 = _mm256_xor_si256(shadow_err1,tempA); + shadow_err1 = _mm256_or_si256(shadow_err1,tempA); tempA = _mm256_sub_epi64(tempB,prev_err1); prev_err1 = tempB; /* Next three intrinsics calculate tempB as abs of tempA */ @@ -267,7 +267,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLA tempB = _mm256_xor_si256(tempA, bitmask); tempB = _mm256_sub_epi64(tempB, bitmask); total_err2 = _mm256_add_epi64(total_err2,tempB); - shadow_err2 = _mm256_xor_si256(shadow_err2,tempB); + shadow_err2 = _mm256_or_si256(shadow_err2,tempB); tempB = _mm256_sub_epi64(tempA,prev_err2); prev_err2 = tempA; /* Next three intrinsics calculate tempA as abs of tempB */ @@ -275,7 +275,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLA tempA = _mm256_xor_si256(tempB, bitmask); tempA = _mm256_sub_epi64(tempA, bitmask); total_err3 = _mm256_add_epi64(total_err3,tempA); - shadow_err3 = _mm256_xor_si256(shadow_err3,tempA); + shadow_err3 = _mm256_or_si256(shadow_err3,tempA); tempA = _mm256_sub_epi64(tempB,prev_err3); prev_err3 = tempB; /* Next three intrinsics calculate tempB as abs of tempA */ @@ -283,28 +283,28 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLA tempB = _mm256_xor_si256(tempA, bitmask); tempB = _mm256_sub_epi64(tempB, bitmask); total_err4 = _mm256_add_epi64(total_err4,tempB); - shadow_err4 = _mm256_xor_si256(shadow_err4,tempB); + shadow_err4 = _mm256_or_si256(shadow_err4,tempB); } - _mm256_storeu_si256((__m256i*)data_scalar,total_err0); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err0); total_error_0 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err1); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err1); total_error_1 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err2); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err2); total_error_2 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err3); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err3); total_error_3 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,total_err4); + _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err4); total_error_4 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,shadow_err0); - shadow_error_0 += data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,shadow_err1); - shadow_error_1 += data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,shadow_err2); - shadow_error_2 += data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,shadow_err3); - shadow_error_3 += data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)data_scalar,shadow_err4); - shadow_error_4 += data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; + _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err0); + shadow_error_0 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; + _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err1); + shadow_error_1 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; + _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err2); + shadow_error_2 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; + _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err3); + shadow_error_3 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; + _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err4); + shadow_error_4 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; /* Take care of remaining sample */ for(i = (data_len/4)*4; i < data_len_int; i++) { diff --git a/src/libFLAC/fixed_intrin_sse2.c b/src/libFLAC/fixed_intrin_sse2.c index 89a9d72d..b92c13c1 100644 --- a/src/libFLAC/fixed_intrin_sse2.c +++ b/src/libFLAC/fixed_intrin_sse2.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/fixed_intrin_sse42.c b/src/libFLAC/fixed_intrin_sse42.c index 6be407e2..0556eaad 100644 --- a/src/libFLAC/fixed_intrin_sse42.c +++ b/src/libFLAC/fixed_intrin_sse42.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -130,7 +130,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FL tempB = _mm_xor_si128(tempA, bitmask); tempB = _mm_sub_epi64(tempB, bitmask); total_err0 = _mm_add_epi64(total_err0,tempB); - shadow_err0 = _mm_xor_si128(shadow_err0,tempB); + shadow_err0 = _mm_or_si128(shadow_err0,tempB); tempB = _mm_sub_epi64(tempA,prev_err0); prev_err0 = tempA; /* Next three intrinsics calculate tempA as abs of tempB */ @@ -138,7 +138,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FL tempA = _mm_xor_si128(tempB, bitmask); tempA = _mm_sub_epi64(tempA, bitmask); total_err1 = _mm_add_epi64(total_err1,tempA); - shadow_err1 = _mm_xor_si128(shadow_err1,tempA); + shadow_err1 = _mm_or_si128(shadow_err1,tempA); tempA = _mm_sub_epi64(tempB,prev_err1); prev_err1 = tempB; /* Next three intrinsics calculate tempB as abs of tempA */ @@ -146,7 +146,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FL tempB = _mm_xor_si128(tempA, bitmask); tempB = _mm_sub_epi64(tempB, bitmask); total_err2 = _mm_add_epi64(total_err2,tempB); - shadow_err2 = _mm_xor_si128(shadow_err2,tempB); + shadow_err2 = _mm_or_si128(shadow_err2,tempB); tempB = _mm_sub_epi64(tempA,prev_err2); prev_err2 = tempA; /* Next three intrinsics calculate tempA as abs of tempB */ @@ -154,7 +154,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FL tempA = _mm_xor_si128(tempB, bitmask); tempA = _mm_sub_epi64(tempA, bitmask); total_err3 = _mm_add_epi64(total_err3,tempA); - shadow_err3 = _mm_xor_si128(shadow_err3,tempA); + shadow_err3 = _mm_or_si128(shadow_err3,tempA); tempA = _mm_sub_epi64(tempB,prev_err3); prev_err3 = tempB; /* Next three intrinsics calculate tempB as abs of tempA */ @@ -162,7 +162,7 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FL tempB = _mm_xor_si128(tempA, bitmask); tempB = _mm_sub_epi64(tempB, bitmask); total_err4 = _mm_add_epi64(total_err4,tempB); - shadow_err4 = _mm_xor_si128(shadow_err4,tempB); + shadow_err4 = _mm_or_si128(shadow_err4,tempB); } _mm_storeu_si128((__m128i*)data_scalar,total_err0); total_error_0 += data_scalar[0] + data_scalar[1]; @@ -175,15 +175,15 @@ uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FL _mm_storeu_si128((__m128i*)data_scalar,total_err4); total_error_4 += data_scalar[0] + data_scalar[1]; _mm_storeu_si128((__m128i*)data_scalar,shadow_err0); - shadow_error_0 += data_scalar[0] | data_scalar[1]; + shadow_error_0 |= data_scalar[0] | data_scalar[1]; _mm_storeu_si128((__m128i*)data_scalar,shadow_err1); - shadow_error_1 += data_scalar[0] | data_scalar[1]; + shadow_error_1 |= data_scalar[0] | data_scalar[1]; _mm_storeu_si128((__m128i*)data_scalar,shadow_err2); - shadow_error_2 += data_scalar[0] | data_scalar[1]; + shadow_error_2 |= data_scalar[0] | data_scalar[1]; _mm_storeu_si128((__m128i*)data_scalar,shadow_err3); - shadow_error_3 += data_scalar[0] | data_scalar[1]; + shadow_error_3 |= data_scalar[0] | data_scalar[1]; _mm_storeu_si128((__m128i*)data_scalar,shadow_err4); - shadow_error_4 += data_scalar[0] | data_scalar[1]; + shadow_error_4 |= data_scalar[0] | data_scalar[1]; /* Take care of remaining sample */ if(data_len_int % 2 > 0) { diff --git a/src/libFLAC/fixed_intrin_ssse3.c b/src/libFLAC/fixed_intrin_ssse3.c index 1f0e63dc..551693bf 100644 --- a/src/libFLAC/fixed_intrin_ssse3.c +++ b/src/libFLAC/fixed_intrin_ssse3.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/float.c b/src/libFLAC/float.c index 1e258275..a06ad285 100644 --- a/src/libFLAC/float.c +++ b/src/libFLAC/float.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/format.c b/src/libFLAC/format.c index 31ffdc2f..8bbffbef 100644 --- a/src/libFLAC/format.c +++ b/src/libFLAC/format.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -55,7 +55,7 @@ FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC git-" GIT_COMMIT_H #else /* PACKAGE_VERSION should come from configure */ FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION; -FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20221022"; +FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20230623"; #endif FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' }; @@ -208,7 +208,7 @@ FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = { FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate) { - if(sample_rate == 0 || sample_rate > FLAC__MAX_SAMPLE_RATE) { + if(sample_rate > FLAC__MAX_SAMPLE_RATE) { return false; } else @@ -247,6 +247,9 @@ FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_S FLAC__ASSERT(0 != seek_table); + if((FLAC__uint64)(seek_table->num_points) * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) + return false; + for(i = 0; i < seek_table->num_points; i++) { if(got_prev) { if( diff --git a/src/libFLAC/include/Makefile.am b/src/libFLAC/include/Makefile.am index 007a929b..8484d128 100644 --- a/src/libFLAC/include/Makefile.am +++ b/src/libFLAC/include/Makefile.am @@ -1,6 +1,6 @@ # libFLAC - Free Lossless Audio Codec library # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/Makefile.am b/src/libFLAC/include/private/Makefile.am index 8e6755ea..3e63d310 100644 --- a/src/libFLAC/include/private/Makefile.am +++ b/src/libFLAC/include/private/Makefile.am @@ -1,6 +1,6 @@ # libFLAC - Free Lossless Audio Codec library # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/all.h b/src/libFLAC/include/private/all.h index c64f9acd..10b69495 100644 --- a/src/libFLAC/include/private/all.h +++ b/src/libFLAC/include/private/all.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/bitmath.h b/src/libFLAC/include/private/bitmath.h index b1dc4e86..12e062f8 100644 --- a/src/libFLAC/include/private/bitmath.h +++ b/src/libFLAC/include/private/bitmath.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/bitreader.h b/src/libFLAC/include/private/bitreader.h index 2943a955..c36c9266 100644 --- a/src/libFLAC/include/private/bitreader.h +++ b/src/libFLAC/include/private/bitreader.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -88,6 +88,10 @@ FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, F FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val); FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter); FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); +#ifdef FLAC__BMI2_SUPPORTED +FLAC__bool FLAC__bitreader_read_rice_signed_block_bmi2(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); +#endif + #if 0 /* UNUSED */ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter); FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter); diff --git a/src/libFLAC/include/private/bitwriter.h b/src/libFLAC/include/private/bitwriter.h index 6029790b..39bcf254 100644 --- a/src/libFLAC/include/private/bitwriter.h +++ b/src/libFLAC/include/private/bitwriter.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/cpu.h b/src/libFLAC/include/private/cpu.h index 1e444c09..8843c74b 100644 --- a/src/libFLAC/include/private/cpu.h +++ b/src/libFLAC/include/private/cpu.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -90,6 +90,7 @@ #define FLAC__AVX_SUPPORTED 1 #define FLAC__AVX2_SUPPORTED 1 #define FLAC__FMA_SUPPORTED 1 + #define FLAC__BMI2_SUPPORTED 1 #endif #elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */ #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) @@ -102,6 +103,7 @@ #define FLAC__AVX_SUPPORTED 1 #define FLAC__AVX2_SUPPORTED 1 #define FLAC__FMA_SUPPORTED 1 + #define FLAC__BMI2_SUPPORTED 1 #endif #elif defined _MSC_VER #define FLAC__SSE_TARGET(x) @@ -178,6 +180,7 @@ typedef struct { FLAC__bool avx; FLAC__bool avx2; FLAC__bool fma; + FLAC__bool bmi2; } FLAC__CPUInfo_x86; typedef struct { diff --git a/src/libFLAC/include/private/crc.h b/src/libFLAC/include/private/crc.h index 8c8fcd4c..fe445020 100644 --- a/src/libFLAC/include/private/crc.h +++ b/src/libFLAC/include/private/crc.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/fixed.h b/src/libFLAC/include/private/fixed.h index 4ee1fd22..c4efecd5 100644 --- a/src/libFLAC/include/private/fixed.h +++ b/src/libFLAC/include/private/fixed.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/float.h b/src/libFLAC/include/private/float.h index 096db7d2..bec26345 100644 --- a/src/libFLAC/include/private/float.h +++ b/src/libFLAC/include/private/float.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/format.h b/src/libFLAC/include/private/format.h index d5c6aa49..7630f6fa 100644 --- a/src/libFLAC/include/private/format.h +++ b/src/libFLAC/include/private/format.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/lpc.h b/src/libFLAC/include/private/lpc.h index eed7b666..766f0560 100644 --- a/src/libFLAC/include/private/lpc.h +++ b/src/libFLAC/include/private/lpc.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/macros.h b/src/libFLAC/include/private/macros.h index ee0d997b..8204ed54 100644 --- a/src/libFLAC/include/private/macros.h +++ b/src/libFLAC/include/private/macros.h @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2022 Xiph.Org Foundation + * Copyright (C) 2012-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/memory.h b/src/libFLAC/include/private/memory.h index b55c9624..4221bcfd 100644 --- a/src/libFLAC/include/private/memory.h +++ b/src/libFLAC/include/private/memory.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/metadata.h b/src/libFLAC/include/private/metadata.h index 409b62cd..d3ceb53f 100644 --- a/src/libFLAC/include/private/metadata.h +++ b/src/libFLAC/include/private/metadata.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/ogg_decoder_aspect.h b/src/libFLAC/include/private/ogg_decoder_aspect.h index 2be979cc..c9236410 100644 --- a/src/libFLAC/include/private/ogg_decoder_aspect.h +++ b/src/libFLAC/include/private/ogg_decoder_aspect.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/ogg_encoder_aspect.h b/src/libFLAC/include/private/ogg_encoder_aspect.h index 35a1ddf5..0e9bb4bc 100644 --- a/src/libFLAC/include/private/ogg_encoder_aspect.h +++ b/src/libFLAC/include/private/ogg_encoder_aspect.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/ogg_helper.h b/src/libFLAC/include/private/ogg_helper.h index 3e15acca..67685787 100644 --- a/src/libFLAC/include/private/ogg_helper.h +++ b/src/libFLAC/include/private/ogg_helper.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/ogg_mapping.h b/src/libFLAC/include/private/ogg_mapping.h index 224f7dc2..1a213a4f 100644 --- a/src/libFLAC/include/private/ogg_mapping.h +++ b/src/libFLAC/include/private/ogg_mapping.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/stream_encoder.h b/src/libFLAC/include/private/stream_encoder.h index 1d22937e..0a1b672a 100644 --- a/src/libFLAC/include/private/stream_encoder.h +++ b/src/libFLAC/include/private/stream_encoder.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/private/stream_encoder_framing.h b/src/libFLAC/include/private/stream_encoder_framing.h index 2799c698..705965ae 100644 --- a/src/libFLAC/include/private/stream_encoder_framing.h +++ b/src/libFLAC/include/private/stream_encoder_framing.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,7 +36,7 @@ #include "FLAC/format.h" #include "bitwriter.h" -FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw); +FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw, FLAC__bool update_vendor_string); FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw); FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); diff --git a/src/libFLAC/include/private/window.h b/src/libFLAC/include/private/window.h index 4aaaaea6..87a3fdf1 100644 --- a/src/libFLAC/include/private/window.h +++ b/src/libFLAC/include/private/window.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/protected/Makefile.am b/src/libFLAC/include/protected/Makefile.am index 30d03665..97e85a84 100644 --- a/src/libFLAC/include/protected/Makefile.am +++ b/src/libFLAC/include/protected/Makefile.am @@ -1,6 +1,6 @@ # libFLAC - Free Lossless Audio Codec library # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/protected/all.h b/src/libFLAC/include/protected/all.h index ad302308..9f6de97a 100644 --- a/src/libFLAC/include/protected/all.h +++ b/src/libFLAC/include/protected/all.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/protected/stream_decoder.h b/src/libFLAC/include/protected/stream_decoder.h index f1c5d0eb..4a9c7686 100644 --- a/src/libFLAC/include/protected/stream_decoder.h +++ b/src/libFLAC/include/protected/stream_decoder.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/include/protected/stream_encoder.h b/src/libFLAC/include/protected/stream_encoder.h index 3e045583..863e43b3 100644 --- a/src/libFLAC/include/protected/stream_encoder.h +++ b/src/libFLAC/include/protected/stream_encoder.h @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/lpc.c b/src/libFLAC/lpc.c index 7c16cdf6..bcb8673c 100644 --- a/src/libFLAC/lpc.c +++ b/src/libFLAC/lpc.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/lpc_intrin_avx2.c b/src/libFLAC/lpc_intrin_avx2.c index 48bd7a85..7f1c03ed 100644 --- a/src/libFLAC/lpc_intrin_avx2.c +++ b/src/libFLAC/lpc_intrin_avx2.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/lpc_intrin_fma.c b/src/libFLAC/lpc_intrin_fma.c index 396ff302..c0740a88 100644 --- a/src/libFLAC/lpc_intrin_fma.c +++ b/src/libFLAC/lpc_intrin_fma.c @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2022 Xiph.Org Foundation + * Copyright (C) 2022-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/lpc_intrin_neon.c b/src/libFLAC/lpc_intrin_neon.c index 0ba45016..b9945d58 100644 --- a/src/libFLAC/lpc_intrin_neon.c +++ b/src/libFLAC/lpc_intrin_neon.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/lpc_intrin_sse2.c b/src/libFLAC/lpc_intrin_sse2.c index f1ad018d..d16a085f 100644 --- a/src/libFLAC/lpc_intrin_sse2.c +++ b/src/libFLAC/lpc_intrin_sse2.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/lpc_intrin_sse41.c b/src/libFLAC/lpc_intrin_sse41.c index 136f71ca..756c5dd8 100644 --- a/src/libFLAC/lpc_intrin_sse41.c +++ b/src/libFLAC/lpc_intrin_sse41.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/memory.c b/src/libFLAC/memory.c index 2dad6e7d..ad5371ee 100644 --- a/src/libFLAC/memory.c +++ b/src/libFLAC/memory.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c index ad8be8e1..20e926be 100644 --- a/src/libFLAC/metadata_iterators.c +++ b/src/libFLAC/metadata_iterators.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1142,6 +1142,12 @@ static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLA static FLAC__off_t chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) { FLAC__off_t current_length = chain_calculate_length_(chain); + FLAC__Metadata_Node * i; + + /* Check all is_last settings on the blocks */ + for(i = chain->head; i->next != NULL; i = i->next) + i->data->is_last = 0; + chain->tail->data->is_last = 1; if(use_padding) { /* if the metadata shrank and the last block is padding, we just extend the last padding block */ @@ -2337,7 +2343,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entr if(max_length < entry->length) { entry->length = 0; return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - } else max_length -= entry->length; + } if(0 != entry->entry) free(entry->entry); @@ -2407,7 +2413,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_( return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; } - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; + return status; } FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track) @@ -2512,7 +2518,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__ block->num_tracks = unpack_uint32_(buffer, len); if(block->num_tracks == 0) { - block->tracks = 0; + return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; } else if(0 == (block->tracks = calloc(block->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)))) return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c index b013cfa0..73e76076 100644 --- a/src/libFLAC/metadata_object.c +++ b/src/libFLAC/metadata_object.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,8 +39,10 @@ #include "private/metadata.h" #include "private/memory.h" +#include "private/stream_encoder_framing.h" #include "FLAC/assert.h" +#include "FLAC/stream_decoder.h" #include "share/alloc.h" #include "share/compat.h" @@ -929,6 +931,9 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMe FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); + if((FLAC__uint64)(new_num_points) * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) + return false; + if (object->data.seek_table.points == 0) { FLAC__ASSERT(object->data.seek_table.num_points == 0); if (new_num_points == 0) @@ -1852,3 +1857,162 @@ FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMet return FLAC__format_picture_is_legal(&object->data.picture, violation); } + +FLAC_API FLAC__byte * FLAC__metadata_object_get_raw(const FLAC__StreamMetadata *object) +{ + FLAC__BitWriter *bw; + const FLAC__byte * buffer; + FLAC__byte * output; + size_t bytes; + + FLAC__ASSERT(object != NULL); + + if((bw = FLAC__bitwriter_new()) == NULL) + return 0; + if(!FLAC__bitwriter_init(bw)) { + FLAC__bitwriter_delete(bw); + return 0; + } + if(!FLAC__add_metadata_block(object, bw, false)) { + FLAC__bitwriter_delete(bw); + return 0; + } + + if(!FLAC__bitwriter_get_buffer(bw, &buffer, &bytes)) { + FLAC__bitwriter_delete(bw); + return 0; + } + + /* Extra check whether length of bitwriter agrees with length of metadata block */ + if(bytes != (object->length+FLAC__STREAM_METADATA_HEADER_LENGTH)) { + FLAC__bitwriter_delete(bw); + return 0; + } + + output = safe_malloc_(bytes); + if(output == 0) { + FLAC__bitwriter_delete(bw); + return 0; + } + + memcpy(output,buffer,bytes); + FLAC__bitwriter_delete(bw); + return output; +} + +/* The following callbacks are for FLAC__metadata_object_set_raw */ + +static FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte *buffer, size_t *bytes, void *client_data); +static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); +static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); +static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); + +typedef struct { + FLAC__StreamMetadata *object; + FLAC__bool got_error; + FLAC__byte *buffer; + FLAC__int32 length; + FLAC__int32 tell; +} set_raw_client_data; + +FLAC_API FLAC__StreamMetadata * FLAC__metadata_object_set_raw(FLAC__byte *buffer, FLAC__uint32 length) +{ + set_raw_client_data cd; + FLAC__StreamDecoder * decoder; + + cd.buffer = buffer; + cd.length = length; + cd.got_error = false; + cd.object = 0; + cd.tell = -4; + + decoder = FLAC__stream_decoder_new(); + + if(0 == decoder) + return 0; + + FLAC__stream_decoder_set_md5_checking(decoder, false); + FLAC__stream_decoder_set_metadata_respond_all(decoder); + + if(FLAC__stream_decoder_init_stream(decoder, read_callback_, NULL, NULL, NULL, NULL, write_callback_, metadata_callback_, error_callback_, &cd) != FLAC__STREAM_DECODER_INIT_STATUS_OK || cd.got_error) { + (void)FLAC__stream_decoder_finish(decoder); + FLAC__stream_decoder_delete(decoder); + return 0; + } + + if((!FLAC__stream_decoder_process_until_end_of_metadata(decoder) && FLAC__stream_decoder_get_state(decoder) != FLAC__STREAM_DECODER_END_OF_STREAM) || cd.got_error) { + (void)FLAC__stream_decoder_finish(decoder); + FLAC__stream_decoder_delete(decoder); + if(0 != cd.object) + FLAC__metadata_object_delete(cd.object); + return 0; + } + + (void)FLAC__stream_decoder_finish(decoder); + FLAC__stream_decoder_delete(decoder); + + return cd.object; + +} + +FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte *buffer, size_t *bytes, void *client_data) +{ + set_raw_client_data *cd = (set_raw_client_data *)client_data; + (void)decoder; + + if(cd->tell == -4) { + if(*bytes < 4) + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + buffer[0] = 'f'; + buffer[1] = 'L'; + buffer[2] = 'a'; + buffer[3] = 'C'; + *bytes = 4; + cd->tell = 0; + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + } + else if(cd->tell < 0) + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + else if(cd->tell == cd->length) { + *bytes = 0; + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + } + else { + if((FLAC__int32)(*bytes) > (cd->length - cd->tell)) + *bytes = cd->length - cd->tell; + memcpy(buffer, cd->buffer+cd->tell, *bytes); + cd->tell += *bytes; + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + } +} + +FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) +{ + (void)decoder, (void)frame, (void)buffer, (void)client_data; + + return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; +} + +void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) +{ + set_raw_client_data *cd = (set_raw_client_data *)client_data; + (void)decoder; + + /* + * we assume we only get here when the one metadata block we were + * looking for was passed to us + */ + if(!cd->got_error && 0 == cd->object) { + if(0 == (cd->object = FLAC__metadata_object_clone(metadata))) + cd->got_error = true; + } +} + +void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) +{ + set_raw_client_data *cd = (set_raw_client_data *)client_data; + (void)decoder; + + if(status != FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC) + cd->got_error = true; +} diff --git a/src/libFLAC/ogg_decoder_aspect.c b/src/libFLAC/ogg_decoder_aspect.c index e331db30..58a29346 100644 --- a/src/libFLAC/ogg_decoder_aspect.c +++ b/src/libFLAC/ogg_decoder_aspect.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/ogg_encoder_aspect.c b/src/libFLAC/ogg_encoder_aspect.c index ae055c84..a88713b1 100644 --- a/src/libFLAC/ogg_encoder_aspect.c +++ b/src/libFLAC/ogg_encoder_aspect.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/ogg_helper.c b/src/libFLAC/ogg_helper.c index acd945ac..a4be34d2 100644 --- a/src/libFLAC/ogg_helper.c +++ b/src/libFLAC/ogg_helper.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/ogg_mapping.c b/src/libFLAC/ogg_mapping.c index 1bd8c3cb..756c7165 100644 --- a/src/libFLAC/ogg_mapping.c +++ b/src/libFLAC/ogg_mapping.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index fcd55881..98825839 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -45,6 +45,7 @@ #include "protected/stream_decoder.h" #include "private/bitreader.h" #include "private/bitmath.h" +#include "private/cpu.h" #include "private/crc.h" #include "private/fixed.h" #include "private/format.h" @@ -147,6 +148,7 @@ typedef struct FLAC__StreamDecoderPrivate { size_t metadata_filter_ids_count, metadata_filter_ids_capacity; /* units for both are IDs, not bytes */ FLAC__Frame frame; FLAC__bool cached; /* true if there is a byte in lookahead */ + FLAC__CPUInfo cpuinfo; FLAC__byte header_warmup[2]; /* contains the sync code and reserved bits */ FLAC__byte lookahead; /* temp storage when we need to look ahead one byte in the stream */ /* unaligned (original) pointers to allocated data */ @@ -164,6 +166,7 @@ typedef struct FLAC__StreamDecoderPrivate { FLAC__uint64 target_sample; uint32_t unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */ FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */ + FLAC__bool (*local_bitreader_read_rice_signed_block)(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); } FLAC__StreamDecoderPrivate; /*********************************************************************** @@ -369,6 +372,15 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_( return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; #endif + FLAC__cpu_info(&decoder->private_->cpuinfo); + decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block; + +#ifdef FLAC__BMI2_SUPPORTED + if (decoder->private_->cpuinfo.x86.bmi2) { + decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block_bmi2; + } +#endif + /* from here on, errors are fatal */ if(!FLAC__bitreader_init(decoder->private_->input, read_callback_, decoder)) { @@ -1403,12 +1415,14 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) /* just in case we already have a seek table, and reading the next one fails: */ decoder->private_->has_seek_table = false; - if(!read_metadata_seektable_(decoder, is_last, length)) - return false; + if(length > 0) { + if(!read_metadata_seektable_(decoder, is_last, length)) + return false; - decoder->private_->has_seek_table = true; - if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTABLE] && decoder->private_->metadata_callback) - decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->client_data); + decoder->private_->has_seek_table = true; + if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTABLE] && decoder->private_->metadata_callback) + decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->client_data); + } } else { FLAC__bool skip_it = !decoder->private_->metadata_filter[type]; @@ -1689,24 +1703,20 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.length)) return false; /* read_callback_ sets the state for us */ - if (obj->vendor_string.length > 0) { - if (length < obj->vendor_string.length) { - obj->vendor_string.length = 0; - obj->vendor_string.entry = 0; - goto skip; - } - else - length -= obj->vendor_string.length; - if (0 == (obj->vendor_string.entry = safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.entry, obj->vendor_string.length)) - return false; /* read_callback_ sets the state for us */ - obj->vendor_string.entry[obj->vendor_string.length] = '\0'; + if (length < obj->vendor_string.length) { + obj->vendor_string.length = 0; + obj->vendor_string.entry = 0; + goto skip; } else - obj->vendor_string.entry = 0; + length -= obj->vendor_string.length; + if (0 == (obj->vendor_string.entry = safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.entry, obj->vendor_string.length)) + return false; /* read_callback_ sets the state for us */ + obj->vendor_string.entry[obj->vendor_string.length] = '\0'; /* read num comments */ FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN == 32); @@ -1741,31 +1751,27 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre obj->num_comments = i; return false; /* read_callback_ sets the state for us */ } - if (obj->comments[i].length > 0) { - if (length < obj->comments[i].length) { - obj->num_comments = i; - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - else - length -= obj->comments[i].length; - if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - obj->num_comments = i; - return false; - } - memset (obj->comments[i].entry, 0, obj->comments[i].length) ; - if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) { - /* Current i-th entry is bad, so we delete it. */ - free (obj->comments[i].entry) ; - obj->comments[i].entry = NULL ; - obj->num_comments = i; - goto skip; - } - obj->comments[i].entry[obj->comments[i].length] = '\0'; + if (length < obj->comments[i].length) { + obj->num_comments = i; + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; } else - obj->comments[i].entry = 0; + length -= obj->comments[i].length; + if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) { + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + obj->num_comments = i; + return false; + } + memset (obj->comments[i].entry, 0, obj->comments[i].length) ; + if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) { + /* Current i-th entry is bad, so we delete it. */ + free (obj->comments[i].entry) ; + obj->comments[i].entry = NULL ; + obj->num_comments = i; + goto skip; + } + obj->comments[i].entry[obj->comments[i].length] = '\0'; } } } @@ -1867,6 +1873,10 @@ FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMet } } } + else { /* obj->num_tracks == 0 */ + FLAC__bitreader_limit_invalidate(decoder->private_->input); + return false; + } return true; } @@ -2087,6 +2097,8 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL else return false; } + if(decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME) + break; } if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) @@ -2149,10 +2161,20 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL decoder->private_->last_frame.header.channels == decoder->private_->frame.header.channels && decoder->private_->last_frame.header.bits_per_sample == decoder->private_->frame.header.bits_per_sample && decoder->private_->last_frame.header.blocksize >= 16) { - FLAC__Frame empty_frame; + FLAC__int32 * empty_buffer[FLAC__MAX_CHANNELS] = {NULL}; empty_frame.header = decoder->private_->last_frame.header; empty_frame.footer.crc = 0; + for(i = 0; i < empty_frame.header.channels; i++) { + empty_buffer[i] = safe_calloc_(empty_frame.header.blocksize, sizeof(FLAC__int32)); + if(empty_buffer[i] == NULL) { + for(i = 0; i < empty_frame.header.channels; i++) + if(empty_buffer[i] != NULL) + free(empty_buffer[i]); + decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; + return false; + } + } /* No repairs larger than 5 seconds or 50 frames are made, to not * unexpectedly create enormous files when one of the headers was * corrupt after all */ @@ -2170,21 +2192,24 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL FLAC__ASSERT(empty_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); decoder->private_->samples_decoded = empty_frame.header.number.sample_number + empty_frame.header.blocksize; - if(!allocate_output_(decoder, empty_frame.header.blocksize, empty_frame.header.channels, empty_frame.header.bits_per_sample)) - return false; - for(channel = 0; channel < empty_frame.header.channels; channel++) { empty_frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; empty_frame.subframes[channel].data.constant.value = 0; empty_frame.subframes[channel].wasted_bits = 0; - memset(decoder->private_->output[channel], 0, sizeof(FLAC__int32) * empty_frame.header.blocksize); } - if(write_audio_frame_to_client_(decoder, &empty_frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) { + if(write_audio_frame_to_client_(decoder, &empty_frame, (const FLAC__int32 * const *)empty_buffer) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) { decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; + for(i = 0; i < empty_frame.header.channels; i++) + if(empty_buffer[i] != NULL) + free(empty_buffer[i]); return false; } } + for(i = 0; i < empty_frame.header.channels; i++) + if(empty_buffer[i] != NULL) + free(empty_buffer[i]); + } } } @@ -2496,6 +2521,14 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) x = (x << 8) | _x; } decoder->private_->frame.header.blocksize = x+1; + if(decoder->private_->frame.header.blocksize > 65535) { /* invalid blocksize (65536) specified */ + decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ + decoder->private_->cached = true; + send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); + decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; + return true; + } + } if(sample_rate_hint) { @@ -2940,7 +2973,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_ if(rice_parameter < pesc) { partitioned_rice_contents->raw_bits[partition] = 0; u = (partition == 0) ? partition_samples - predictor_order : partition_samples; - if(!FLAC__bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter)){ + if(!decoder->private_->local_bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter)){ if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { /* no error was set, read_callback_ didn't set it, so * invalid rice symbol was found */ @@ -3198,8 +3231,12 @@ FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder if(delta > 0) { uint32_t channel; const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS]; - for(channel = 0; channel < frame->header.channels; channel++) + for(channel = 0; channel < frame->header.channels; channel++) { newbuffer[channel] = buffer[channel] + delta; + decoder->private_->last_frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; + decoder->private_->last_frame.subframes[channel].data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32; + decoder->private_->last_frame.subframes[channel].data.verbatim.data.int32 = newbuffer[channel]; + } decoder->private_->last_frame.header.blocksize -= delta; decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; /* write the relevant samples */ diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index 189b1203..c1c03e49 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1064,7 +1064,6 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( # ifdef FLAC__SSE4_2_SUPPORTED if (encoder->private_->cpuinfo.x86.sse42) { encoder->private_->local_fixed_compute_best_predictor_limit_residual = FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42; - } # endif # ifdef FLAC__AVX2_SUPPORTED @@ -1209,7 +1208,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( memset(encoder->private_->streaminfo.data.stream_info.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */ if(encoder->protected_->do_md5) FLAC__MD5Init(&encoder->private_->md5context); - if(!FLAC__add_metadata_block(&encoder->private_->streaminfo, encoder->private_->frame)) { + if(!FLAC__add_metadata_block(&encoder->private_->streaminfo, encoder->private_->frame, true)) { encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; } @@ -1245,7 +1244,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( vorbis_comment.data.vorbis_comment.vendor_string.entry = 0; vorbis_comment.data.vorbis_comment.num_comments = 0; vorbis_comment.data.vorbis_comment.comments = 0; - if(!FLAC__add_metadata_block(&vorbis_comment, encoder->private_->frame)) { + if(!FLAC__add_metadata_block(&vorbis_comment, encoder->private_->frame, true)) { encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; } @@ -1260,7 +1259,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( */ for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) { encoder->protected_->metadata[i]->is_last = (i == encoder->protected_->num_metadata_blocks - 1); - if(!FLAC__add_metadata_block(encoder->protected_->metadata[i], encoder->private_->frame)) { + if(!FLAC__add_metadata_block(encoder->protected_->metadata[i], encoder->private_->frame, true)) { encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; } @@ -2249,7 +2248,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_limit_min_bitrate(const FLAC__Strea FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], uint32_t samples) { uint32_t i, j = 0, k = 0, channel; - const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize, bps = encoder->protected_->bits_per_sample; + const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; const FLAC__int32 sample_max = INT32_MAX >> (32 - encoder->protected_->bits_per_sample); const FLAC__int32 sample_min = INT32_MIN >> (32 - encoder->protected_->bits_per_sample); @@ -2278,24 +2277,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, c } memcpy(&encoder->private_->integer_signal[channel][encoder->private_->current_sample_number], &buffer[channel][j], sizeof(buffer[channel][0]) * n); } - - if(encoder->protected_->do_mid_side_stereo) { - FLAC__ASSERT(channels == 2); - /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */ - if(bps < 32) - for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { - encoder->private_->integer_signal_mid_side[1][i] = buffer[0][j] - buffer[1][j]; - encoder->private_->integer_signal_mid_side[0][i] = (buffer[0][j] + buffer[1][j]) >> 1; /* NOTE: not the same as 'mid = (buffer[0][j] + buffer[1][j]) / 2' ! */ - } - else - for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { - encoder->private_->integer_signal_33bit_side[i] = (FLAC__int64)buffer[0][j] - (FLAC__int64)buffer[1][j]; - encoder->private_->integer_signal_mid_side[0][i] = ((FLAC__int64)buffer[0][j] + (FLAC__int64)buffer[1][j]) >> 1; /* NOTE: not the same as 'mid = (buffer[0][j] + buffer[1][j]) / 2' ! */ - } - } - else - j += n; - + j += n; encoder->private_->current_sample_number += n; /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */ @@ -2307,13 +2289,6 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, c /* move unprocessed overread samples to beginnings of arrays */ for(channel = 0; channel < channels; channel++) encoder->private_->integer_signal[channel][0] = encoder->private_->integer_signal[channel][blocksize]; - if(encoder->protected_->do_mid_side_stereo) { - encoder->private_->integer_signal_mid_side[0][0] = encoder->private_->integer_signal_mid_side[0][blocksize]; - if(bps < 32) - encoder->private_->integer_signal_mid_side[1][0] = encoder->private_->integer_signal_mid_side[1][blocksize]; - else - encoder->private_->integer_signal_33bit_side[0] = encoder->private_->integer_signal_33bit_side[blocksize]; - } encoder->private_->current_sample_number = 1; } } while(j < samples); @@ -2324,7 +2299,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, c FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], uint32_t samples) { uint32_t i, j, k, channel; - const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize, bps = encoder->protected_->bits_per_sample; + const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; const FLAC__int32 sample_max = INT32_MAX >> (32 - encoder->protected_->bits_per_sample); const FLAC__int32 sample_min = INT32_MIN >> (32 - encoder->protected_->bits_per_sample); @@ -2336,87 +2311,33 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder return false; j = k = 0; - /* - * we have several flavors of the same basic loop, optimized for - * different conditions: - */ - if(encoder->protected_->do_mid_side_stereo && channels == 2) { - /* - * stereo coding: unroll channel loop - */ - do { - if(encoder->protected_->verify) - append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); + do { + if(encoder->protected_->verify) + append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */ - for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { - if(buffer[k] < sample_min || buffer[k] > sample_max || - buffer[k+1] < sample_min || buffer[k+1] > sample_max){ + for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { + for(channel = 0; channel < channels; channel++){ + if(buffer[k] < sample_min || buffer[k] > sample_max){ encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; return false; } - encoder->private_->integer_signal[0][i] = buffer[k++]; - encoder->private_->integer_signal[1][i] = buffer[k++]; - if(bps < 32){ - encoder->private_->integer_signal_mid_side[1][i] = encoder->private_->integer_signal[0][i] - encoder->private_->integer_signal[1][i]; - encoder->private_->integer_signal_mid_side[0][i] = (encoder->private_->integer_signal[0][i] + encoder->private_->integer_signal[1][i]) >> 1; - } - else { - encoder->private_->integer_signal_33bit_side[i] = (FLAC__int64)encoder->private_->integer_signal[0][i] - (FLAC__int64)encoder->private_->integer_signal[1][i]; - encoder->private_->integer_signal_mid_side[0][i] = ((FLAC__int64)encoder->private_->integer_signal[0][i] + (FLAC__int64)encoder->private_->integer_signal[1][i]) >> 1; - } - } - encoder->private_->current_sample_number = i; - /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */ - if(i > blocksize) { - if(!process_frame_(encoder, /*is_last_block=*/false)) - return false; - /* move unprocessed overread samples to beginnings of arrays */ - FLAC__ASSERT(i == blocksize+OVERREAD_); - FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */ - encoder->private_->integer_signal[0][0] = encoder->private_->integer_signal[0][blocksize]; - encoder->private_->integer_signal[1][0] = encoder->private_->integer_signal[1][blocksize]; - encoder->private_->integer_signal_mid_side[0][0] = encoder->private_->integer_signal_mid_side[0][blocksize]; - if(bps < 32) - encoder->private_->integer_signal_mid_side[1][0] = encoder->private_->integer_signal_mid_side[1][blocksize]; - else - encoder->private_->integer_signal_33bit_side[0] = encoder->private_->integer_signal_33bit_side[blocksize]; - encoder->private_->current_sample_number = 1; + encoder->private_->integer_signal[channel][i] = buffer[k++]; } - } while(j < samples); - } - else { - /* - * independent channel coding: buffer each channel in inner loop - */ - do { - if(encoder->protected_->verify) - append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); - - /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */ - for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { - for(channel = 0; channel < channels; channel++){ - if(buffer[k] < sample_min || buffer[k] > sample_max){ - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - encoder->private_->integer_signal[channel][i] = buffer[k++]; - } - } - encoder->private_->current_sample_number = i; - /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */ - if(i > blocksize) { - if(!process_frame_(encoder, /*is_last_block=*/false)) - return false; - /* move unprocessed overread samples to beginnings of arrays */ - FLAC__ASSERT(i == blocksize+OVERREAD_); - FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */ - for(channel = 0; channel < channels; channel++) - encoder->private_->integer_signal[channel][0] = encoder->private_->integer_signal[channel][blocksize]; - encoder->private_->current_sample_number = 1; - } - } while(j < samples); - } + } + encoder->private_->current_sample_number = i; + /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */ + if(i > blocksize) { + if(!process_frame_(encoder, /*is_last_block=*/false)) + return false; + /* move unprocessed overread samples to beginnings of arrays */ + FLAC__ASSERT(i == blocksize+OVERREAD_); + FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */ + for(channel = 0; channel < channels; channel++) + encoder->private_->integer_signal[channel][0] = encoder->private_->integer_signal[channel][blocksize]; + encoder->private_->current_sample_number = 1; + } + } while(j < samples); return true; } @@ -3281,6 +3202,25 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder) FLAC__ASSERT(do_independent || do_mid_side); /* + * Prepare mid-side signals if applicable + */ + if(do_mid_side) { + uint32_t i; + FLAC__ASSERT(encoder->protected_->channels == 2); + if(encoder->protected_->bits_per_sample < 32) + for(i = 0; i < encoder->protected_->blocksize; i++) { + encoder->private_->integer_signal_mid_side[1][i] = encoder->private_->integer_signal[0][i] - encoder->private_->integer_signal[1][i]; + encoder->private_->integer_signal_mid_side[0][i] = (encoder->private_->integer_signal[0][i] + encoder->private_->integer_signal[1][i]) >> 1; /* NOTE: not the same as 'mid = (signal[0][j] + signal[1][j]) / 2' ! */ + } + else + for(i = 0; i <= encoder->protected_->blocksize; i++) { + encoder->private_->integer_signal_33bit_side[i] = (FLAC__int64)encoder->private_->integer_signal[0][i] - (FLAC__int64)encoder->private_->integer_signal[1][i]; + encoder->private_->integer_signal_mid_side[0][i] = ((FLAC__int64)encoder->private_->integer_signal[0][i] + (FLAC__int64)encoder->private_->integer_signal[1][i]) >> 1; /* NOTE: not the same as 'mid = (signal[0][j] + signal[1][j]) / 2' ! */ + } + } + + + /* * Check for wasted bits; set effective bps for each subframe */ if(do_independent) { diff --git a/src/libFLAC/stream_encoder_framing.c b/src/libFLAC/stream_encoder_framing.c index 0a7095ab..0e07a317 100644 --- a/src/libFLAC/stream_encoder_framing.c +++ b/src/libFLAC/stream_encoder_framing.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -44,7 +44,7 @@ static FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCodingMethod *method); static FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const uint32_t residual_samples, const uint32_t predictor_order, const uint32_t rice_parameters[], const uint32_t raw_bits[], const uint32_t partition_order, const FLAC__bool is_extended); -FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw) +FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw, FLAC__bool update_vendor_string) { uint32_t i, j, metadata_length; const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); @@ -62,7 +62,7 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__ * First, for VORBIS_COMMENTs, adjust the length to reflect our vendor string */ metadata_length = metadata->length; - if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { + if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT && update_vendor_string) { FLAC__ASSERT(metadata->data.vorbis_comment.vendor_string.length == 0 || 0 != metadata->data.vorbis_comment.vendor_string.entry); metadata_length -= metadata->data.vorbis_comment.vendor_string.length; metadata_length += vendor_string_length; @@ -130,10 +130,18 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__ } break; case FLAC__METADATA_TYPE_VORBIS_COMMENT: - if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, vendor_string_length)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)FLAC__VENDOR_STRING, vendor_string_length)) - return false; + if(update_vendor_string) { + if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, vendor_string_length)) + return false; + if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)FLAC__VENDOR_STRING, vendor_string_length)) + return false; + } + else { + if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, metadata->data.vorbis_comment.vendor_string.length)) + return false; + if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.vorbis_comment.vendor_string.entry, metadata->data.vorbis_comment.vendor_string.length)) + return false; + } if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, metadata->data.vorbis_comment.num_comments)) return false; for(i = 0; i < metadata->data.vorbis_comment.num_comments; i++) { diff --git a/src/libFLAC/stream_encoder_intrin_avx2.c b/src/libFLAC/stream_encoder_intrin_avx2.c index 665f8036..b37efb38 100644 --- a/src/libFLAC/stream_encoder_intrin_avx2.c +++ b/src/libFLAC/stream_encoder_intrin_avx2.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/stream_encoder_intrin_sse2.c b/src/libFLAC/stream_encoder_intrin_sse2.c index fdab55b8..dd25fa65 100644 --- a/src/libFLAC/stream_encoder_intrin_sse2.c +++ b/src/libFLAC/stream_encoder_intrin_sse2.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/stream_encoder_intrin_ssse3.c b/src/libFLAC/stream_encoder_intrin_ssse3.c index 6f217521..241f723a 100644 --- a/src/libFLAC/stream_encoder_intrin_ssse3.c +++ b/src/libFLAC/stream_encoder_intrin_ssse3.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/libFLAC/version.rc b/src/libFLAC/version.rc new file mode 100644 index 00000000..019da1dd --- /dev/null +++ b/src/libFLAC/version.rc @@ -0,0 +1,40 @@ +#include <winver.h> +#include "config.h" +#include "FLAC/export.h" + +#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) +# ifdef GIT_COMMIT_TAG +# define VERSIONSTRING GIT_COMMIT_TAG +# else +# define VERSIONSTRING "git-" GIT_COMMIT_HASH +# endif +#else +# define VERSIONSTRING PACKAGE_VERSION +#endif + +#define xstr(s) str(s) +#define str(s) #s + +VS_VERSION_INFO VERSIONINFO +FILEVERSION FLAC_API_VERSION_CURRENT,FLAC_API_VERSION_REVISION,0,0 +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "libFLAC for Windows" + VALUE "ProductName", "Free Lossless Audio Codec" + VALUE "ProductVersion", VERSIONSTRING + VALUE "CompanyName", "Xiph.Org" + VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/src/libFLAC/window.c b/src/libFLAC/window.c index 4ee6f79d..69d5464a 100644 --- a/src/libFLAC/window.c +++ b/src/libFLAC/window.c @@ -1,6 +1,6 @@ /* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/metaflac/CMakeLists.txt b/src/metaflac/CMakeLists.txt index 677ab1a5..b8af7058 100644 --- a/src/metaflac/CMakeLists.txt +++ b/src/metaflac/CMakeLists.txt @@ -9,6 +9,7 @@ add_executable(metaflac options.c usage.c utils.c + version.rc $<$<BOOL:${WIN32}>:../../include/share/win_utf8_io.h> $<$<BOOL:${WIN32}>:../share/win_utf8_io/win_utf8_io.c>) target_link_libraries(metaflac FLAC getopt utf8) diff --git a/src/metaflac/Makefile.am b/src/metaflac/Makefile.am index 446a3c37..8c212ff4 100644 --- a/src/metaflac/Makefile.am +++ b/src/metaflac/Makefile.am @@ -1,6 +1,6 @@ # metaflac - Command-line FLAC metadata editor # Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -16,12 +16,21 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +if OS_IS_WINDOWS +win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la +if HAVE_WINDRES +metaflac_DEPENDENCIES = version.o +windows_resource_link = -Wl,version.o +endif +endif + bin_PROGRAMS = metaflac AM_CFLAGS = @OGG_CFLAGS@ AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include EXTRA_DIST = \ - CMakeLists.txt + CMakeLists.txt \ + version.rc metaflac_SOURCES = \ main.c \ @@ -39,11 +48,7 @@ metaflac_SOURCES = \ options.h \ usage.h \ utils.h -metaflac_LDFLAGS = $(AM_LDFLAGS) - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -endif +metaflac_LDFLAGS = $(AM_LDFLAGS) $(windows_resource_link) metaflac_LDADD = \ $(top_builddir)/src/share/grabbag/libgrabbag.la \ @@ -55,3 +60,6 @@ metaflac_LDADD = \ @LTLIBICONV@ CLEANFILES = metaflac.exe + +.rc.o: + $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/src/metaflac/main.c b/src/metaflac/main.c index cd488e7c..bb662935 100644 --- a/src/metaflac/main.c +++ b/src/metaflac/main.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,7 +28,11 @@ #include <string.h> #include "share/compat.h" +#ifndef FUZZ_TOOL_METAFLAC int main(int argc, char *argv[]) +#else +static int main_to_fuzz(int argc, char *argv[]) +#endif { CommandLineOptions options; int ret = 0; diff --git a/src/metaflac/operations.c b/src/metaflac/operations.c index 09b225cc..d81d87a7 100644 --- a/src/metaflac/operations.c +++ b/src/metaflac/operations.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -49,6 +49,7 @@ static FLAC__bool do_shorthand_operation__add_padding(const char *filename, FLAC static FLAC__bool passes_filter(const CommandLineOptions *options, const FLAC__StreamMetadata *block, unsigned block_number); static void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned block_number, FLAC__bool raw, FLAC__bool hexdump_application); +static void write_metadata_binary(FLAC__StreamMetadata *block, FLAC__byte *block_raw, FLAC__bool headerless); /* from operations_shorthand_seektable.c */ extern FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write); @@ -189,8 +190,20 @@ FLAC__bool do_major_operation__list(const char *filename, FLAC__Metadata_Chain * ok &= (0 != block); if(!ok) flac_fprintf(stderr, "%s: ERROR: couldn't get block from chain\n", filename); - else if(passes_filter(options, FLAC__metadata_iterator_get_block(iterator), block_number)) - write_metadata(filename, block, block_number, !options->utf8_convert, options->application_data_format_is_hexdump); + else if(passes_filter(options, FLAC__metadata_iterator_get_block(iterator), block_number)) { + if(!options->data_format_is_binary && !options->data_format_is_binary_headerless) + write_metadata(filename, block, block_number, !options->utf8_convert, options->application_data_format_is_hexdump); + else { + FLAC__byte * block_raw = FLAC__metadata_object_get_raw(block); + if(block_raw == 0) { + flac_fprintf(stderr, "%s: ERROR: couldn't get block in raw form\n", filename); + FLAC__metadata_iterator_delete(iterator); + return false; + } + write_metadata_binary(block, block_raw, options->data_format_is_binary_headerless); + free(block_raw); + } + } block_number++; } while(ok && FLAC__metadata_iterator_next(iterator)); @@ -201,9 +214,124 @@ FLAC__bool do_major_operation__list(const char *filename, FLAC__Metadata_Chain * FLAC__bool do_major_operation__append(FLAC__Metadata_Chain *chain, const CommandLineOptions *options) { - (void) chain, (void) options; - flac_fprintf(stderr, "ERROR: --append not implemented yet\n"); - return false; + FLAC__byte header[FLAC__STREAM_METADATA_HEADER_LENGTH]; + FLAC__byte *buffer; + FLAC__uint32 buffer_size, num_objects = 0, i, append_after = UINT32_MAX; + FLAC__StreamMetadata *object; + FLAC__Metadata_Iterator *iterator = 0; + FLAC__bool has_vorbiscomment = false; + + /* First, find out after which block appending should take place */ + for(i = 0; i < options->args.num_arguments; i++) { + if(options->args.arguments[i].type == ARG__BLOCK_NUMBER) { + if(append_after != UINT32_MAX || options->args.arguments[i].value.block_number.num_entries > 1) { + flac_fprintf(stderr, "ERROR: more than one block number specified with --append\n"); + return false; + } + append_after = options->args.arguments[i].value.block_number.entries[0]; + } + } + + iterator = FLAC__metadata_iterator_new(); + + if(0 == iterator) + die("out of memory allocating iterator"); + + FLAC__metadata_iterator_init(iterator, chain); + + /* Find out whether there is already a vorbis comment block present */ + do { + FLAC__MetadataType type = FLAC__metadata_iterator_get_block_type(iterator); + if(type == FLAC__METADATA_TYPE_VORBIS_COMMENT) + has_vorbiscomment = true; + } + while(FLAC__metadata_iterator_next(iterator)); + + /* Reset iterator */ + FLAC__metadata_iterator_init(iterator, chain); + + /* Go to requested block */ + for(i = 0; i < append_after; i++) { + if(!FLAC__metadata_iterator_next(iterator)) + break; + } + +#ifdef _WIN32 + _setmode(fileno(stdin),_O_BINARY); +#endif + + /* Read header from stdin */ + while(fread(header, 1, FLAC__STREAM_METADATA_HEADER_LENGTH, stdin) == FLAC__STREAM_METADATA_HEADER_LENGTH) { + + buffer_size = ((FLAC__uint32)(header[1]) << 16) + ((FLAC__uint32)(header[2]) << 8) + header[3]; + buffer = safe_malloc_(buffer_size + FLAC__STREAM_METADATA_HEADER_LENGTH); + if(0 == buffer) + die("out of memory allocating read buffer"); + memcpy(buffer, header, FLAC__STREAM_METADATA_HEADER_LENGTH); + + num_objects++; + + if(fread(buffer+FLAC__STREAM_METADATA_HEADER_LENGTH, 1, buffer_size, stdin) < buffer_size) { + flac_fprintf(stderr, "ERROR: couldn't read metadata block #%u from stdin\n",(num_objects)); + free(buffer); + FLAC__metadata_iterator_delete(iterator); + return false; + } + + if((object = FLAC__metadata_object_set_raw(buffer, buffer_size + FLAC__STREAM_METADATA_HEADER_LENGTH)) == NULL) { + flac_fprintf(stderr, "ERROR: couldn't parse supplied metadata block #%u\n",(num_objects)); + free(buffer); + FLAC__metadata_iterator_delete(iterator); + return false; + } + free(buffer); + + if(has_vorbiscomment && object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { + flac_fprintf(stderr, "ERROR: can't add another vorbis comment block to file, it already has one\n"); + FLAC__metadata_object_delete(object); + FLAC__metadata_iterator_delete(iterator); + return false; + } + + + if(object->type == FLAC__METADATA_TYPE_STREAMINFO) { + flac_fprintf(stderr, "ERROR: can't add streaminfo to file\n"); + FLAC__metadata_object_delete(object); + FLAC__metadata_iterator_delete(iterator); + return false; + } + + if(object->type == FLAC__METADATA_TYPE_SEEKTABLE) { + flac_fprintf(stderr, "ERROR: can't add seektable to file, please use --add-seekpoint instead\n"); + FLAC__metadata_object_delete(object); + FLAC__metadata_iterator_delete(iterator); + return false; + } + + if(!FLAC__metadata_iterator_insert_block_after(iterator, object)) { + flac_fprintf(stderr, "ERROR: couldn't add supplied metadata block #%u to file\n",(num_objects)); + FLAC__metadata_object_delete(object); + FLAC__metadata_iterator_delete(iterator); + return false; + } + /* Now check whether what type of block was added */ + { + FLAC__MetadataType type = FLAC__metadata_iterator_get_block_type(iterator); + if(type == FLAC__METADATA_TYPE_VORBIS_COMMENT) + has_vorbiscomment = true; + } + } + +#ifdef _WIN32 + _setmode(fileno(stdin),_O_TEXT); +#endif + + if(num_objects == 0) + flac_fprintf(stderr, "ERROR: unable to find a metadata block in the supplied input\n"); + + FLAC__metadata_iterator_delete(iterator); + + return true; } FLAC__bool do_major_operation__remove(FLAC__Metadata_Chain *chain, const CommandLineOptions *options) @@ -444,8 +572,11 @@ FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned nu flac_fprintf(stderr, "%s: ERROR: # of channels (%u) is not supported, must be 1 or 2\n", filenames[i], channels); return false; } + if(bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || bits_per_sample > FLAC__MAX_BITS_PER_SAMPLE) { + flac_fprintf(stderr, "%s: ERROR: resolution (%u) is not supported, must be between %u and %u\n", filenames[i], bits_per_sample, FLAC__MIN_BITS_PER_SAMPLE, FLAC__MAX_BITS_PER_SAMPLE); + return false; + } } - FLAC__ASSERT(bits_per_sample >= FLAC__MIN_BITS_PER_SAMPLE && bits_per_sample <= FLAC__MAX_BITS_PER_SAMPLE); if(!grabbag__replaygain_init(sample_rate)) { FLAC__ASSERT(0); @@ -672,3 +803,21 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned } #undef PPR } + +void write_metadata_binary(FLAC__StreamMetadata *block, FLAC__byte *block_raw, FLAC__bool headerless) +{ +#ifdef _WIN32 + fflush(stdout); + _setmode(fileno(stdout),_O_BINARY); +#endif + if(!headerless) + local_fwrite(block_raw, 1, block->length+FLAC__STREAM_METADATA_HEADER_LENGTH, stdout); + else if(block->type == FLAC__METADATA_TYPE_APPLICATION && block->length > 3) + local_fwrite(block_raw+FLAC__STREAM_METADATA_HEADER_LENGTH+4, 1, block->length-4, stdout); + else + local_fwrite(block_raw+FLAC__STREAM_METADATA_HEADER_LENGTH, 1, block->length, stdout); +#ifdef _WIN32 + fflush(stdout); + _setmode(fileno(stdout),_O_TEXT); +#endif +} diff --git a/src/metaflac/operations.h b/src/metaflac/operations.h index a5c1ebbb..79e1c3ba 100644 --- a/src/metaflac/operations.h +++ b/src/metaflac/operations.h @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/metaflac/operations_shorthand.h b/src/metaflac/operations_shorthand.h index 6567efe2..1877c268 100644 --- a/src/metaflac/operations_shorthand.h +++ b/src/metaflac/operations_shorthand.h @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/metaflac/operations_shorthand_cuesheet.c b/src/metaflac/operations_shorthand_cuesheet.c index 72154efb..13c4dedb 100644 --- a/src/metaflac/operations_shorthand_cuesheet.c +++ b/src/metaflac/operations_shorthand_cuesheet.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -69,6 +69,12 @@ FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata return false; } + if(sample_rate == 0) { + flac_fprintf(stderr, "%s: ERROR: cannot parse cuesheet when sample rate is unknown\n", filename); + FLAC__metadata_iterator_delete(iterator); + return false; + } + switch(operation->type) { case OP__IMPORT_CUESHEET_FROM: if(0 != cuesheet) { @@ -144,6 +150,7 @@ FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, if(!FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/false, &error_message)) { flac_fprintf(stderr, "%s: ERROR parsing cuesheet \"%s\": %s\n", filename, cs_filename, error_message); + FLAC__metadata_object_delete(*cuesheet); return false; } @@ -209,6 +216,11 @@ FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cueshe if(f != stdout) fclose(f); +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Delete output file when fuzzing */ + if(f != stdout) + flac_unlink(cs_filename); +#endif return true; } diff --git a/src/metaflac/operations_shorthand_picture.c b/src/metaflac/operations_shorthand_picture.c index 1c5ecf40..6bb459ba 100644 --- a/src/metaflac/operations_shorthand_picture.c +++ b/src/metaflac/operations_shorthand_picture.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -136,6 +136,8 @@ FLAC__bool import_pic_from(const char *filename, FLAC__StreamMetadata **picture, if(!FLAC__format_picture_is_legal(&(*picture)->data.picture, &error_message)) { flac_fprintf(stderr, "%s: ERROR: new PICTURE block for \"%s\" is illegal: %s\n", filename, specification, error_message); + FLAC__metadata_object_delete(*picture); + *picture = 0; return false; } @@ -172,5 +174,11 @@ FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *pictu if(f != stdout) fclose(f); +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Delete output file when fuzzing */ + if(f != stdout) + flac_unlink(pic_filename); +#endif + return true; } diff --git a/src/metaflac/operations_shorthand_seektable.c b/src/metaflac/operations_shorthand_seektable.c index 50136581..c9175b36 100644 --- a/src/metaflac/operations_shorthand_seektable.c +++ b/src/metaflac/operations_shorthand_seektable.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -55,6 +55,7 @@ FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Me if(total_samples == 0) { flac_fprintf(stderr, "%s: ERROR: cannot add seekpoints because STREAMINFO block does not specify total_samples\n", filename); + FLAC__metadata_iterator_delete(iterator); return false; } @@ -68,6 +69,7 @@ FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Me if(!FLAC__metadata_iterator_insert_block_after(iterator, block)) { print_error_with_chain_status(chain, "%s: ERROR: adding new SEEKTABLE block to metadata", filename); FLAC__metadata_object_delete(block); + FLAC__metadata_iterator_delete(iterator); return false; } /* iterator is left pointing to new block */ diff --git a/src/metaflac/operations_shorthand_streaminfo.c b/src/metaflac/operations_shorthand_streaminfo.c index 0fe471ec..32198416 100644 --- a/src/metaflac/operations_shorthand_streaminfo.c +++ b/src/metaflac/operations_shorthand_streaminfo.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/metaflac/operations_shorthand_vorbiscomment.c b/src/metaflac/operations_shorthand_vorbiscomment.c index bf135d4b..27c9e4c8 100644 --- a/src/metaflac/operations_shorthand_vorbiscomment.c +++ b/src/metaflac/operations_shorthand_vorbiscomment.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -419,5 +419,12 @@ FLAC__bool export_vc_to(const char *filename, FLAC__StreamMetadata *block, const if(f != stdout) fclose(f); + +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Delete output file when fuzzing */ + if(f != stdout) + flac_unlink(vc_filename->value); +#endif + return ret; } diff --git a/src/metaflac/options.c b/src/metaflac/options.c index 10d05906..1b4b6f62 100644 --- a/src/metaflac/options.c +++ b/src/metaflac/options.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -139,6 +139,8 @@ void init_options(CommandLineOptions *options) options->cued_seekpoints = true; options->show_long_help = false; options->show_version = false; + options->data_format_is_binary = false; + options->data_format_is_binary_headerless = false; options->application_data_format_is_hexdump = false; options->ops.operations = 0; @@ -210,7 +212,7 @@ FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options) } /* check for only one FLAC file used with certain options */ - if(options->num_files > 1) { + if(!had_error && options->num_files > 1) { if(0 != find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM)) { flac_fprintf(stderr, "ERROR: you may only specify one FLAC file when using '--import-cuesheet-from'\n"); had_error = true; @@ -713,6 +715,8 @@ FLAC__bool parse_option(int option_index, const char *option_argument, CommandLi flac_fprintf(stderr, "ERROR (--%s): illegal data format \"%s\"\n", opt, option_argument); ok = false; } + options->data_format_is_binary = arg->value.data_format.is_binary; + options->data_format_is_binary_headerless = arg->value.data_format.is_headerless; } else if(0 == strcmp(opt, "application-data-format")) { FLAC__ASSERT(0 != option_argument); @@ -1108,10 +1112,18 @@ FLAC__bool parse_block_type(const char *in, Argument_BlockType *out) FLAC__bool parse_data_format(const char *in, Argument_DataFormat *out) { - if(0 == strcmp(in, "binary")) + if(0 == strcmp(in, "binary-headerless")) { + out->is_binary = false; + out->is_headerless = true; + } + else if(0 == strcmp(in, "binary")) { out->is_binary = true; - else if(0 == strcmp(in, "text")) + out->is_headerless = false; + } + else if(0 == strcmp(in, "text")) { out->is_binary = false; + out->is_headerless = false; + } else return false; return true; diff --git a/src/metaflac/options.h b/src/metaflac/options.h index d13e2d88..984f2e11 100644 --- a/src/metaflac/options.h +++ b/src/metaflac/options.h @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -131,6 +131,7 @@ typedef struct { typedef struct { FLAC__bool is_binary; + FLAC__bool is_headerless; } Argument_DataFormat; typedef struct { @@ -190,6 +191,8 @@ typedef struct { FLAC__bool cued_seekpoints; FLAC__bool show_long_help; FLAC__bool show_version; + FLAC__bool data_format_is_binary; + FLAC__bool data_format_is_binary_headerless; FLAC__bool application_data_format_is_hexdump; struct { Operation *operations; diff --git a/src/metaflac/usage.c b/src/metaflac/usage.c index 62c2f1a8..58afc0ea 100644 --- a/src/metaflac/usage.c +++ b/src/metaflac/usage.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,6 +21,7 @@ # include <config.h> #endif +#include "utils.h" #include "usage.h" #include "FLAC/format.h" #include <stdarg.h> @@ -32,7 +33,7 @@ static void usage_header(FILE *out) fprintf(out, "==============================================================================\n"); fprintf(out, "metaflac - Command-line FLAC metadata editor version %s\n", FLAC__VERSION_STRING); fprintf(out, "Copyright (C) 2001-2009 Josh Coalson\n"); - fprintf(out, "Copyright (C) 2011-2022 Xiph.Org Foundation\n"); + fprintf(out, "Copyright (C) 2011-2023 Xiph.Org Foundation\n"); fprintf(out, "\n"); fprintf(out, "This program is free software; you can redistribute it and/or\n"); fprintf(out, "modify it under the terms of the GNU General Public License\n"); @@ -61,7 +62,9 @@ static void usage_summary(FILE *out) fprintf(out, "Options:\n"); fprintf(out, "--preserve-modtime Preserve the original modification time in spite of edits\n"); fprintf(out, "--with-filename Prefix each output line with the FLAC file name\n"); - fprintf(out, " (the default if more than one FLAC file is specified)\n"); + fprintf(out, " (the default if more than one FLAC file is specified).\n"); + fprintf(out, " This option has no effect for options exporting to a\n"); + fprintf(out, " file, like --export-tags-to.\n"); fprintf(out, "--no-filename Do not prefix each output line with the FLAC file name\n"); fprintf(out, " (the default if only one FLAC file is specified)\n"); fprintf(out, "--no-utf8-convert Do not convert tags from UTF-8 to local charset,\n"); @@ -274,23 +277,30 @@ int long_usage(const char *message, ...) fprintf(out, " NOTE: if both --block-number and --[except-]block-type are specified,\n"); fprintf(out, " the result is the logical AND of both arguments.\n"); fprintf(out, "\n"); -#if 0 - /*@@@ not implemented yet */ - fprintf(out, " --data-format=binary|text\n"); + fprintf(out, " --data-format=binary|binary-headerless|text\n"); fprintf(out, " By default a human-readable text representation of the data is displayed.\n"); fprintf(out, " You may specify --data-format=binary to dump the raw binary form of each\n"); - fprintf(out, " metadata block. The output can be read in using a subsequent call to\n"); - fprintf(out, " "metaflac --append --from-file=..."\n"); + fprintf(out, " metadata block. Specify --data-format=binary-headerless to omit output of\n"); + fprintf(out, " metadata block headers, including the id of APPLICATION metadata blocks.\n"); + fprintf(out, " The output can be read in using a subsequent call to\n"); + fprintf(out, " \"metaflac --append\"\n"); fprintf(out, "\n"); -#endif fprintf(out, " --application-data-format=hexdump|text\n"); fprintf(out, " If the application block you are displaying contains binary data but your\n"); fprintf(out, " --data-format=text, you can display a hex dump of the application data\n"); fprintf(out, " contents instead using --application-data-format=hexdump\n"); fprintf(out, "\n"); -#if 0 - /*@@@ not implemented yet */ fprintf(out, "--append\n"); + fprintf(out, " Insert a metadata block from a file. This must be a binary block as\n"); + fprintf(out, " exported with --list --data-format=binary. The insertion point is\n"); + fprintf(out, " defined with --block-number=#. The new block will be added after the\n"); + fprintf(out, " given block number. This prevents the illegal insertion of a block\n"); + fprintf(out, " before the first STREAMINFO block. You may not --append another\n"); + fprintf(out, " STREAMINFO block. It is possible to copy a metadata block from one\n"); + fprintf(out, " file to another with this option. For example use\n"); + fprintf(out, " metaflac --list --data-format=binary --block-number=6 file.flac > block\n"); + fprintf(out, " to export the block, and then import it with\n"); + fprintf(out, " metaflac --append anotherfile.flac < block\n"); fprintf(out, " Insert a metadata block from a file. The input file must be in the same\n"); fprintf(out, " format as generated with --list.\n"); fprintf(out, "\n"); @@ -300,6 +310,8 @@ int long_usage(const char *message, ...) fprintf(out, " of a block before the first STREAMINFO block. You may not --append another\n"); fprintf(out, " STREAMINFO block.\n"); fprintf(out, "\n"); +#if 0 + /*@@@ not implemented yet */ fprintf(out, " --from-file=filename\n"); fprintf(out, " Mandatory 'option' to specify the input file containing the block contents.\n"); fprintf(out, "\n"); diff --git a/src/metaflac/usage.h b/src/metaflac/usage.h index 86893edc..1366417a 100644 --- a/src/metaflac/usage.h +++ b/src/metaflac/usage.h @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/metaflac/utils.c b/src/metaflac/utils.c index e3f27601..045719a7 100644 --- a/src/metaflac/utils.c +++ b/src/metaflac/utils.c @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -76,12 +76,18 @@ void local_strcat(char **dest, const char *source) *dest = safe_realloc_add_3op_(*dest, ndest, /*+*/nsource, /*+*/1); if(*dest == NULL) die("out of memory growing string"); + /* If ndest == 0, strlen in safe_strncat reads + * uninitialized data. To prevent that, set first character + * to zero */ + if(ndest == 0) + *dest[0] = 0; safe_strncat(*dest, source, outlen); } static inline int local_isprint(int c) { if (c < 32) return 0; + if (c > 127) return 0; return isprint(c); } diff --git a/src/metaflac/utils.h b/src/metaflac/utils.h index 41c395be..972a4501 100644 --- a/src/metaflac/utils.h +++ b/src/metaflac/utils.h @@ -1,6 +1,6 @@ /* metaflac - Command-line FLAC metadata editor * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,6 +23,11 @@ #include "FLAC/metadata.h" #include <stdio.h> /* for FILE */ +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +#undef stderr +#define stderr stdout +#endif + void die(const char *message); #ifdef FLAC__VALGRIND_TESTING size_t local_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); diff --git a/src/metaflac/version.rc b/src/metaflac/version.rc new file mode 100644 index 00000000..51172024 --- /dev/null +++ b/src/metaflac/version.rc @@ -0,0 +1,38 @@ +#include <winver.h> +#include "config.h" + +#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) +# ifdef GIT_COMMIT_TAG +# define VERSIONSTRING GIT_COMMIT_TAG +# else +# define VERSIONSTRING "git-" GIT_COMMIT_HASH +# endif +#else +# define VERSIONSTRING PACKAGE_VERSION +#endif + +#define xstr(s) str(s) +#define str(s) #s + +VS_VERSION_INFO VERSIONINFO +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "metaflac command line tool for Windows" + VALUE "ProductName", "Free Lossless Audio Codec" + VALUE "ProductVersion", VERSIONSTRING + VALUE "CompanyName", "Xiph.Org" + VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/src/share/Makefile.am b/src/share/Makefile.am index 412a7dff..caf61226 100644 --- a/src/share/Makefile.am +++ b/src/share/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/src/share/getopt/getopt1.c b/src/share/getopt/getopt1.c index 740e498b..fc526784 100644 --- a/src/share/getopt/getopt1.c +++ b/src/share/getopt/getopt1.c @@ -36,9 +36,6 @@ # include <config.h> #endif -#include "share/getopt.h" -/*[JEC] was:#include "getopt.h"*/ - #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ @@ -49,6 +46,9 @@ #include <stdio.h> +#include "share/getopt.h" +/*[JEC] was:#include "getopt.h"*/ + /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling @@ -79,13 +79,7 @@ #define NULL 0 #endif -int -share__getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct share__option *long_options; - int *opt_index; +int share__getopt_long(int argc, char *const *argv, const char *options, const struct share__option *long_options, int *opt_index) { return share___getopt_internal (argc, argv, options, long_options, opt_index, 0); } @@ -95,13 +89,7 @@ share__getopt_long (argc, argv, options, long_options, opt_index) but does match a short option, it is parsed as a short option instead. */ -int -share__getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct share__option *long_options; - int *opt_index; +int share__getopt_long_only(int argc, char *const *argv, const char *options, const struct share__option *long_options, int *opt_index) { return share___getopt_internal (argc, argv, options, long_options, opt_index, 1); } @@ -113,10 +101,7 @@ share__getopt_long_only (argc, argv, options, long_options, opt_index) #include <stdio.h> -int -main (argc, argv) - int argc; - char **argv; +int main(int argc, char **argv) { int c; int digit_optind = 0; diff --git a/src/share/grabbag/alloc.c b/src/share/grabbag/alloc.c index edf189a0..4e5fb60c 100644 --- a/src/share/grabbag/alloc.c +++ b/src/share/grabbag/alloc.c @@ -1,6 +1,6 @@ /* alloc - Convenience routines for safely allocating memory * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/share/grabbag/cuesheet.c b/src/share/grabbag/cuesheet.c index 1e1a132b..0d19ee72 100644 --- a/src/share/grabbag/cuesheet.c +++ b/src/share/grabbag/cuesheet.c @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +24,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "FLAC/assert.h" #include "share/compat.h" #include "share/grabbag.h" @@ -44,17 +45,21 @@ void grabbag__cuesheet_frame_to_msf(uint32_t frame, uint32_t *minutes, uint32_t } /* since we only care about values >= 0 or error, returns < 0 for any illegal string, else value */ -static int local__parse_int_(const char *s) +static FLAC__int64 local__parse_int64_(const char *s) { - int ret = 0; + FLAC__int64 ret = 0; char c; if(*s == '\0') return -1; while('\0' != (c = *s++)) - if(c >= '0' && c <= '9') - ret = ret * 10 + (c - '0'); + if(c >= '0' && c <= '9') { + if(ret >= (INT64_MAX / 10)) + return -1; + else + ret = ret * 10 + (c - '0'); + } else return -1; @@ -62,21 +67,12 @@ static int local__parse_int_(const char *s) } /* since we only care about values >= 0 or error, returns < 0 for any illegal string, else value */ -static FLAC__int64 local__parse_int64_(const char *s) +static int local__parse_int_(const char *s) { - FLAC__int64 ret = 0; - char c; - - if(*s == '\0') + FLAC__int64 ret64 = local__parse_int64_(s); + if(ret64 < 0 || ret64 > INT_MAX) return -1; - - while('\0' != (c = *s++)) - if(c >= '0' && c <= '9') - ret = ret * 10 + (c - '0'); - else - return -1; - - return ret; + return ret64; } /* accept minute:second:frame syntax of '[0-9]+:[0-9][0-9]?:[0-9][0-9]?', but max second of 59 and max frame of 74, e.g. 0:0:0, 123:45:67 @@ -88,18 +84,27 @@ static FLAC__int64 local__parse_msf_(const char *s, uint32_t sample_rate) FLAC__int64 ret, field; char c; + if(sample_rate == 0) + return -1; + c = *s++; if(c >= '0' && c <= '9') field = (c - '0'); else return -1; while(':' != (c = *s++)) { - if(c >= '0' && c <= '9') - field = field * 10 + (c - '0'); + if(c >= '0' && c <= '9') { + if(field >= (INT64_MAX / 10)) + return -1; + else + field = field * 10 + (c - '0'); + } else return -1; } + if(field >= INT64_MAX / (60 * sample_rate)) + return -1; ret = field * 60 * sample_rate; c = *s++; @@ -121,7 +126,12 @@ static FLAC__int64 local__parse_msf_(const char *s, uint32_t sample_rate) if(field >= 60) return -1; - ret += field * sample_rate; + { + FLAC__int64 tmp = ret; + ret += field * sample_rate; + if(ret < tmp) + return -1; + } c = *s++; if(c >= '0' && c <= '9') @@ -143,7 +153,12 @@ static FLAC__int64 local__parse_msf_(const char *s, uint32_t sample_rate) if(field >= 75) return -1; - ret += field * (sample_rate / 75); + { + FLAC__int64 tmp = ret; + ret += field * (sample_rate / 75); + if(ret < tmp) + return -1; + } return ret; } @@ -158,21 +173,29 @@ static FLAC__int64 local__parse_ms_(const char *s, uint32_t sample_rate) double x; char c, *end; + if(sample_rate == 0) + return -1; + c = *s++; if(c >= '0' && c <= '9') field = (c - '0'); else return -1; while(':' != (c = *s++)) { - if(c >= '0' && c <= '9') - field = field * 10 + (c - '0'); + if(c >= '0' && c <= '9') { + if(field >= (INT64_MAX / 10)) + return -1; + else + field = field * 10 + (c - '0'); + } else return -1; } + if(field >= INT64_MAX / (60 * sample_rate)) + return -1; ret = field * 60 * sample_rate; - s++; /* skip the ':' */ if(strspn(s, "0123456789.") != strlen(s)) return -1; x = strtod(s, &end); @@ -626,6 +649,8 @@ void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, co fprintf(file, "CATALOG %s\n", cs->media_catalog_number); fprintf(file, "FILE %s\n", file_reference); + FLAC__ASSERT(cs->num_tracks > 0); + for(track_num = 0; track_num < cs->num_tracks-1; track_num++) { const FLAC__StreamMetadata_CueSheet_Track *track = cs->tracks + track_num; diff --git a/src/share/grabbag/file.c b/src/share/grabbag/file.c index 1a781526..307645f5 100644 --- a/src/share/grabbag/file.c +++ b/src/share/grabbag/file.c @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/share/grabbag/picture.c b/src/share/grabbag/picture.c index 9be95ea3..9a4aafe2 100644 --- a/src/share/grabbag/picture.c +++ b/src/share/grabbag/picture.c @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/share/grabbag/replaygain.c b/src/share/grabbag/replaygain.c index 7d81e0fe..32c96031 100644 --- a/src/share/grabbag/replaygain.c +++ b/src/share/grabbag/replaygain.c @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -641,6 +641,8 @@ FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadat res = false; if(res && !parse_double_(block->data.vorbis_comment.comments + peak_offset, peak)) res = false; + if(res && *peak < 0.0) + res = false; setlocale(LC_ALL, saved_locale); free(saved_locale); diff --git a/src/share/grabbag/seektable.c b/src/share/grabbag/seektable.c index 96b56c31..01caa998 100644 --- a/src/share/grabbag/seektable.c +++ b/src/share/grabbag/seektable.c @@ -1,6 +1,6 @@ /* grabbag - Convenience lib for various routines common to several tools * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -61,8 +61,7 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec } } else if(q[-1] == 's') { /* -S #s */ - if(total_samples_to_encode > 0) { /* we can only do these if we know the number of samples to encode up front */ - FLAC__ASSERT(sample_rate > 0); + if(total_samples_to_encode > 0 && sample_rate > 0) { /* we can only do these if we know the number of samples and sample rate to encode up front */ if(0 != spec_has_real_points) *spec_has_real_points = true; if(!only_explicit_placeholders) { diff --git a/src/share/grabbag/snprintf.c b/src/share/grabbag/snprintf.c index 4453a1bd..bd7ffba8 100644 --- a/src/share/grabbag/snprintf.c +++ b/src/share/grabbag/snprintf.c @@ -1,5 +1,5 @@ /* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2013-2022 Xiph.Org Foundation + * Copyright (C) 2013-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/share/replaygain_synthesis/replaygain_synthesis.c b/src/share/replaygain_synthesis/replaygain_synthesis.c index 328afd10..8d4fda6b 100644 --- a/src/share/replaygain_synthesis/replaygain_synthesis.c +++ b/src/share/replaygain_synthesis/replaygain_synthesis.c @@ -1,6 +1,6 @@ /* replaygain_synthesis - Routines for applying ReplayGain to a signal * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/share/utf8/iconvert.c b/src/share/utf8/iconvert.c index 876c06e8..9a1e3f6b 100644 --- a/src/share/utf8/iconvert.c +++ b/src/share/utf8/iconvert.c @@ -62,7 +62,7 @@ int iconvert(const char *fromcode, const char *tocode, char *ib; char *ob; char *utfbuf = 0, *outbuf, *newbuf; - size_t utflen, outlen, ibl, obl, k; + size_t utflen, outlen, ibl, obl, obp, k; char tbuf[2048]; cd1 = iconv_open("UTF-8", fromcode); @@ -124,11 +124,12 @@ int iconvert(const char *fromcode, const char *tocode, if(utflen*2 < utflen) /* overflow check */ goto fail; utflen *= 2; + obp = ob - utfbuf; /* save position */ newbuf = realloc(utfbuf, utflen); if (!newbuf) goto fail; - ob = (ob - utfbuf) + newbuf; - obl = utflen - (ob - newbuf); + ob = newbuf + obp; + obl = utflen - obp; utfbuf = newbuf; } else { @@ -161,6 +162,8 @@ int iconvert(const char *fromcode, const char *tocode, /* Truncate the buffer to be tidy */ utflen = ob - utfbuf; + if (utflen == 0) + goto fail; newbuf = realloc(utfbuf, utflen); if (!newbuf) goto fail; diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c index 65b56997..3ae35b31 100644 --- a/src/share/win_utf8_io/win_utf8_io.c +++ b/src/share/win_utf8_io/win_utf8_io.c @@ -1,5 +1,5 @@ /* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2022 Xiph.Org Foundation + * Copyright (C) 2013-2023 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,9 +39,15 @@ #define UTF8_BUFFER_SIZE 32768 -#if !defined(WINAPI_FAMILY_PARTITION) -#define WINAPI_FAMILY_PARTITION(x) x -#define WINAPI_PARTITION_DESKTOP 1 +/* detect whether it is Windows APP (UWP) or standard Win32 envionment */ +#ifdef WINAPI_FAMILY_PARTITION + #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + #define FLAC_WINDOWS_APP 1 + #else + #define FLAC_WINDOWS_APP 0 + #endif +#else + #define FLAC_WINDOWS_APP 0 #endif static int local_vsnprintf(char *str, size_t size, const char *fmt, va_list va) @@ -106,15 +112,22 @@ static wchar_t *wchar_from_utf8(const char *str) /* retrieve WCHAR commandline, expand wildcards and convert everything to UTF-8 */ int get_utf8_argv(int *argc, char ***argv) { +#if !FLAC_WINDOWS_APP typedef int (__cdecl *wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*); wgetmainargs_t wgetmainargs; HMODULE handle; +#endif // !FLAC_WINDOWS_APP int wargc; wchar_t **wargv; wchar_t **wenv; char **utf8argv; int ret, i; +#if FLAC_WINDOWS_APP + wargc = __argc; + wargv = __wargv; + wenv = _wenviron; +#else // !FLAC_WINDOWS_APP if ((handle = LoadLibraryW(L"msvcrt.dll")) == NULL) return 1; if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) { FreeLibrary(handle); @@ -126,8 +139,11 @@ int get_utf8_argv(int *argc, char ***argv) FreeLibrary(handle); return 1; } +#endif // !FLAC_WINDOWS_APP if ((utf8argv = (char **)calloc(wargc, sizeof(char*))) == NULL) { + #if !FLAC_WINDOWS_APP FreeLibrary(handle); + #endif // !FLAC_WINDOWS_APP return 1; } @@ -139,7 +155,9 @@ int get_utf8_argv(int *argc, char ***argv) } } +#if !FLAC_WINDOWS_APP FreeLibrary(handle); /* do not free it when wargv or wenv are still in use */ +#endif // !FLAC_WINDOWS_APP if (ret == 0) { *argc = wargc; @@ -160,9 +178,9 @@ HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWO HANDLE handle = INVALID_HANDLE_VALUE; if ((wname = wchar_from_utf8(lpFileName)) != NULL) { -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#if !FLAC_WINDOWS_APP handle = CreateFileW(wname, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); -#else // !WINAPI_PARTITION_DESKTOP +#else // FLAC_WINDOWS_APP CREATEFILE2_EXTENDED_PARAMETERS params; params.dwSize = sizeof(params); params.dwFileAttributes = dwFlagsAndAttributes & 0xFFFF; @@ -171,7 +189,7 @@ HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWO params.lpSecurityAttributes = lpSecurityAttributes; params.hTemplateFile = hTemplateFile; handle = CreateFile2(wname, dwDesiredAccess, dwShareMode, dwCreationDisposition, ¶ms); -#endif // !WINAPI_PARTITION_DESKTOP +#endif // FLAC_WINDOWS_APP free(wname); } @@ -193,19 +211,19 @@ size_t strlen_utf8(const char *str) int win_get_console_width(void) { int width = 80; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#if !FLAC_WINDOWS_APP CONSOLE_SCREEN_BUFFER_INFO csbi; HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); if(hOut != INVALID_HANDLE_VALUE && hOut != NULL) if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0) width = csbi.dwSize.X; -#endif // WINAPI_PARTITION_DESKTOP +#endif // !FLAC_WINDOWS_APP return width; } /* print functions */ -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#if !FLAC_WINDOWS_APP static int wprint_console(FILE *stream, const wchar_t *text, size_t len) { DWORD out; @@ -235,7 +253,7 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len) return ret; return len; } -#endif // WINAPI_PARTITION_DESKTOP +#endif // !FLAC_WINDOWS_APP int printf_utf8(const char *format, ...) { @@ -276,12 +294,12 @@ int vfprintf_utf8(FILE *stream, const char *format, va_list argptr) ret = -1; break; } -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#if !FLAC_WINDOWS_APP ret = wprint_console(stream, wout, wcslen(wout)); -#else // !WINAPI_PARTITION_DESKTOP +#else // FLAC_WINDOWS_APP OutputDebugStringW(wout); ret = 0; -#endif // !WINAPI_PARTITION_DESKTOP +#endif // FLAC_WINDOWS_APP } while(0); free(utmp); diff --git a/src/test_grabbag/Makefile.am b/src/test_grabbag/Makefile.am index 74e21ce3..ea710091 100644 --- a/src/test_grabbag/Makefile.am +++ b/src/test_grabbag/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/src/test_grabbag/cuesheet/Makefile.am b/src/test_grabbag/cuesheet/Makefile.am index e9d2465a..1cee3707 100644 --- a/src/test_grabbag/cuesheet/Makefile.am +++ b/src/test_grabbag/cuesheet/Makefile.am @@ -1,6 +1,6 @@ # test_cuesheet - Simple tester for cuesheet routines in grabbag # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/test_grabbag/cuesheet/main.c b/src/test_grabbag/cuesheet/main.c index b40ead8b..b3d0e9ab 100644 --- a/src/test_grabbag/cuesheet/main.c +++ b/src/test_grabbag/cuesheet/main.c @@ -1,6 +1,6 @@ /* test_cuesheet - Simple tester for cuesheet routines in grabbag * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_grabbag/picture/Makefile.am b/src/test_grabbag/picture/Makefile.am index 1e336595..45e14571 100644 --- a/src/test_grabbag/picture/Makefile.am +++ b/src/test_grabbag/picture/Makefile.am @@ -1,6 +1,6 @@ # test_picture - Simple tester for picture routines in grabbag # Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/test_grabbag/picture/main.c b/src/test_grabbag/picture/main.c index 6b8b17a2..fe43be94 100644 --- a/src/test_grabbag/picture/main.c +++ b/src/test_grabbag/picture/main.c @@ -1,6 +1,6 @@ /* test_picture - Simple tester for picture routines in grabbag * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/Makefile.am b/src/test_libFLAC++/Makefile.am index a27f1fa7..8bf746f7 100644 --- a/src/test_libFLAC++/Makefile.am +++ b/src/test_libFLAC++/Makefile.am @@ -1,6 +1,6 @@ # test_libFLAC++ - Unit tester for libFLAC++ # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/decoders.cpp b/src/test_libFLAC++/decoders.cpp index 59b746a1..9f375f34 100644 --- a/src/test_libFLAC++/decoders.cpp +++ b/src/test_libFLAC++/decoders.cpp @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/decoders.h b/src/test_libFLAC++/decoders.h index dad7cfad..4bbce132 100644 --- a/src/test_libFLAC++/decoders.h +++ b/src/test_libFLAC++/decoders.h @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/encoders.cpp b/src/test_libFLAC++/encoders.cpp index dd3d1106..0e356afe 100644 --- a/src/test_libFLAC++/encoders.cpp +++ b/src/test_libFLAC++/encoders.cpp @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/encoders.h b/src/test_libFLAC++/encoders.h index c03cbc50..9da415c5 100644 --- a/src/test_libFLAC++/encoders.h +++ b/src/test_libFLAC++/encoders.h @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/main.cpp b/src/test_libFLAC++/main.cpp index 5496250f..7183def7 100644 --- a/src/test_libFLAC++/main.cpp +++ b/src/test_libFLAC++/main.cpp @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/metadata.cpp b/src/test_libFLAC++/metadata.cpp index c4d9bfb0..a31031b6 100644 --- a/src/test_libFLAC++/metadata.cpp +++ b/src/test_libFLAC++/metadata.cpp @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/metadata.h b/src/test_libFLAC++/metadata.h index 7c8ac92b..8c45bc0a 100644 --- a/src/test_libFLAC++/metadata.h +++ b/src/test_libFLAC++/metadata.h @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/metadata_manip.cpp b/src/test_libFLAC++/metadata_manip.cpp index 95fe153f..5d395dbd 100644 --- a/src/test_libFLAC++/metadata_manip.cpp +++ b/src/test_libFLAC++/metadata_manip.cpp @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC++/metadata_object.cpp b/src/test_libFLAC++/metadata_object.cpp index ba7fbe50..ab4cfbfe 100644 --- a/src/test_libFLAC++/metadata_object.cpp +++ b/src/test_libFLAC++/metadata_object.cpp @@ -1,6 +1,6 @@ /* test_libFLAC++ - Unit tester for libFLAC++ * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/Makefile.am b/src/test_libFLAC/Makefile.am index bbbf6c6c..c77f87e8 100644 --- a/src/test_libFLAC/Makefile.am +++ b/src/test_libFLAC/Makefile.am @@ -1,6 +1,6 @@ # test_libFLAC - Unit tester for libFLAC # Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/bitreader.c b/src/test_libFLAC/bitreader.c index bae98675..d40bd1f2 100644 --- a/src/test_libFLAC/bitreader.c +++ b/src/test_libFLAC/bitreader.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/bitreader.h b/src/test_libFLAC/bitreader.h index 1d7c90bc..f497acf6 100644 --- a/src/test_libFLAC/bitreader.h +++ b/src/test_libFLAC/bitreader.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/bitwriter.c b/src/test_libFLAC/bitwriter.c index f3466139..0aafff2f 100644 --- a/src/test_libFLAC/bitwriter.c +++ b/src/test_libFLAC/bitwriter.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/bitwriter.h b/src/test_libFLAC/bitwriter.h index 1e081cf6..9b6a8248 100644 --- a/src/test_libFLAC/bitwriter.h +++ b/src/test_libFLAC/bitwriter.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/crc.c b/src/test_libFLAC/crc.c index 03d9adaf..8b876711 100644 --- a/src/test_libFLAC/crc.c +++ b/src/test_libFLAC/crc.c @@ -1,5 +1,5 @@ /* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2022 Xiph.Org Foundation + * Copyright (C) 2014-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/crc.h b/src/test_libFLAC/crc.h index b4e35276..11523cd8 100644 --- a/src/test_libFLAC/crc.h +++ b/src/test_libFLAC/crc.h @@ -1,5 +1,5 @@ /* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2022 Xiph.Org Foundation + * Copyright (C) 2014-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/decoders.c b/src/test_libFLAC/decoders.c index c353e6fc..ae114ced 100644 --- a/src/test_libFLAC/decoders.c +++ b/src/test_libFLAC/decoders.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/decoders.h b/src/test_libFLAC/decoders.h index d77ae80d..431eb176 100644 --- a/src/test_libFLAC/decoders.h +++ b/src/test_libFLAC/decoders.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/encoders.c b/src/test_libFLAC/encoders.c index 7f6e5ff7..d3fd39dd 100644 --- a/src/test_libFLAC/encoders.c +++ b/src/test_libFLAC/encoders.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/encoders.h b/src/test_libFLAC/encoders.h index 882b34ac..7bdcaf5c 100644 --- a/src/test_libFLAC/encoders.h +++ b/src/test_libFLAC/encoders.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/endswap.c b/src/test_libFLAC/endswap.c index d569197d..808f81f3 100644 --- a/src/test_libFLAC/endswap.c +++ b/src/test_libFLAC/endswap.c @@ -1,5 +1,5 @@ /* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2022 Xiph.Org Foundation + * Copyright (C) 2014-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/endswap.h b/src/test_libFLAC/endswap.h index 1814f628..952b17f0 100644 --- a/src/test_libFLAC/endswap.h +++ b/src/test_libFLAC/endswap.h @@ -1,5 +1,5 @@ /* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2022 Xiph.Org Foundation + * Copyright (C) 2014-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/format.c b/src/test_libFLAC/format.c index 4071b1c4..c5e8bf27 100644 --- a/src/test_libFLAC/format.c +++ b/src/test_libFLAC/format.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +33,7 @@ static struct { FLAC__bool valid; FLAC__bool subset; } SAMPLE_RATES[] = { - { 0 , false, false }, + { 0 , true , true }, { 1 , true , true }, { 9 , true , true }, { 10 , true , true }, diff --git a/src/test_libFLAC/format.h b/src/test_libFLAC/format.h index a37b675c..f78d55df 100644 --- a/src/test_libFLAC/format.h +++ b/src/test_libFLAC/format.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/main.c b/src/test_libFLAC/main.c index f7f3fe52..a4be0fee 100644 --- a/src/test_libFLAC/main.c +++ b/src/test_libFLAC/main.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/md5.c b/src/test_libFLAC/md5.c index 39684e56..bac4a74a 100644 --- a/src/test_libFLAC/md5.c +++ b/src/test_libFLAC/md5.c @@ -1,5 +1,5 @@ /* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2022 Xiph.Org Foundation + * Copyright (C) 2014-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/md5.h b/src/test_libFLAC/md5.h index f1aff45f..6863268d 100644 --- a/src/test_libFLAC/md5.h +++ b/src/test_libFLAC/md5.h @@ -1,5 +1,5 @@ /* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2022 Xiph.Org Foundation + * Copyright (C) 2014-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/metadata.c b/src/test_libFLAC/metadata.c index 143ded46..0347f6d2 100644 --- a/src/test_libFLAC/metadata.c +++ b/src/test_libFLAC/metadata.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/metadata.h b/src/test_libFLAC/metadata.h index 809e9801..51bdf7aa 100644 --- a/src/test_libFLAC/metadata.h +++ b/src/test_libFLAC/metadata.h @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/metadata_manip.c b/src/test_libFLAC/metadata_manip.c index 52ce3a75..334dc3ae 100644 --- a/src/test_libFLAC/metadata_manip.c +++ b/src/test_libFLAC/metadata_manip.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libFLAC/metadata_object.c b/src/test_libFLAC/metadata_object.c index a538480c..ea6b69fd 100644 --- a/src/test_libFLAC/metadata_object.c +++ b/src/test_libFLAC/metadata_object.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libs_common/Makefile.am b/src/test_libs_common/Makefile.am index 667734de..30e1f157 100644 --- a/src/test_libs_common/Makefile.am +++ b/src/test_libs_common/Makefile.am @@ -1,6 +1,6 @@ # test_libs_common - Common code to library unit tests # Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/test_libs_common/file_utils_flac.c b/src/test_libs_common/file_utils_flac.c index 4df6a5ff..3cc8c308 100644 --- a/src/test_libs_common/file_utils_flac.c +++ b/src/test_libs_common/file_utils_flac.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_libs_common/metadata_utils.c b/src/test_libs_common/metadata_utils.c index 38fe2aa8..929ca639 100644 --- a/src/test_libs_common/metadata_utils.c +++ b/src/test_libs_common/metadata_utils.c @@ -1,6 +1,6 @@ /* test_libFLAC - Unit tester for libFLAC * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -511,7 +511,8 @@ void mutils__init_metadata_blocks( vorbiscomment->data.vorbis_comment.comments[0].entry = malloc_or_die_(5+1); memcpy(vorbiscomment->data.vorbis_comment.comments[0].entry, "ab=cd", 5+1); vorbiscomment->data.vorbis_comment.comments[1].length = 0; - vorbiscomment->data.vorbis_comment.comments[1].entry = 0; + vorbiscomment->data.vorbis_comment.comments[1].entry = malloc_or_die_(1); + vorbiscomment->data.vorbis_comment.comments[1].entry[0] = '\0'; } cuesheet->is_last = false; diff --git a/src/test_seeking/Makefile.am b/src/test_seeking/Makefile.am index d0ceca7b..9c9b8da8 100644 --- a/src/test_seeking/Makefile.am +++ b/src/test_seeking/Makefile.am @@ -1,6 +1,6 @@ # test_seeking - Seeking tester for libFLAC # Copyright (C) 2004-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c index be50cedd..16ab9f40 100644 --- a/src/test_seeking/main.c +++ b/src/test_seeking/main.c @@ -1,6 +1,6 @@ /* test_seeking - Seeking tester for libFLAC * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/test_streams/Makefile.am b/src/test_streams/Makefile.am index 5dc4a630..9aa4b025 100644 --- a/src/test_streams/Makefile.am +++ b/src/test_streams/Makefile.am @@ -1,6 +1,6 @@ # test_streams - Simple test pattern generator # Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/test_streams/main.c b/src/test_streams/main.c index 886b0249..466bf8ef 100644 --- a/src/test_streams/main.c +++ b/src/test_streams/main.c @@ -1,6 +1,6 @@ /* test_streams - Simple test pattern generator * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am index d609529a..5207b13c 100644 --- a/src/utils/Makefile.am +++ b/src/utils/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/src/utils/flacdiff/Makefile.am b/src/utils/flacdiff/Makefile.am index 2186bff5..b181d980 100644 --- a/src/utils/flacdiff/Makefile.am +++ b/src/utils/flacdiff/Makefile.am @@ -1,6 +1,6 @@ # flacdiff - Displays where two FLAC streams differ # Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/utils/flacdiff/main.cpp b/src/utils/flacdiff/main.cpp index 90322a13..358fe047 100644 --- a/src/utils/flacdiff/main.cpp +++ b/src/utils/flacdiff/main.cpp @@ -1,6 +1,6 @@ /* flacdiff - Displays where two FLAC streams differ * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/src/utils/flactimer/Makefile.am b/src/utils/flactimer/Makefile.am index cd0de169..07378630 100644 --- a/src/utils/flactimer/Makefile.am +++ b/src/utils/flactimer/Makefile.am @@ -1,6 +1,6 @@ # flactimer - Runs a command and prints timing information # Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/src/utils/flactimer/main.cpp b/src/utils/flactimer/main.cpp index dbce469e..120a37ff 100644 --- a/src/utils/flactimer/main.cpp +++ b/src/utils/flactimer/main.cpp @@ -1,6 +1,6 @@ /* flactimer - Runs a command and prints timing information * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2022 Xiph.Org Foundation + * Copyright (C) 2011-2023 Xiph.Org Foundation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/test/Makefile.am b/test/Makefile.am index fb9c430a..2d69fea6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries @@ -49,8 +49,9 @@ endif @echo "----------------" EXTRA_DIST = \ - CMakeLists.txt \ + CMakeLists.txt \ cuesheet.ok \ + generate_streams.sh \ metaflac.flac.in \ metaflac.flac.ok \ picture.ok \ diff --git a/test/abi/abi-descriptor-libFLAC++-1.4.0.xml b/test/abi/abi-descriptor-libFLAC++-1.4.3.xml index 4d19b282..18d6ccdd 100644 --- a/test/abi/abi-descriptor-libFLAC++-1.4.0.xml +++ b/test/abi/abi-descriptor-libFLAC++-1.4.3.xml @@ -1,5 +1,5 @@ <version> - 1.4.0 + 1.4.3 </version> <headers> @@ -7,5 +7,5 @@ </headers> <libs> - src/libFLAC++/.libs/libFLAC++.so.10.0.0 + src/libFLAC++/.libs/libFLAC++.so.10.0.1 </libs> diff --git a/test/abi/abi-descriptor-libFLAC-1.4.0.xml b/test/abi/abi-descriptor-libFLAC-1.4.3.xml index 75f9b75a..1b083862 100644 --- a/test/abi/abi-descriptor-libFLAC-1.4.0.xml +++ b/test/abi/abi-descriptor-libFLAC-1.4.3.xml @@ -1,5 +1,5 @@ <version> - 1.4.0 + 1.4.3 </version> <headers> @@ -7,5 +7,5 @@ </headers> <libs> - src/libFLAC/.libs/libFLAC.so.12.0.0 + src/libFLAC/.libs/libFLAC.so.12.1.0 </libs> diff --git a/test/common.sh.in b/test/common.sh.in index b05c244e..b958f30e 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/cuesheets/Makefile.am b/test/cuesheets/Makefile.am index 959fd0cc..8db5c5fe 100644 --- a/test/cuesheets/Makefile.am +++ b/test/cuesheets/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/flac-to-flac-metadata-test-files/Makefile.am b/test/flac-to-flac-metadata-test-files/Makefile.am index 254ece8e..d76843d1 100644 --- a/test/flac-to-flac-metadata-test-files/Makefile.am +++ b/test/flac-to-flac-metadata-test-files/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/foreign-metadata-test-files/Makefile.am b/test/foreign-metadata-test-files/Makefile.am index 3cca7a96..bdb2ed2d 100644 --- a/test/foreign-metadata-test-files/Makefile.am +++ b/test/foreign-metadata-test-files/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/generate_streams.sh b/test/generate_streams.sh index 62887c01..29e32dcb 100755 --- a/test/generate_streams.sh +++ b/test/generate_streams.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/metaflac-test-files/Makefile.am b/test/metaflac-test-files/Makefile.am index c56ddaf5..6f089610 100644 --- a/test/metaflac-test-files/Makefile.am +++ b/test/metaflac-test-files/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries @@ -81,7 +81,10 @@ EXTRA_DIST = \ case61-expect.meta \ case62-expect.meta \ case63-expect.meta \ - case64-expect.meta + case64-expect.meta \ + case65-expect.meta \ + case66-expect.meta \ + case67-expect.meta clean-local: -rm -f out.* diff --git a/test/metaflac-test-files/case07-expect.meta b/test/metaflac-test-files/case07-expect.meta index 2a025bb5..8e9efd12 100644 --- a/test/metaflac-test-files/case07-expect.meta +++ b/test/metaflac-test-files/case07-expect.meta @@ -1,4 +1,4 @@ -reference libFLAC 1.4.2 20221022 +reference libFLAC 1.4.3 20230623 ARTIST=The_artist_formerly_known_as_the_artist... ARTIST=Chuck_Woolery ARTIST=Vern diff --git a/test/metaflac-test-files/case65-expect.meta b/test/metaflac-test-files/case65-expect.meta Binary files differnew file mode 100644 index 00000000..3f863b17 --- /dev/null +++ b/test/metaflac-test-files/case65-expect.meta diff --git a/test/metaflac-test-files/case66-expect.meta b/test/metaflac-test-files/case66-expect.meta new file mode 100644 index 00000000..9345b158 --- /dev/null +++ b/test/metaflac-test-files/case66-expect.meta @@ -0,0 +1,62 @@ +METADATA block #0 + type: 0 (STREAMINFO) + is last: false + length: 34 + minimum blocksize: 1152 samples + maximum blocksize: 1152 samples + minimum framesize: 11 bytes + maximum framesize: 11 bytes + sample_rate: 44100 Hz + channels: 1 + bits-per-sample: 8 + total samples: 1 + MD5 signature: 8d39dd7eef115ea6975446ef4082951f +METADATA block #1 + type: 3 (SEEKTABLE) + is last: false + length: 18 + seek points: 1 + point 0: sample_number=0, stream_offset=0, frame_samples=1 +METADATA block #2 + type: 4 (VORBIS_COMMENT) + is last: false + length: 46 + vendor string: reference libFLAC 1.0.5_beta2 20030114 + comments: 0 +METADATA block #3 + type: 126 (UNKNOWN) + is last: false + length: 4 + data contents: + 00000000: AA 55 A5 5A 00 00 00 00 00 00 00 00 00 00 00 00 .U.Z +METADATA block #4 + type: 5 (CUESHEET) + is last: false + length: 480 + media catalog number: + lead-in: 88200 + is CD: true + number of tracks: 2 + track[0] + offset: 0 + number: 1 + ISRC: + type: AUDIO + pre-emphasis: false + number of index points: 1 + index[0] + offset: 0 + number: 1 + track[1] + offset: 1 + number: 170 (LEAD-OUT) +METADATA block #5 + type: 2 (APPLICATION) + is last: false + length: 12 + application ID: 61626364 + data contents: +calfflacMETADATA block #6 + type: 1 (PADDING) + is last: true + length: 12 diff --git a/test/metaflac-test-files/case67-expect.meta b/test/metaflac-test-files/case67-expect.meta new file mode 100644 index 00000000..3f6f2179 --- /dev/null +++ b/test/metaflac-test-files/case67-expect.meta @@ -0,0 +1,95 @@ +METADATA block #0 + type: 0 (STREAMINFO) + is last: false + length: 34 + minimum blocksize: 1152 samples + maximum blocksize: 1152 samples + minimum framesize: 11 bytes + maximum framesize: 11 bytes + sample_rate: 44100 Hz + channels: 1 + bits-per-sample: 8 + total samples: 1 + MD5 signature: 8d39dd7eef115ea6975446ef4082951f +METADATA block #1 + type: 126 (UNKNOWN) + is last: false + length: 4 + data contents: + 00000000: AA 55 A5 5A 00 00 00 00 00 00 00 00 00 00 00 00 .U.Z +METADATA block #2 + type: 5 (CUESHEET) + is last: false + length: 480 + media catalog number: + lead-in: 88200 + is CD: true + number of tracks: 2 + track[0] + offset: 0 + number: 1 + ISRC: + type: AUDIO + pre-emphasis: false + number of index points: 1 + index[0] + offset: 0 + number: 1 + track[1] + offset: 1 + number: 170 (LEAD-OUT) +METADATA block #3 + type: 2 (APPLICATION) + is last: false + length: 12 + application ID: 61626364 + data contents: +calfflacMETADATA block #4 + type: 3 (SEEKTABLE) + is last: false + length: 18 + seek points: 1 + point 0: sample_number=0, stream_offset=0, frame_samples=1 +METADATA block #5 + type: 4 (VORBIS_COMMENT) + is last: false + length: 46 + vendor string: reference libFLAC 1.0.5_beta2 20030114 + comments: 0 +METADATA block #6 + type: 126 (UNKNOWN) + is last: false + length: 4 + data contents: + 00000000: AA 55 A5 5A 00 00 00 00 00 00 00 00 00 00 00 00 .U.Z +METADATA block #7 + type: 5 (CUESHEET) + is last: false + length: 480 + media catalog number: + lead-in: 88200 + is CD: true + number of tracks: 2 + track[0] + offset: 0 + number: 1 + ISRC: + type: AUDIO + pre-emphasis: false + number of index points: 1 + index[0] + offset: 0 + number: 1 + track[1] + offset: 1 + number: 170 (LEAD-OUT) +METADATA block #8 + type: 2 (APPLICATION) + is last: false + length: 12 + application ID: 61626364 + data contents: +calfflacMETADATA block #9 + type: 1 (PADDING) + is last: true + length: 28 diff --git a/test/pictures/Makefile.am b/test/pictures/Makefile.am index 4cc3e093..a1bf9e71 100644 --- a/test/pictures/Makefile.am +++ b/test/pictures/Makefile.am @@ -1,6 +1,6 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/test_compression.sh b/test/test_compression.sh index 3972d147..60c23993 100755 --- a/test/test_compression.sh +++ b/test/test_compression.sh @@ -1,7 +1,7 @@ #!/bin/sh -e # FLAC - Free Lossless Audio Codec -# Copyright (C) 2012-2022 Xiph.Org Foundation +# Copyright (C) 2012-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/test_flac.sh b/test/test_flac.sh index befc8dee..df2d10e4 100755 --- a/test/test_flac.sh +++ b/test/test_flac.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries @@ -1092,45 +1092,12 @@ cp shortnoise.raw file0.raw cp shortnoise.raw file1.raw cp shortnoise.raw file2.raw rm -f shortnoise.raw -# create authoritative sector-aligned files for comparison -file0_samples=$(( (short_noise_cdda_samples / 588) * 588)) -file0_remainder=$((short_noise_cdda_samples - file0_samples)) -file1_samples=$(( ( ( file0_remainder + short_noise_cdda_samples ) / 588 ) * 588)) -file1_remainder=$((file0_remainder + short_noise_cdda_samples - file1_samples)) -file1_samples=$((file1_samples - file0_remainder)) -file2_samples=$(( ( ( file1_remainder + short_noise_cdda_samples ) / 588 ) * 588)) -file2_remainder=$(( file1_remainder + short_noise_cdda_samples - file2_samples)) -file2_samples=$((file2_samples - file1_remainder)) -if [ $file2_remainder != '0' ] ; then - file2_samples=$((file2_samples + file2_remainder)) - file2_remainder=$((588 - file2_remainder)) -fi - -dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie -dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie -dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie -cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files" -dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie -dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie -cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files" -dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie -cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files" -rm -f z.raw - -convert_to_wav file0s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE" -convert_to_wav file1s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE" -convert_to_wav file2s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE" - -convert_to_aiff file0s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF" -convert_to_aiff file1s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF" -convert_to_aiff file2s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF" test_multifile () { input_type=$1 streamtype=$2 - sector_align=$3 - encode_options="$4" + encode_options="$3" extra_encode_options="" extra_decode_options="" @@ -1150,10 +1117,6 @@ test_multifile () suffix=flac fi - if [ $sector_align = sector_align ] ; then - encode_options="$encode_options --sector-align" - fi - if [ $input_type = flac ] || [ $input_type = ogg ] ; then CMP=md5cmp else @@ -1165,15 +1128,9 @@ test_multifile () done run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR" run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR" - if [ $sector_align != sector_align ] ; then - for n in 0 1 2 ; do - $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n" - done - else - for n in 0 1 2 ; do - $CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n" - done - fi + for n in 0 1 2 ; do + $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n" + done for n in 0 1 2 ; do rm -f file${n}x.$suffix file${n}x.$input_type done @@ -1186,36 +1143,20 @@ input_types="raw wav aiff flac" #@@@fi for input_type in $input_types ; do echo "Testing multiple $input_type files without verify..." - test_multifile $input_type flac no_sector_align "" + test_multifile $input_type flac "" echo "Testing multiple $input_type files with verify..." - test_multifile $input_type flac no_sector_align "--verify" - - if [ $input_type != flac ] && [ $input_type != ogg ] ; then # --sector-align not supported for FLAC input - echo "Testing multiple $input_type files with --sector-align, without verify..." - test_multifile $input_type flac sector_align "" - - echo "Testing multiple $input_type files with --sector-align, with verify..." - test_multifile $input_type flac sector_align "--verify" - fi + test_multifile $input_type flac "--verify" if [ $has_ogg = yes ] ; then echo "Testing multiple $input_type files with --ogg, without verify..." - test_multifile $input_type ogg no_sector_align "" + test_multifile $input_type ogg "" echo "Testing multiple $input_type files with --ogg, with verify..." - test_multifile $input_type ogg no_sector_align "--verify" - - if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input - echo "Testing multiple $input_type files with --ogg and --sector-align, without verify..." - test_multifile $input_type ogg sector_align "" - - echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..." - test_multifile $input_type ogg sector_align "--verify" - fi + test_multifile $input_type ogg "--verify" echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..." - test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify" + test_multifile $input_type ogg "--serial-number=321 --verify" fi done diff --git a/test/test_grabbag.sh b/test/test_grabbag.sh index b5c6cb62..6f2aca12 100755 --- a/test/test_grabbag.sh +++ b/test/test_grabbag.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/test_libFLAC++.sh b/test/test_libFLAC++.sh index 9ae128e3..089ec165 100755 --- a/test/test_libFLAC++.sh +++ b/test/test_libFLAC++.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/test_libFLAC.sh b/test/test_libFLAC.sh index edef8fd2..a3a1f0e5 100755 --- a/test/test_libFLAC.sh +++ b/test/test_libFLAC.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/test_metaflac.sh b/test/test_metaflac.sh index e150e1bd..b2dbee07 100755 --- a/test/test_metaflac.sh +++ b/test/test_metaflac.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries @@ -30,7 +30,7 @@ if echo a | (grep -E '(a|b)') >/dev/null 2>&1 fi testdir="metaflac-test-files" -flacfile="metaflac.flac" +flacfile="metaflac1.flac" flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable" @@ -69,6 +69,17 @@ run_metaflac_silent () fi } +run_metaflac_to_metaflac_silent () +{ + if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then + echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log + valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 2>/dev/null 4>>test_metaflac.valgrind.log + else + metaflac${EXE} $1 | metaflac${EXE} $2 2>/dev/null + fi +} + + check_flac () { run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2 @@ -113,6 +124,30 @@ metaflac_test () echo OK } +metaflac_test_nofilter () +{ + case="$testdatadir/$1" + desc="$2" + args="$3" + expect="$case-expect.meta" + echo $ECHO_N "test $1: $desc... " $ECHO_C + run_metaflac $args $flacfile > $testdir/out.meta || die "ERROR running metaflac" + diff -w $expect $testdir/out.meta || die "ERROR: metadata does not match expected $expect" + echo OK +} + +metaflac_test_binary () +{ + case="$testdatadir/$1" + desc="$2" + args="$3" + expect="$case-expect.meta" + echo $ECHO_N "test $1: $desc... " $ECHO_C + run_metaflac $args $flacfile > $testdir/out.meta || die "ERROR running metaflac" + cmp $expect $testdir/out.meta || die "ERROR: metadata does not match expected $expect" + echo OK +} + metaflac_test case00 "--list" "--list" metaflac_test case01 "STREAMINFO --show-* shortcuts" " @@ -375,7 +410,11 @@ metaflac_test case63 "--remove-all-tags-except=artist=title" "--list" metaflac_test case64 "--export-tags-to=-" "--export-tags-to=-" metaflac_test case64 "--show-all-tags" "--show-all-tags" +run_flac ${top_srcdir}/test/foreign-metadata-test-files/AIFF-ID3.aiff --keep-foreign-metadata -f -o $flacfile +metaflac_test_binary case65 "--data-format=binary" "--list --data-format=binary-headerless --block-type=APPLICATION:aiff" + # UNKNOWN blocks +flacfile=metaflac2.flac echo $ECHO_N "Testing FLAC file with unknown metadata... " $ECHO_C cp -p ${top_srcdir}/test/metaflac.flac.in $flacfile # remove the VORBIS_COMMENT block so vendor string changes don't interfere with the comparison: @@ -383,4 +422,57 @@ run_metaflac --remove --block-type=VORBIS_COMMENT --dont-use-padding $flacfile cmp $flacfile ${top_srcdir}/test/metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ" echo OK +flacfile=metaflac3.flac +cp -p ${top_srcdir}/test/metaflac.flac.in $flacfile + +flacfile2=metaflac4.flac +cp $flacfile $flacfile2 +run_metaflac --remove-all --dont-use-padding $flacfile + +echo $ECHO_N "Appending a streaminfo metadata block... " $ECHO_C +if run_metaflac_to_metaflac_silent "--list --data-format=binary $flacfile2" "--append $flacfile" ; then + die "ERROR: it should have failed but didn't" +else + echo "OK, it failed as it should" +fi + +echo $ECHO_N "Appending a seektable metadata block... " $ECHO_C +if run_metaflac_to_metaflac_silent "--list --data-format=binary --except-block-type=STREAMINFO $flacfile2" "--append $flacfile" ; then + die "ERROR: it should have failed but didn't" +else + echo "OK, it failed as it should" +fi + +run_metaflac --add-seekpoint=0 $flacfile + +echo $ECHO_N "Appending a vorbis comment metadata block... " $ECHO_C +if run_metaflac_to_metaflac_silent "--list --data-format=binary --block-type=VORBIS_COMMENT $flacfile2" "--append $flacfile" ; then + echo "OK" +else + die "ERROR, couldn't add vorbis comment metadata block" +fi + +echo $ECHO_N "Appending another vorbis comment metadata block... " $ECHO_C +if run_metaflac_to_metaflac_silent "--list --data-format=binary --block-type=VORBIS_COMMENT $flacfile2" "--append $flacfile" ; then + die "ERROR: it should have failed but didn't" +else + echo "OK, it failed as it should" +fi + +if run_metaflac_to_metaflac_silent "--list --data-format=binary --except-block-type=STREAMINFO,SEEKTABLE,VORBIS_COMMENT $flacfile2" "--append $flacfile" ; then + : +else + die "ERROR, couldn't add vorbis comment metadata block" +fi + +metaflac_test_nofilter case66 "--append" "--list" + +if run_metaflac_to_metaflac_silent "--list --data-format=binary --except-block-type=STREAMINFO,SEEKTABLE,VORBIS_COMMENT $flacfile2" "--append --block-number=0 $flacfile" ; then + : +else + die "ERROR, couldn't add vorbis comment metadata block" +fi + +metaflac_test_nofilter case67 "--append --block-number=0" "--list" + rm -f metaflac-test-files/out.meta metaflac-test-files/out1.meta diff --git a/test/test_replaygain.sh b/test/test_replaygain.sh index 02464541..69ed9930 100755 --- a/test/test_replaygain.sh +++ b/test/test_replaygain.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/test_seeking.sh b/test/test_seeking.sh index 21a1fe22..a00e7d1c 100755 --- a/test/test_seeking.sh +++ b/test/test_seeking.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2004-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries diff --git a/test/test_streams.sh b/test/test_streams.sh index 09e86ad8..22dd747d 100755 --- a/test/test_streams.sh +++ b/test/test_streams.sh @@ -2,7 +2,7 @@ # FLAC - Free Lossless Audio Codec # Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2022 Xiph.Org Foundation +# Copyright (C) 2011-2023 Xiph.Org Foundation # # This file is part the FLAC project. FLAC is comprised of several # components distributed under different licenses. The codec libraries |