summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix assertion failure in seek_to_absolute_sample_Martijn van Beurden2022-06-151-16/+10
| | | | | | | | | | On fuzzing the assertion 'decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER' failed. This was because it was possible to get there without having decoded a valid frame yet. The checks are rearranged such that the code past this assertion is only reached after it is made sure a valid frame has been decoded.
* Fix bitreader bug, leaving bitreader in undefined stateMartijn van Beurden2022-06-151-1/+14
| | | | | | | | | | | When a call to read_callback failed in bitreader_read_from_client_ it left the bitreader buffer in a state where the last word was swapped for endianness. While this wasn't ever a problem, recently code was merged that rewound the bitreader in case a bogus frame was found. If this happened, the bitreader buffer would be used in the state where the last word in the buffer was still swapped. This commit restores the last word of the buffer in case the call to the read callback fails
* Fix two timeouts when decoding oggMartijn van Beurden2022-06-151-1/+8
| | | | | | Fuzzing found timeouts occuring when processing garbage input with the decoder trying to decode or seek in it assuming it to be an ogg stream
* Add check for unsigned integer underflow in seeking codeMartijn van Beurden2022-06-151-1/+6
|
* Add 32-bit files to testMartijn van Beurden2022-06-121-3/+109
|
* Add 32-bit encoding, including limiting of residual to 32-bit intMartijn van Beurden2022-06-1212-85/+594
|
* Add 32-bit decoding capabilityMartijn van Beurden2022-06-1211-104/+363
| | | | | | Decoding for 32-bit files is added, including the ability to decode a 33-bit side subframe. However, residuals are assumed to be limited to a 32-bit signed int, the encoder must make sure of this
* Fix fuzzer_decoder timeoutsMartijn van Beurden2022-05-291-3/+8
| | | | | | | | | | | | | | fuzzer_decoder was running into timeouts because it triggered the gap-filling for broken frames with 5*192000 samples and a blocksize of 1, causing the write callback to be called 960000 times. Doing this several times in one file caused a single fuzz run to take > 60 seconds This commit limits the minimum blocksize to 16 samples, and the maximum number of frames emitted to 50 Credit: Oss-Fuzz Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47193
* Close file when stream_encoder init failsMartijn van Beurden2022-05-281-0/+5
|
* Only locally disable signed integer sanitizing on decoder fuzzersMartijn van Beurden2022-05-283-3/+4
| | | | See https://github.com/google/oss-fuzz/pull/7687
* Improve compute_residual_from_qlp_coefficients datapath selectionMartijn van Beurden2022-05-284-2/+32
| | | | | This bases the selection of the datapath on the actual predictor coefficients instead of on the predictor coefficient precision
* Remove Makefile.lite build systemMartijn van Beurden2022-05-2743-1177/+11
|
* Small make distcheck fixesMartijn van Beurden2022-05-271-1/+0
|
* Remove all Visual Studio specific build filesMartijn van Beurden2022-05-2780-10518/+10
|
* Remove all assembler and intrinsics from decoderMartijn van Beurden2022-05-264-1270/+2
| | | | | | | This commit drops all use of assembler and intrinsics from the libFLAC decoder. This is because they are only for 32-bit x86, hard to debug, maintain and fuzz properly, and because the decoder has much greater security risks than the encoder.
* Renable escape coding for fuzzingMartijn van Beurden2022-05-221-2/+4
| | | | | | | | Escape coding has been deprecated since FLAC 1.0.4 (24-Sep-2002), but it is needed for full spec coverage, (as this is a reference implementation after all) so this should be reenabled at some point. For now only enable while fuzzing, so we can get some bugs out first.
* Fix compression of loose mid-side for certain kinds of musicMartijn van Beurden2022-05-211-1/+5
| | | | | | | | | The loose mid-side option only fully evaluates stereo decorrelation once every few frames. However, in case of finding left-side or right-side to be the best option, subsequent frames were coded mid-side, which could be worse off. To not complicate code too much (to make it possible to evaluate only left or right and side frame for example), evaluation of left-side and right-side is completely disabled when loose mid-side is enabled.
* Default to picture type other when unknown picture type is foundMartijn van Beurden2022-05-201-1/+4
| | | | | | | | | When an unknown picture type was found, the resulting type wouldn't occur in the enum, which is undefined behaviour. This commit changes the picture type to 0 (other) when that happens. Credit: Oss-Fuzz Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=46964
* Fix use of undefined valueMartijn van Beurden2022-05-201-1/+2
| | | | | | | | | | | | The mechanism to improve metadata reading added in 0077d3b overrides a FLAC__STREAM_DECODER_ABORTED with FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC causing the decoder to overread a buffer into an uninitialized part. A check is added that ensures searching for frame sync is only set when the decoder is still in a valid state Credit: Oss-Fuzz Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47525
* [CMake] Add /arch:avx2 flag, clarify WITH_SSE2 and WITH_AVX optionsMartijn van Beurden2022-05-201-2/+5
| | | | | | | | | | | Adds /arch:avx2 to the avx2-specific source files. This mirrors the current vcxproj files. While it currently brings no improvements, it might if CPU-specific optimization is left to the compiler instead of with hand-optimized code in the future Also, the exact meaning of options WITH_SSE2 and WITH_AVX is stated, as the first is compile-time only, and the second also has runtime detection
* Fix heap overflow when invalid encoder is used anywayMartijn van Beurden2022-05-191-2/+6
|
* Fix memory leakMartijn van Beurden2022-05-181-2/+7
| | | | | When resetting the decoder, the MD5 buffer wasn't freed but the pointer set to zero anyway.
* Simplify and merge win_utf8 files and remove from DLL interfaceMartijn van Beurden2022-05-1717-225/+142
| | | | | | | | | libFLAC DLLs were exposing windows_unicode_filename.h functions because flac and metaflac needed to set flac_internal_set_utf8_ filenames. Files windows_unicode_filename.{c/h} and win_utf8_io.[c/h] are merged, and all non-utf8 parts are removed. With this commit, the libFLAC DLL interface is the same as the libFLAC interface of shared libraries on other platforms
* Revert part of commit 5df56dbMartijn van Beurden2022-05-162-219/+112
| | | | | | | | | | Commit 5df56db introduced four completely rewritten functions with intrinsics, but it turns out two of them have integers that can overflow. Because those two functions were barely faster than what they replaced, fixing these overflows will probably make the functions slower than what they replaced, so this is reverted. Credit: Oss-Fuzz Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47416
* Add residual limit checkingMartijn van Beurden2022-05-112-4/+21
| | | | | This patch adds a (fast) check in the bitreader to detect overflow of the residual
* Make it possible for fuzzer to disable instruction set optimizationsMartijn van Beurden2022-05-111-2/+39
| | | | This should greatly increase code coverage of the encoder fuzzer
* Check whether verify decoder is still validMartijn van Beurden2022-05-111-1/+7
| | | | | | | | | Errors returned by the verifing decoder were ignored, while an error often invalidates the assumptions the encoder made about the state of the verifying decoder. If an error was ignored, it could be the decoder outputs an (invalid) frame with a different number of channels than the encoder expects. This could cause heap overflows. This commit adds checks for this occuring.
* Fix overflows in fixed_compute_best_predictorMartijn van Beurden2022-05-093-6/+21
| | | | | Credit: Oss-Fuzz Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47187
* Rename FLAC__get_decoder_client_data to ...Martijn van Beurden2022-05-091-5/+5
| | | | | | ... FLAC__stream_decoder_get_client_data. Also the function definition was moved to its 'siblings'. This way, the function fits better in the API with respect to naming.
* Rewrite of fixed_compute_best_predictor functionsMartijn van Beurden2022-05-081-21/+30
| | | | | The code of fixed_compute_best_predictor was presumable once optimized, but it appears a much more readable form is now equally fast or even faster, see https://github.com/xiph/flac/pull/337 for details.
* Fix distcheckMartijn van Beurden2022-05-061-1/+2
|
* Lengthen test_compression.sh material for benchmarking on CIMartijn van Beurden2022-05-031-2/+3
| | | | | This is necessary to compare CI WITH_ASM=1 and WITH_ASM=0 to be able to check whether this switch does anything
* [CMake] Fix ARM64 intrinsics activationMartijn van Beurden2022-05-032-11/+10
| | | | | | | In 95e2c52 the autotools build worked fine, but CMake missed a few defines. Activition of the lpc_compute_residual_from_qlp_coefficients depended on encoder->private_->cpuinfo.use_asm for no reason, so this dependency is removed
* Add --limit-min-bitrate to flac and add test for itMartijn van Beurden2022-05-023-0/+15
|
* Add API functions to limit minimum bitrateMartijn van Beurden2022-05-028-29/+96
| | | | | | | | | | | | | Quite a lot of decoders have trouble streaming or seeking in a file with frames that only consist of constant subframes because of the large difference between the largest and smallest subframe. To remedy this, this commit makes it possible to disable the use of constant subframes for the last subframe in case all others are constant with a new API function. This means the minimum bitrate for a FLAC file encoded with this function used is raised to 1bit/sample (i.e. 48kbit/s for 48kHz material). This commit also adds tests to the test suite
* Replace seek error with handling when hitting EOF while reading frameMartijn van Beurden2022-05-011-2/+8
|
* Fix memory leak in stream_decoder.cMartijn van Beurden2022-04-301-1/+7
| | | | | Memory leaked in case FLAC__stream_encoder_set_metadata was used but subsequent init failed
* Silence a bunch of MSVC warningsMartijn van Beurden2022-04-308-8/+50
| | | See https://github.com/xiph/flac/issues/313
* Fix uclibc buildFabrice Fontaine2022-04-301-6/+5
| | | | | | | | | | | Commit 4fbb6d4f2ecf2a96c17ea9880108409f852c08a9 reverted commit 44036c9a9b45d03373fe90e9c112852bfc054c51 and so broke again the build on uclibc So put back the sys/auxv.h check as well as a getauxval check in a way that doesn't break iOS Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
* Silence oss-fuzz integer overflow warnings in audio data pathMartijn van Beurden2022-04-303-38/+67
| | | | | | | | | | Because fuzzing feeds bogus predictors and residual samples to the decoder, having overflows in certain functions is unavoidable. Also, because the calculated values are audio path only, there is little potential for security problems Should 'fix' the following reports https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44824 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=46964
* Add ARM64 NEON intrinsics lpc_compute_autocorrelation routinesMartijn van Beurden2022-04-294-3/+113
|
* change if checks to ifdefRosen Penev2022-04-291-1/+1
| | | | | | More similar to the rest of the code. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* Adding ARM64 support and optimized Neon implementation (#270)RonenGvili2022-04-296-0/+1273
| | | | Add NEON intrinsics routines for lpc_compute_residual_from_qlp_coefficients and lpc_compute_residual_from_qlp_coefficients_wide
* Speed up intrinsic routines for fixed_compute_best_predictorMartijn van Beurden2022-04-282-225/+390
| | | | | | | New intrinsic routines are added to compute the best fixed predictor. According to my testing, the new routine is about 3 times as fast as the existing routine. This means an overall speedup for preset -2 of about 30% and for preset -0 of about 15% for CDDA
* Rework error handling (#283)Martijn van Beurden2022-04-273-43/+187
| | | | | | This commit reworks the code decoding a frame, to add silence when frames are missing and output silence when something other than the frame header seems corrupted. Tests are added to the test suite for this functionality. Also, decoded values are checked to be within bps
* Fix seeking bugMartijn van Beurden2022-04-271-1/+2
| | | | | | | | | | | Commit 159cd6c introduced a bug that only triggered upon seeking from the start of a headerless FLAC file to the first frame (so really not a seek at all). Furthermore that commit did nothing else in any other circumstance. This commit fixes that, by both fixing the problem and the behaviour the commit mentioned earlier meant to introduce. Co-authored-by: Robert Kausch <robert.kausch@freac.org>
* Enable flac to skip extra STREAMINFO and check number of samplesMartijn van Beurden2022-04-271-0/+19
| | | | | | | | | | | | | This commit fixed problems with two files mentioned here: https://hydrogenaud.io/index.php?topic=121478.msg1004022#msg1004022 The first file was truncated and had no MD5. flac didn't warn about the number of samples not being correct. The second file had corrupted metadata in which flac detected two STREAMINFO blocks, triggering quite odd behaviour. This commit adds checks for the number of samples and skips a STREAMINFO block if it has already received one
* Documentation fixes: preset description and subset blocksizesMartijn van Beurden2022-04-261-4/+6
| | | | | | | | As described in github issue #236, the description of compression presets in flac.sgml wasn't updated. Also, the description of which blocksizes are considered subset has been lagging behind in the manpages as well as the build-in help of FLAC for years, as this was changed back in 2007. This commit fixes those issues
* [CMake] Honor WITH_AVXMartijn van Beurden2022-04-261-28/+36
| | | | Fixes https://github.com/xiph/flac/issues/286
* [CMake] Add check for PPC64, POWER8/9 and vec_doublehMartijn van Beurden2022-04-251-0/+10
| | | | | Add checks for POWER8/9 intrinsics similar to those in autotools to cmake