Commit Graph

4474 Commits

Author SHA1 Message Date
Martijn van Beurden 4d6d8b342f
Speed up set_partitioned_rice_ 2023-03-08 12:26:44 +01:00
Martijn van Beurden e2faeb80ec Check for 0 samples before outputting gnuplot data
Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56339
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56374
2023-03-07 06:49:45 +01:00
Martijn van Beurden 07471c89e7 Swap small and large loop for further speed up in format_input 2023-03-06 11:15:02 +01:00
Martijn van Beurden 724a8aa32e Further speed up format_input for 24-bit PCM by about 25% 2023-03-06 11:15:02 +01:00
Martijn van Beurden 6884355d87 Speed up format_input for 24-bit PCM by 50% 2023-03-06 11:15:02 +01:00
Martijn van Beurden 2b66d94b34 Speed up format_input for 32-bit PCM 2023-03-06 11:15:02 +01:00
Martijn van Beurden 2b84e8593d Write SANE extended zero to remove assert
Simply ignoring this assert (as production code does) results in
an endless loop.

Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56323
2023-03-03 16:35:31 +01:00
Martijn van Beurden fe19b113a9 Fix use of undefined value in flac
Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56327
2023-03-03 16:35:31 +01:00
Martijn van Beurden 3857234f2b Fix memory leak in flac on foreign metadata object
Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56305
2023-03-03 16:35:31 +01:00
Martijn van Beurden 4d21da1183 Add FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2
This function seems to execute twice as fast as
FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42 and
5x as fast as plain C
2023-02-27 17:22:17 +01:00
Martijn van Beurden d24b45515e Add fixed_compute_best_predictor_limit_residual_intrin_sse42
I couldn't find a fixed_compute_best_predictor_wide_intrin_sse42
that was faster than plain C, but I was able to find a working
variant for this function. Execution time is halved.
2023-02-27 17:22:17 +01:00
Martijn van Beurden f6fb70442e Add fixed_compute_best_predictor_wide_intrin_avx2
This function executes twice as fast as plain C, test with Intel
Xeon E-2224G
2023-02-27 17:22:17 +01:00
Martijn van Beurden 3173fc064f Remove fixed_compute_best_predictor_wide_intrin
Profiling revealed that this intrinsic is about 50% slower than
plain C on my Intel Xeon E-2224G.
2023-02-27 17:22:17 +01:00
Martijn van Beurden 2db6c1d138 Fix mistake in use of bitwriter_grow_ 2023-02-26 15:10:10 +01:00
Martijn van Beurden 9f3894f0d5 Change FLAC__bitwriter_write_rice_signed_block for 64-bit words 2023-02-26 15:10:10 +01:00
Martijn van Beurden b698ed45f3 Rewrite FLAC__bitwriter_write_rice_signed_block for 32 bit words
Using a very different approach: instead of trying to write a full
32-bit bitwriter word, a 64-bit buffer is filled, of which the
first 32 bits are copied to the bitwriter as soon as they are
filled. This way, only very large symbols have to be splitted.

This approach is considerably simpler, and the fast path is taken
much more often.
2023-02-26 15:10:10 +01:00
Zhipeng Xue a336ea5264
Fix potential resource leak 2023-02-24 21:58:45 +01:00
Martijn van Beurden 9382c5375b Add checks on re-encoding FLAC
While decoding from FLAC checks for changes no. of channels, bps
and sample rate, re-encoding doesn't. A fuzzer found use of
uninitialized memory because of this. A few checks are added,
although the user isn't warned on a samplerate change.
2023-02-23 06:59:11 +01:00
Martijn van Beurden 14f19cb245 Fix undefined behaviour in chunk size reading 2023-02-23 06:59:11 +01:00
Martijn van Beurden da3254a72a Fix null dereference read 2023-02-23 06:59:11 +01:00
Martijn van Beurden 67a0a153ca Fix oss-build problem and add fuzzer_tool_flac to .gitignore 2023-02-23 06:59:11 +01:00
Jake Schmidt 0408d2518d
In metaflac/usage.c, add missing newlines in the --remove-all-tags-except description 2023-02-22 07:22:28 +01:00
Martijn van Beurden 2d34861226 Fix mistake in preparing for fuzzer_tool_flac 2023-02-22 03:18:20 +01:00
Martijn van Beurden b318f29869 Increase CI-fuzz time spend 2023-02-22 03:18:20 +01:00
Martijn van Beurden 1a8279b7d1 Fix some fuzz finds in grabbag picture code
- Check for chunk length overflow in PNG reading code
- Check for empty file
- Check for empty URL
2023-02-22 03:18:20 +01:00
Martijn van Beurden 21ffc935f0 Add fuzzer for flac command-line tool
Up until now, only libFLAC was being fuzzed. This commit adds a
fuzzer capable of fuzzing most code of the flac executable
2023-02-22 03:18:20 +01:00
Martijn van Beurden d52921bc0b Disable signed int overflow sanitizer in hotspots by default
See https://github.com/xiph/flac/issues/546
2023-02-21 15:56:40 +01:00
Martijn van Beurden 8daf62da0c Rename fuzzer source files to simplify oss-fuzz build script 2023-02-21 15:56:40 +01:00
Martijn van Beurden 3baaf23faa
Add warning that md5 functions are used elsewhere 2023-02-21 08:16:46 +01:00
Martijn van Beurden 771eb050e7 Add tests for foreign metadata handling 2023-02-17 11:06:46 +01:00
Martijn van Beurden 625acf4f37 Document that FLAC pick output format with --keep-foreign-metadata 2023-02-17 11:06:46 +01:00
Martijn van Beurden 285a3f554a Split up writing metadata and comparing metadata into separate steps
For some reason it is possible to read and write in the same file
when opened with fopen mode r+b on linux, but not on MacOS. Reading
and 'verifying' is now split up into two steps, which does work.
Additional benefit is that all foreign metadata is written first,
before verifying, which means as much data as possible is restored.
The error messages also more clearly state whether things went wrong
copying or verifying.
2023-02-17 11:06:46 +01:00
Martijn van Beurden 7ea43e3ba4 Fix some bugs from recent foreign metadata improvements 2023-02-17 11:06:46 +01:00
Martijn van Beurden 92b5292d65 Restore compression type name to AIFF-C from foreign metadata 2023-02-17 11:06:46 +01:00
Martijn van Beurden 692f2ebe93 Add support for decoding to AIFF-C NONE and sowt
Also, add the option to force decoding to WAVE_FORMAT_EXTENSIBLE
2023-02-17 11:06:46 +01:00
Martijn van Beurden a8c20a6af1 Let --keep-foreign-metadata on decode pick the right decode format 2023-02-17 11:06:46 +01:00
Martijn van Beurden a12c6f3236 Add more precise format detection in stored foreign metadata 2023-02-17 11:06:46 +01:00
Martijn van Beurden 1ef4120c93 Check stored foreign metadata chunks
When foreign metadata is being restored, the master chunk and the
format chunk (and similar) are skipped over. This commit adds code
checking whether the stored chunk agrees with what is written.

This will catch cases where a legacy wave format file has been
stored to FLAC with --keep-foreign-metadata, but is being restored
to WAVE_FORMAT_EXTENSIBLE, or AIFF-C to AIFF. Also, it will reveal
when a FLAC file has been changed in length, or had an invalid
format chunk
2023-02-17 11:06:46 +01:00
Martijn van Beurden 3f1f82c8fa
Fix warning in test suite, introduced in a87e6b
Recently a warning was added to libFLAC when RIFF header doesn't
match the filesize. It turns out that warning is trigger by a very
old (harmless) bug in the test suite file generator
2023-02-11 09:42:11 +01:00
Martijn van Beurden aaffdcaa96
Fix running several tests in parallel with CTest
This only fixes CTest, it does not make it possible to run tests
in parallel with make
2023-02-11 09:04:45 +01:00
Martijn van Beurden 748f3938e2
Add warnings for max pathlength 2023-01-29 20:39:43 +01:00
Martijn van Beurden ba5172e554
Remove all PPC-specific code (and a mention of SPARC)
As it turns out that the PPC-specific code provides no benefit with
modern, autovectorizing compilers, and given that there is a lot of
cruft surrounding the PPC-specific parts, remove all of it.

See also https://lists.xiph.org/pipermail/flac-dev/2022-December/006620.html
2023-01-27 19:02:36 +01:00
Martijn van Beurden fe0bf2309a
Lift restrictions on channel mask
See also https://github.com/ietf-wg-cellar/flac-specification/pull/182
2023-01-09 11:00:51 +01:00
Martijn van Beurden 6ea23b0fd3
Remove 'default is signed' mention for raw input 2023-01-09 10:50:40 +01:00
Martijn van Beurden 0a52c6fd5c
Replace own bool with stdbool.h, check for header being available 2023-01-07 09:58:00 +01:00
Martijn van Beurden 2b87e4cd25
Let libFLAC not write a seektable in Ogg, even when asked for
The seektable libFLAC currently writes does not conform to
https://datatracker.ietf.org/doc/draft-ietf-cellar-flac/07/ and
it probably isn't used anywhere, so the code writing it is removed
2023-01-06 19:34:57 +01:00
Martijn van Beurden 8d2830b6a9
Refactor code applying apodization and finding lp_coeffs (#530)
This code was rather hard to read. By separating it from the other
logic steering the lpc subframe evaluation, readability should
improve.
2022-12-31 22:16:01 +01:00
Martijn van Beurden 9b7ca112e9
Fix segfault introduced in commit 3975b3e
A read from the input file was attempted without checking whether
opening it was succesful.
2022-12-02 10:05:45 +01:00
Sam James 7844578995
libFLAC.m4, libFLAC++.m4: fix -Wstrict-prototypes (#521) 2022-11-28 22:13:26 +01:00
Martijn van Beurden c42d4467d5
Remove unused include of safe_str.h 2022-11-28 18:48:12 +01:00