4 years agobitwriter: Add overflow check
Erik de Castro Lopo [Fri, 8 Jan 2016 23:59:41 +0000 (10:59 +1100)]
bitwriter: Add overflow check

The old version of `FLAC__bitwriter_write_raw_uint32()` assumes that the
unused bits of the `val` argument are equal to zero, but don't check it.

This patch adds a new version of that function which does have the check
and then calls a new function `FLAC__bitwriter_write_raw_uint32_nocheck()`
which behaves like the old one.

Code updated to use these two functions as needed.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC: Fix total_samples_estimate
Erik de Castro Lopo [Fri, 8 Jan 2016 23:46:41 +0000 (10:46 +1100)]
libFLAC: Fix total_samples_estimate

See the SF ticket for details.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
Closes: https://sourceforge.net/p/flac/bugs/351/

4 years agoError out when asked to store an picture that is too large
Erik de Castro Lopo [Fri, 8 Jan 2016 23:42:39 +0000 (10:42 +1100)]
Error out when asked to store an picture that is too large

Picture size must be smaller than the maximum block size.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoflac/encode.c: Limit padding size
Erik de Castro Lopo [Fri, 8 Jan 2016 23:35:23 +0000 (10:35 +1100)]
flac/encode.c: Limit padding size

This prevents a too large padding value overflowing the block length.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
Closes: https://sourceforge.net/p/flac/bugs/284/

4 years agochangelog.html: Start on 1.3.2 changelog entry
Erik de Castro Lopo [Fri, 8 Jan 2016 10:33:26 +0000 (21:33 +1100)]
changelog.html: Start on 1.3.2 changelog entry

4 years agoCleanup FLAC__bitmath_silog2()
Thomas Zander [Sun, 3 Jan 2016 18:13:52 +0000 (19:13 +0100)]
Cleanup FLAC__bitmath_silog2()

- Retire 32bit variant of silog2(), since only the _wide variant is used
- Rename FLAC__bitmath_silog2_wide() to FLAC__bitmath_silog2()
- Replace existing implementation by shorter, clearer implementation
  using optimised routines from bitmath.h
- Update Copyright string to 2016 in changed files

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Closes: https://github.com/xiph/flac/pull/6

4 years agoconfigure.ac: Add --enable-64-bit-words option
Erik de Castro Lopo [Mon, 4 Jan 2016 00:29:03 +0000 (11:29 +1100)]
configure.ac: Add --enable-64-bit-words option

The old 32 bit words the default which can be overridded with this
configure option.

4 years agolibFLAC: Support 64bit brword/bwword
Erik de Castro Lopo [Sun, 3 Jan 2016 23:30:54 +0000 (10:30 +1100)]
libFLAC: Support 64bit brword/bwword

This patch allows FLAC__BYTES_PER_WORD to be set to 8, but is disabled by

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC: Tweak MSVC support
Erik de Castro Lopo [Sun, 3 Jan 2016 23:28:49 +0000 (10:28 +1100)]
libFLAC: Tweak MSVC support

Visual Studio 2013 and newer has better support for C99.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agotest_libFLAC/bitwriter.c: Unify with bitwriter.c
Erik de Castro Lopo [Wed, 30 Dec 2015 20:37:09 +0000 (07:37 +1100)]
test_libFLAC/bitwriter.c: Unify with bitwriter.c

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agobitwriter.c: Cleanups and fixups
Erik de Castro Lopo [Wed, 30 Dec 2015 20:32:35 +0000 (07:32 +1100)]
bitwriter.c: Cleanups and fixups

Assertions added, assertions simplified, unnecessary assignments
removed, mask calculations improved.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agobitmath.h: Cleanups
Erik de Castro Lopo [Tue, 29 Dec 2015 10:31:24 +0000 (21:31 +1100)]
bitmath.h: Cleanups

* Drop support from MSVC earlier than 2005.
* Make types of FLAC__clz_uint32() and FLAC__clz_soft_uint32() the same.
* Remove un-needed parens.
* Cleanup FLAC__bitmath_ilog2_wide().

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoCouple of minor tweaks
Erik de Castro Lopo [Tue, 29 Dec 2015 10:17:44 +0000 (21:17 +1100)]
Couple of minor tweaks

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agobitmath.h: Whitespace only
Erik de Castro Lopo [Thu, 24 Dec 2015 22:40:59 +0000 (09:40 +1100)]
bitmath.h: Whitespace only

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoWhitespace only
Erik de Castro Lopo [Thu, 24 Dec 2015 22:39:30 +0000 (09:39 +1100)]
Whitespace only

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoExplicitly use base class virtual methods; silence unnecessary warning
Thomas Zander [Thu, 24 Dec 2015 17:49:26 +0000 (18:49 +0100)]
Explicitly use base class virtual methods; silence unnecessary warning

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agobitwriter.c: Fix undefined behaviour
Erik de Castro Lopo [Sun, 20 Dec 2015 08:40:27 +0000 (19:40 +1100)]
bitwriter.c: Fix undefined behaviour

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agostream_encoder.c: Fix compiler warning
Erik de Castro Lopo [Sun, 13 Dec 2015 00:33:52 +0000 (11:33 +1100)]
stream_encoder.c: Fix compiler warning

Remove incorrect assignment to `encoder->protected_->state`.

4 years agoWin32: Only use large buffers when writing to disk
Erik de Castro Lopo [Fri, 11 Dec 2015 21:23:22 +0000 (08:23 +1100)]
Win32: Only use large buffers when writing to disk

Windows can suffer quite badly from disk fragmentations. To avoid
this, on Windows, the FILE* buffer size was set to 10Meg. However,
this huge buffer is undesireable when writing to a eg a pipe.

This patch updates the behaviour to only use the huge buffer when
writing to disk.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
Closes: https://sourceforge.net/p/flac/feature-requests/114/

4 years agoRemove (defined _MSC_VER) from cpp workaround
Erik de Castro Lopo [Wed, 9 Dec 2015 19:12:08 +0000 (06:12 +1100)]
Remove (defined _MSC_VER) from cpp workaround

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC/stream_encoder.c: Fix overflow in total_error_*
Erik de Castro Lopo [Tue, 24 Nov 2015 18:42:40 +0000 (05:42 +1100)]
libFLAC/stream_encoder.c: Fix overflow in total_error_*

lvqvl found that 32-bit total_error_* variables can overflow when the
right encoding parameters are used. This patch disables them.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC/stream_encoder_intrin_*.c: More refactoring II
Erik de Castro Lopo [Thu, 19 Nov 2015 07:32:31 +0000 (18:32 +1100)]
libFLAC/stream_encoder_intrin_*.c: More refactoring II

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC/stream_encoder_intrin_*.c: More refactoring
Erik de Castro Lopo [Wed, 18 Nov 2015 08:24:44 +0000 (19:24 +1100)]
libFLAC/stream_encoder_intrin_*.c: More refactoring

Combine two intrinsic instructions into one line of code.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC/stream_encoder_intrin_*.c: Refactor abs calculation
Erik de Castro Lopo [Wed, 18 Nov 2015 08:23:02 +0000 (19:23 +1100)]
libFLAC/stream_encoder_intrin_*.c: Refactor abs calculation

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC/cpu.c: Whitespace
Erik de Castro Lopo [Wed, 18 Nov 2015 07:59:26 +0000 (18:59 +1100)]
libFLAC/cpu.c: Whitespace

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC: Fix link error
Erik de Castro Lopo [Fri, 6 Nov 2015 20:06:23 +0000 (07:06 +1100)]
libFLAC: Fix link error

The function FLAC__cpu_xgetbv_x86() is declared and defined only
if FLAC__HAS_X86INTRIN is defined. However FLAC__cpu_info() was
calling it even if FLAC__HAS_X86INTRIN was undefined,

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC: Refactoring
Erik de Castro Lopo [Tue, 3 Nov 2015 07:08:49 +0000 (18:08 +1100)]
libFLAC: Refactoring

No functional changes.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoInclude proper headers for sysctlbyname() on Mac OS
Thomas Zander [Thu, 29 Oct 2015 13:32:03 +0000 (14:32 +0100)]
Include proper headers for sysctlbyname() on Mac OS

According to Xcode documentation[1], sysctlbyname is available on
Mac OS via the same includes as on FreeBSD/DragonFly.

[1] https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/sysctlbyname.3.html

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agoMakefile.lite: Include config.mk from top level build dir
Thomas Zander [Thu, 29 Oct 2015 13:22:12 +0000 (14:22 +0100)]
Makefile.lite: Include config.mk from top level build dir

Makefile.lite in libs/executables subdirs must include
top level's config.mk to allow variables defined there (OS, PROC)
to be used; otherwise e.g. EXPLICIT_LIBS is not set and link
fails on Darwin.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agoMake.lite: Proper detection Darwin/x86_64
Thomas Zander [Thu, 29 Oct 2015 13:18:56 +0000 (14:18 +0100)]
Make.lite: Proper detection Darwin/x86_64

- Use uname -m for Darwin/i386 platform
  (uname -p returns i386 on Mac OS)
- Darwin does have sys/param.h; allow correct flac_min/flac_max macro

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agoFix manpage: synonyms for encoding options -0 .. -8 now match the code
Thomas Zander [Sun, 25 Oct 2015 12:31:23 +0000 (13:31 +0100)]
Fix manpage: synonyms for encoding options -0 .. -8 now match the code

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agostream_encoder.c: Fix subframe_bps comparison
lvqcl [Sun, 11 Oct 2015 21:59:08 +0000 (00:59 +0300)]
stream_encoder.c: Fix subframe_bps comparison

libFLAC limits the value of qlp_coeff_precision to make sure that
32-bit math is enough for decoding of 16-bit audio.

subframe_bps can be equal to 17 for 16-bit input (for side channel)
so the value of subframe_bps should be compared with 17, not 16.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agolibFLAC/cpu.c: Fix un-initialized variable
Erik de Castro Lopo [Tue, 13 Oct 2015 09:20:29 +0000 (20:20 +1100)]
libFLAC/cpu.c: Fix un-initialized variable

Suggested-by: lvqcl <lvqcl.mail@gmail.com>
4 years agoLet Makefile.lite build succeed on FreeBSD amd64
Thomas Zander [Sun, 11 Oct 2015 15:56:13 +0000 (17:56 +0200)]
Let Makefile.lite build succeed on FreeBSD amd64

- build/config.mk: some OS call x86_64 amd64
- build/config.mk: FreeBSD needs -DHAVE_SYS_PARAM_H in CFLAGS
- build/exe.mk and lib.mk: default compilers on FreeBSD are cc/c++
- src/libFLAC++/Makefile.lite: $(OS) is not defined
- src/libFLAC++/Makefile.lite: Link -lstdc++ on FreeBSD

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agoflac: Error out if decoding RAW with bits != (8|16|24)
Erik de Castro Lopo [Sat, 3 Oct 2015 23:52:23 +0000 (10:52 +1100)]
flac: Error out if decoding RAW with bits != (8|16|24)

Suggested by Christopher Key.

Closes: https://sourceforge.net/p/flac/patches/43/

4 years agotest/ : Use more portable echo constructs
Erik de Castro Lopo [Sat, 3 Oct 2015 22:43:33 +0000 (09:43 +1100)]
test/ : Use more portable echo constructs

Fix suggested by Daniel Macks.

Closes: https://sourceforge.net/p/flac/bugs/433/

4 years agomicrobench: remove duplicate define
Tristan Matthews [Tue, 29 Sep 2015 23:27:49 +0000 (19:27 -0400)]
microbench: remove duplicate define

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agomicrobench: add benchmarking code for Darwin
Tristan Matthews [Tue, 29 Sep 2015 23:27:48 +0000 (19:27 -0400)]
microbench: add benchmarking code for Darwin

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agolibFLAC: Fix an out-of-bounds heap read
Erik de Castro Lopo [Fri, 25 Sep 2015 22:17:13 +0000 (08:17 +1000)]
libFLAC: Fix an out-of-bounds heap read

When doing a flac to flac conversion, bad data read from the input file
was making it all the way through the encoder to cause a read past the
end of the buffer in the CRC calculation.

Fix had two parts:

* bitwriter.c: Make a debug only assert (assert bits < 32) into a proper
* stream_encoder.c: Catch the error condition of wasted bits being greater
  that bits_pers_sample and limit it to the bits_per_sample value.

Found using the American Fuzzy Lop fuzzer.

4 years agosrc/flac/encode.c: Fix undefined behaviour
Erik de Castro Lopo [Mon, 7 Sep 2015 05:55:22 +0000 (15:55 +1000)]
src/flac/encode.c: Fix undefined behaviour

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agotest_flac.sh: Test unsigned as well as signed
Erik de Castro Lopo [Mon, 7 Sep 2015 05:21:47 +0000 (15:21 +1000)]
test_flac.sh: Test unsigned as well as signed

4 years agosrc/test_streams: Generate signed and unsigned RAW files
Erik de Castro Lopo [Mon, 7 Sep 2015 02:30:59 +0000 (12:30 +1000)]
src/test_streams: Generate signed and unsigned RAW files

4 years agotest_streams.sh: Improve error message
Erik de Castro Lopo [Wed, 9 Sep 2015 05:49:11 +0000 (15:49 +1000)]
test_streams.sh: Improve error message

4 years agoflac/decode.c: Fix undefined behaviour
Erik de Castro Lopo [Thu, 3 Sep 2015 14:22:18 +0000 (00:22 +1000)]
flac/decode.c: Fix undefined behaviour

4 years agotest_seeking: Fix undefined behaviour
Erik de Castro Lopo [Thu, 3 Sep 2015 04:51:20 +0000 (14:51 +1000)]
test_seeking: Fix undefined behaviour

4 years agomicrobench/util.c: Win32 support
Erik de Castro Lopo [Wed, 2 Sep 2015 06:34:22 +0000 (16:34 +1000)]
microbench/util.c: Win32 support

4 years agomicrobench/Makefile.am: Fix 'make distcheck'
Erik de Castro Lopo [Wed, 2 Sep 2015 06:33:30 +0000 (16:33 +1000)]
microbench/Makefile.am: Fix 'make distcheck'

4 years agoAdd first micro-benchmark
Erik de Castro Lopo [Mon, 31 Aug 2015 17:38:43 +0000 (03:38 +1000)]
Add first micro-benchmark

4 years agolibFLAC++/metadata.cpp: Fix undefined behaviour
Erik de Castro Lopo [Mon, 31 Aug 2015 14:46:32 +0000 (00:46 +1000)]
libFLAC++/metadata.cpp: Fix undefined behaviour

4 years agoMSVC: Fix libFLAC_static.vcxproj dependencies
Erik de Castro Lopo [Mon, 31 Aug 2015 14:21:34 +0000 (00:21 +1000)]
MSVC: Fix libFLAC_static.vcxproj dependencies

libFLAC_static.vcxproj was missing a dependency on win_utf8_io_static.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoflac/encode.c: Fix undefinoed behaviour
Erik de Castro Lopo [Sun, 30 Aug 2015 14:17:03 +0000 (00:17 +1000)]
flac/encode.c: Fix undefinoed behaviour

4 years agolibFLAC/bitwriter.c: Fix undefined behaviour
Erik de Castro Lopo [Sun, 30 Aug 2015 13:54:33 +0000 (23:54 +1000)]
libFLAC/bitwriter.c: Fix undefined behaviour

4 years agolibFLAC/fixed.c: Fix undefined behaviour
Erik de Castro Lopo [Fri, 28 Aug 2015 19:21:43 +0000 (05:21 +1000)]
libFLAC/fixed.c: Fix undefined behaviour

Left shift if a negative integer such that the sign bit is affected is
(according to the C spec) undefined behaviour and the residual
calculations using the shift operator were hitting this.

Fortunately these same calculations using plain multiplication do not
invoke UB and according to benchmarking (on x86_64 linux) have the same
performance as the bit shift version.

4 years agotests: Fix undefined behaviour
Erik de Castro Lopo [Wed, 26 Aug 2015 22:42:23 +0000 (08:42 +1000)]
tests: Fix undefined behaviour

Undefined behaviour in the test support code.

4 years agolibFLAC/format.c: Fix undefined behaviour
Erik de Castro Lopo [Wed, 26 Aug 2015 07:13:39 +0000 (17:13 +1000)]
libFLAC/format.c: Fix undefined behaviour

In the case where seek_table->num_points is zero, seek_table->points
will be NULL and passing that to qsort() invokes undefined behaviour.

Since seek_table->num_points is zero, the only sensible thing to do
is to short circuit return 0.

4 years agolibFLAC/stream_decoder.c: Fix undefined behaviour
Erik de Castro Lopo [Mon, 24 Aug 2015 09:20:35 +0000 (19:20 +1000)]
libFLAC/stream_decoder.c: Fix undefined behaviour

Found by compiling with -fsanitize=undefined and running the testsuite.

4 years agolibFLAC/bitwriter.c: Fix undefined behaviour
Erik de Castro Lopo [Sat, 22 Aug 2015 22:08:27 +0000 (08:08 +1000)]
libFLAC/bitwriter.c: Fix undefined behaviour

Improve folding of signed to unsgned to avoid UB.

4 years agolibFLAC/bitreader.c: Fix undefined behaviour
Erik de Castro Lopo [Sat, 22 Aug 2015 22:05:02 +0000 (08:05 +1000)]
libFLAC/bitreader.c: Fix undefined behaviour

The function FLAC__bitreader_read_raw_int32() triggered undefined behaviour
when sign extending an unsigned value. The Stanford Grahpics bithacks page
provided an alternative that avoided UB.

4 years agolibFLAC/md5.c: Clean up allocation
Erik de Castro Lopo [Sat, 22 Aug 2015 21:37:53 +0000 (07:37 +1000)]
libFLAC/md5.c: Clean up allocation

Make sure ctx->capacity gets updated correctly when safe_realloc()

Patch-from:  lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC: Fix memory leak
Erik de Castro Lopo [Sat, 22 Aug 2015 10:28:44 +0000 (20:28 +1000)]
libFLAC: Fix memory leak

Leak introduced in commit d9ae5e9128. Thanks to lvqcl <lvqcl.mail@gmail.com>
for pointing it out.

4 years agolibFLAC: Add function safe_realloc_()
Erik de Castro Lopo [Sat, 22 Aug 2015 09:22:50 +0000 (19:22 +1000)]
libFLAC: Add function safe_realloc_()

The new function wraps, realloc() and if the realloc() fails, it
free()s the old pointer.

This is an improvement on the potential realloc() memory leak that
was fixed in 15a9062609.

Still needs fuzzing to validate it.

4 years agolibFLAC/stream_decoder: Fix double free
Erik de Castro Lopo [Sat, 22 Aug 2015 06:51:08 +0000 (16:51 +1000)]
libFLAC/stream_decoder: Fix double free

The american-fuzzy-lop fuzzer found a couple of instances of double
free() resulting from commit 15a9062609.

The problematic free() were the ones associated with use of the
safe_realloc_mul_2op_() function which can call realloc(ptr,0) which
according to the realloc manpage is already an implicit free().

4 years agometaflac: add --scan-replay-gain option
Ben Boeckel [Thu, 13 Aug 2015 01:45:04 +0000 (21:45 -0400)]
metaflac: add --scan-replay-gain option

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agolibFLAC: Fix potential meory leaks
Erik de Castro Lopo [Sun, 9 Aug 2015 04:31:57 +0000 (14:31 +1000)]
libFLAC: Fix potential meory leaks

If the `realloc` function failed, memory would leak.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agodecoder: Treat negative qlp_shift as an error
Erik de Castro Lopo [Sat, 8 Aug 2015 22:50:30 +0000 (08:50 +1000)]
decoder: Treat negative qlp_shift as an error

Shift by a negative value is undefined behaviour so there is no "right"
way of dealing with this.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoWindows: Ensure FreeLibrary() calls match LoadLibrary() calls
Erik de Castro Lopo [Sat, 8 Aug 2015 22:45:44 +0000 (08:45 +1000)]
Windows: Ensure FreeLibrary() calls match LoadLibrary() calls

The function get_utf8_argv() was calling LoadLibrary to load msvcrt.dll
but wasn't calling FreeLibrary() if GetProcAddress() fails.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoflac/metaflac: Do case-insensitve comparison of hex values
Erik de Castro Lopo [Sat, 8 Aug 2015 22:43:29 +0000 (08:43 +1000)]
flac/metaflac: Do case-insensitve comparison of hex values

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoCompat: Fix for MSVC deprecated functions
Erik de Castro Lopo [Sat, 8 Aug 2015 22:41:27 +0000 (08:41 +1000)]
Compat: Fix for MSVC deprecated functions

According to MSDN, stricmp and strnicmp functions are deprecated
since MSVC 2005 and _stricmp/_strnicmp should be used instead.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoautogen.sh: Add --no-symlinks option
Erik de Castro Lopo [Sat, 1 Aug 2015 07:54:49 +0000 (17:54 +1000)]
autogen.sh: Add --no-symlinks option

4 years agoautogen.sh: Switch from bash to sh and make it POSIX
Erik de Castro Lopo [Sat, 1 Aug 2015 07:47:06 +0000 (17:47 +1000)]
autogen.sh: Switch from bash to sh and make it POSIX

4 years agolibFLAC: Fix decoder_flush with uninitialized decoder
Erik de Castro Lopo [Mon, 13 Jul 2015 12:15:58 +0000 (22:15 +1000)]
libFLAC: Fix decoder_flush with uninitialized decoder

Closes: https://sourceforge.net/p/flac/bugs/428

4 years agolibFLAC/cpu.c: Assume Android has SSE
Erik de Castro Lopo [Sun, 12 Jul 2015 02:08:18 +0000 (12:08 +1000)]
libFLAC/cpu.c: Assume Android has SSE

According to https://developer.android.com/ndk/guides/abis.html#x86
Android always support SSE, so there's no need to test SSE OS support.

Why both __ANDROID__ and ANDROID are tested:

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoflac/foreign_metadata: Fix for odd RIFF chunk size
Erik de Castro Lopo [Fri, 10 Jul 2015 09:20:24 +0000 (19:20 +1000)]
flac/foreign_metadata: Fix for odd RIFF chunk size

Accept odd values to ckSize of RIFF chunk. FLAC should read these
but should avoid creating them.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
Closes: https://sourceforge.net/p/flac/support-requests/152/
Closes: https://sourceforge.net/p/flac/bugs/419/

4 years agoconfigure.ac : Pass -fno-inline-small-functions when using GCC 4.7
Mario Sanchez Prada [Mon, 8 Jun 2015 16:25:27 +0000 (17:25 +0100)]
configure.ac : Pass -fno-inline-small-functions when using GCC 4.7

For some reason, the build fails when using GCC 4.7 due to the implicit
-finline-functions option passed to the compiler when -O3 is enabled,
which does not happen in newer versions of GCC, probably due to some of
the "General Optimizer Improvements" included in 4.8 (see [1]).

Fortunately, we don't need to disable -finline-functions completely but
just do it for "small functions", which is what this patch does.

[1] https://gcc.gnu.org/gcc-4.8/changes.html

Closes: https://sourceforge.net/p/flac/bugs/429/
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agolibFLAC/metadata_object.c: Assign NULL after free()
Erik de Castro Lopo [Mon, 6 Jul 2015 11:30:55 +0000 (21:30 +1000)]
libFLAC/metadata_object.c: Assign NULL after free()

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC/md5.c: Minor formatting fixes
Erik de Castro Lopo [Mon, 6 Jul 2015 11:29:36 +0000 (21:29 +1000)]
libFLAC/md5.c: Minor formatting fixes

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC: More comment validation
Erik de Castro Lopo [Sun, 5 Jul 2015 11:21:44 +0000 (21:21 +1000)]
libFLAC: More comment validation

When the allocation for obj->comment fails, set obj->num_comments
to zero.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoMakefile.am: Remove old cruft
Erik de Castro Lopo [Sun, 5 Jul 2015 10:59:15 +0000 (20:59 +1000)]
Makefile.am: Remove old cruft

4 years agolibFLAC: Improve fix in bc5113007a
Erik de Castro Lopo [Sun, 5 Jul 2015 10:54:28 +0000 (20:54 +1000)]
libFLAC: Improve fix in bc5113007a

The assert that was removed in bc5113007a, was a result of error
handling in read_metadata_vorbiscomment_() which set obj->num_comments
to zero, without freeing obj->comments and setting it to NULL.

This commit also restores the assert that was removed.

4 years agolibFLAC: Remove un-needed assert
Erik de Castro Lopo [Sat, 4 Jul 2015 06:27:21 +0000 (16:27 +1000)]
libFLAC: Remove un-needed assert

This asset was firing when the build was configured with --enable-debug
and the flac executable was then run under American Fuzzy Lop. Removing
the assert did not cause any other problems, even under AFL.

4 years agoreplaygain: Remove dead assignment
Erik de Castro Lopo [Sat, 4 Jul 2015 02:34:57 +0000 (12:34 +1000)]
replaygain: Remove dead assignment

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agolibFLAC: Remove un-needed test for NULL before free
Erik de Castro Lopo [Sat, 4 Jul 2015 02:19:29 +0000 (12:19 +1000)]
libFLAC: Remove un-needed test for NULL before free

Passing a NULL pointer to free() is a no-op.

4 years agoflac: Fix inlining failure warning
Erik de Castro Lopo [Sat, 4 Jul 2015 01:51:22 +0000 (11:51 +1000)]
flac: Fix inlining failure warning

Also remove related, but old and irrelevant comment.

4 years agograbbag: Replace strncpy with safe_strncpy
Erik de Castro Lopo [Fri, 3 Jul 2015 23:15:24 +0000 (09:15 +1000)]
grabbag: Replace strncpy with safe_strncpy

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoRemove old incorrect comment
Erik de Castro Lopo [Fri, 24 Apr 2015 22:16:27 +0000 (08:16 +1000)]
Remove old incorrect comment

As discussed on the flac-dev mailing list.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoconfigure: Only use -mstackrealign on i686 for mingw32/os2
Tristan Matthews [Sat, 11 Apr 2015 05:05:30 +0000 (01:05 -0400)]
configure: Only use -mstackrealign on i686 for mingw32/os2

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agoconfigure.ac : Add -mstackrealign whenever we add -msse2.
Erik de Castro Lopo [Tue, 31 Mar 2015 07:21:38 +0000 (18:21 +1100)]
configure.ac : Add -mstackrealign whenever we add -msse2.

There have been some (pretty much unconfirmed) reports of problems
with SSE enabled but without this stack alignment flag.

4 years agosrc/libFLAC/lpc.c : Restore missing conditional.
Erik de Castro Lopo [Tue, 31 Mar 2015 07:08:09 +0000 (18:08 +1100)]
src/libFLAC/lpc.c : Restore missing conditional.

Git commit 9c2290ade5 in-correctly removed a conditional around
an fprintf. Thanks to mark4o on #xiph (freenode) for reporting

4 years agoconfigure.ac : Tweak for x32 architecture.
Erik de Castro Lopo [Wed, 11 Mar 2015 09:51:42 +0000 (20:51 +1100)]
configure.ac : Tweak for x32 architecture.

The x32 architecture uses and ILP32 (32 bit ints, longs and pointers)
on an x86_64 CPU. Since the CPU is x86_64 we need to set FLAC__CPU_X86_64
even though the pointer size is 32 bits.

Patch-from: Stuart Shelton
Closes: https://sourceforge.net/p/flac/bugs/427/

4 years agoconfigure.ac : Fix FLAC__HAS_X86INTRIN / FLaC__SSE_OS.
Erik de Castro Lopo [Tue, 24 Feb 2015 19:40:53 +0000 (06:40 +1100)]
configure.ac : Fix FLAC__HAS_X86INTRIN / FLaC__SSE_OS.

* Correct definition of FLAC__HAS_X86INTRIN in config.h file.
* Correct comparison of sse_os with 'true' instead of 'yes'.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agosrc/test_streams/main.c : Use flac_snprintf() instead of snprintf().
Erik de Castro Lopo [Tue, 24 Feb 2015 19:38:04 +0000 (06:38 +1100)]
src/test_streams/main.c : Use flac_snprintf() instead of snprintf().

MSVC doesn't have snprintf().

Patch-from: lvqcl <lvqcl.mail@gmail.com>

4 years agoci/flac-autotool.sh : Test 'distcheck' target instead of 'check'.
Erik de Castro Lopo [Tue, 24 Feb 2015 07:14:12 +0000 (18:14 +1100)]
ci/flac-autotool.sh : Test 'distcheck' target instead of 'check'.

4 years agotest/test_flac.sh : Make it work for 'make distcheck'.
Erik de Castro Lopo [Tue, 24 Feb 2015 07:04:44 +0000 (18:04 +1100)]
test/test_flac.sh : Make it work for 'make distcheck'.

An output file was being set to read only and hence could not be
overwritten by a later test. Not sure why this only affected the
'make distcheck' target.

4 years agoFix cursheet tests for 'make distcheck'.
Erik de Castro Lopo [Mon, 23 Feb 2015 08:42:30 +0000 (19:42 +1100)]
Fix cursheet tests for 'make distcheck'.

4 years agosrc/encode.c : Fix potential infinite loop in flac-toflac encoding.
Erik de Castro Lopo [Sun, 22 Feb 2015 07:05:12 +0000 (18:05 +1100)]
src/encode.c : Fix potential infinite loop in flac-toflac encoding.

A malformed file (generated by AFL) had a 'samples_left_to_process' value
of greater than the actual numbe of samples. When re-encoding the decoder
would get to the end of the file and then continuously return a decode
status of FLAC__STREAM_DECODER_END_OF_STREAM, causing an infinite loop.

Solution is to break out of the loop on two consecutive end-of-stream

4 years agoAdd file ci/flac-autotool.sh.
Erik de Castro Lopo [Fri, 20 Feb 2015 21:47:41 +0000 (08:47 +1100)]
Add file ci/flac-autotool.sh.

Currently only does 'make check' because 'make distcheck' is currently

4 years agolibFLAC/metadata_object.c : Fix typo in comment.
Erik de Castro Lopo [Fri, 20 Feb 2015 20:05:21 +0000 (07:05 +1100)]
libFLAC/metadata_object.c : Fix typo in comment.

4 years agoconfigure.ac : Detect 'amd64' as being same as 'x86_64'.
Christian Weisgerber [Fri, 9 Jan 2015 22:37:37 +0000 (22:37 +0000)]
configure.ac : Detect 'amd64' as being same as 'x86_64'.

On BSD systems, the 64-bit x86 architecture is called "amd64".

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agosrc/libFLAC/stream_decoder.c : Rework fix for seeking bug.
Miroslav Lichvar [Mon, 15 Dec 2014 14:46:12 +0000 (15:46 +0100)]
src/libFLAC/stream_decoder.c : Rework fix for seeking bug.

To avoid crash caused by an unbound LPC decoding when predictor order is
larger than blocksize, the sanity check needs to be moved to the subframe
decoding functions.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
4 years agolibFLAC : Put upper bound on number of seek points.
Erik de Castro Lopo [Wed, 18 Feb 2015 06:55:52 +0000 (17:55 +1100)]
libFLAC : Put upper bound on number of seek points.

Restrict number of seek points to 32768 total and a maximum of two per

Ten hours of content is 36000 seconds which gives about one seek point
for every second for those ten hours. Also, having more than two seek
point per second makes little sense regardless of content length.

Without these restrictions flac-to-flac encoding of a malformed input
file (eg something generated with http://lcamtuf.coredump.cx/afl/)
can result in an attempt to generate a stupidly large number of seek
points and cause an allocation failure.