flac.git
2 years agostream_decoder: check state==ABORTED after process_single() for seek
Max Kellermann [Wed, 6 Jul 2016 14:28:53 +0000 (16:28 +0200)]
stream_decoder: check state==ABORTED after process_single() for seek

FLAC__stream_decoder_process_single() ignores frame_sync_() errors,
which means the caller cannot rely solely on the boolean return value,
it is also required to check the new "state".

After FLAC__stream_decoder_process_until_end_of_metadata(),
state==SEARCH_FOR_FRAME_SYNC and
last_frame.header.number_type==FRAME_NUMBER.  When an application
seeks at this time, but an I/O error occurs, then
FLAC__stream_decoder_process_single() returns true, but no frame has
been read yet, i.e. last_frame.header.number_type is still
FRAME_NUMBER.  This triggers the assertion in
seek_to_absolute_sample_():

 FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);

So what needs to be done is check for state==ABORTED after the
FLAC__stream_decoder_process_single() call.

This bug can be triggered remotely with the Music Player Daemon
(https://www.musicpd.org/), and crashes the process.

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

2 years agoflac++.pc.in: Make flac a private requires
Erik de Castro Lopo [Sat, 9 Jul 2016 11:55:07 +0000 (21:55 +1000)]
flac++.pc.in: Make flac a private requires

Patch pulled from Debian package.

Description:
Chain::Status::as_cstring uses FLAC__Metadata_ChainStatusString which
is in libFLAC. Since the function is inline, every program calling
this function must also link with -lflac, but this is missing in
flac++.pc.

Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=713645

2 years agolibFLAC/cpu.c: Fix dfprintf macro for MSVS
Erik de Castro Lopo [Thu, 30 Jun 2016 20:41:18 +0000 (06:41 +1000)]
libFLAC/cpu.c: Fix dfprintf macro for MSVS

2 years agolibFLAC/cpu.c: Add parens to avoid compiler warnings
Erik de Castro Lopo [Mon, 27 Jun 2016 21:12:42 +0000 (07:12 +1000)]
libFLAC/cpu.c: Add parens to avoid compiler warnings

2 years agolibFLAC/cpu.c: Inline *_disable_avx()
Julian Calaby [Mon, 27 Jun 2016 13:22:20 +0000 (23:22 +1000)]
libFLAC/cpu.c: Inline *_disable_avx()

Also only print out OS AVX status if AVX is actually enabled.

2 years agolibFLAC/cpu.c: Move cpu_id_ex into cpu_info_x86()
Julian Calaby [Mon, 27 Jun 2016 12:41:13 +0000 (22:41 +1000)]
libFLAC/cpu.c: Move cpu_id_ex into cpu_info_x86()

This simplifies the C code without complexifying the preprocessor
code.

2 years agolibFLAC/cpu.c: Eliminate a branch in cpu_info_x86
Julian Calaby [Mon, 27 Jun 2016 12:37:45 +0000 (22:37 +1000)]
libFLAC/cpu.c: Eliminate a branch in cpu_info_x86

Inverting all the if statements allows us to move the common code of
setting all the registers to zero outside the #if statement.

2 years agolibFLAC/cpu.c: Remove a layer of cpp conditionals
Julian Calaby [Mon, 27 Jun 2016 12:17:03 +0000 (22:17 +1000)]
libFLAC/cpu.c: Remove a layer of cpp conditionals

2 years agolibFLAC/cpu.c: Drop some unnecessary returns
Julian Calaby [Mon, 27 Jun 2016 12:15:31 +0000 (22:15 +1000)]
libFLAC/cpu.c: Drop some unnecessary returns

2 years agolibFLAC/cpu.c: Get rid of OS_IS_ANDROID function
Julian Calaby [Mon, 27 Jun 2016 12:13:30 +0000 (22:13 +1000)]
libFLAC/cpu.c: Get rid of OS_IS_ANDROID function

2 years agolibFLAC/cpu.c: Move stdio.h include under DEBUG
Julian Calaby [Mon, 27 Jun 2016 12:10:47 +0000 (22:10 +1000)]
libFLAC/cpu.c: Move stdio.h include under DEBUG

2 years agolibFLAC/cpu.c: Use a dummy function for debugging
Julian Calaby [Mon, 27 Jun 2016 12:08:51 +0000 (22:08 +1000)]
libFLAC/cpu.c: Use a dummy function for debugging

This saves 5 if statements that would have had to have been
optimised away.

2 years agolibFLAC/cpu.c: More MSVC fixes
Erik de Castro Lopo [Sun, 26 Jun 2016 19:09:07 +0000 (05:09 +1000)]
libFLAC/cpu.c: More MSVC fixes

With help from lvqcl <lvqcl.mail@gmail.com>

3 years agolibFLAC/cpu.c: Fixes for MSVC
Erik de Castro Lopo [Sun, 26 Jun 2016 11:09:08 +0000 (21:09 +1000)]
libFLAC/cpu.c: Fixes for MSVC

MSVC is strange and perverse.

3 years agolibFLAC/cpu.c: Fix build on non-Intel CPUs
Erik de Castro Lopo [Sun, 26 Jun 2016 07:28:27 +0000 (17:28 +1000)]
libFLAC/cpu.c: Fix build on non-Intel CPUs

3 years agolibFLAC/cpu.c: More cleanup and refactoring
Erik de Castro Lopo [Sun, 26 Jun 2016 02:59:11 +0000 (12:59 +1000)]
libFLAC/cpu.c: More cleanup and refactoring

* Split `FLAC__cpu_info` into CPU specific functions. We now have
  `ia32_cpi_info` and `x86_64_cpu_info` and a simple obvious way
  to add support for other CPUs.
* Improve handling of Android OS.
* Remove more #ifdefs where possible.
* Compile (syntax and type check) DEBUG output code even when debugging
  is disabled.
* Remove build support for ancient NetBSD version 1.5 (version 1.6 was
  released in 2002).

3 years agolibFLAC/cpu.[ch]: More pre-processor cleanups
Erik de Castro Lopo [Sun, 26 Jun 2016 01:32:06 +0000 (11:32 +1000)]
libFLAC/cpu.[ch]: More pre-processor cleanups

3 years agolibFLAC/cpu.c: More refactoring and cleanups
Erik de Castro Lopo [Sun, 26 Jun 2016 00:39:18 +0000 (10:39 +1000)]
libFLAC/cpu.c: More refactoring and cleanups

* Make `FLAC__cpu_xgetbv_x86` private to cpu.c (and rename it to
  `cpu_xgetbv_x86` (it wasn't being used anywhere else).
* Remove `FLAC__cpu_have_cpuid_x86` altogether as it wasn't actually
  being used but that was difficult to tell because of all the #ifdef
  nonsense.

3 years agolibFLAC/cpu.c: More pre-processor cleanups
Erik de Castro Lopo [Sat, 25 Jun 2016 07:02:06 +0000 (17:02 +1000)]
libFLAC/cpu.c: More pre-processor cleanups

3 years agoFix use of FLAC__HAS_X86INTRIN configure variable
Erik de Castro Lopo [Mon, 20 Jun 2016 10:29:59 +0000 (20:29 +1000)]
Fix use of FLAC__HAS_X86INTRIN configure variable

3 years agoFix use of FLAC__SSE_OS configure variable
Erik de Castro Lopo [Sun, 19 Jun 2016 11:51:31 +0000 (21:51 +1000)]
Fix use of FLAC__SSE_OS configure variable

3 years agoFix nasm compile on OS X / Darwin
Erik de Castro Lopo [Mon, 13 Jun 2016 20:27:24 +0000 (06:27 +1000)]
Fix nasm compile on OS X / Darwin

Apparently this had been fixes in Audacity and other projects
but no one had bothered to feed them back upstream. Thanks to
lvqcl for researching this and finding the relevant patches.
Thanks to Ozkan Sezer for validating them.

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

3 years agolibFLAC: More metadata_iterators fixes
Erik de Castro Lopo [Sun, 22 May 2016 01:06:29 +0000 (11:06 +1000)]
libFLAC: More metadata_iterators fixes

The previous fixes for metadata_iterators didn't completely fix the problem.

The behavior of chain_prepare_for_write_() must always be the same as the
behavior of FLAC__metadata_chain_check_if_tempfile_needed(). Before this
fix, one check was missing in FLAC__metadata_chain_check_if_tempfile_needed(),
and also chain_prepare_for_write_() checked the sizes of the metadata blocks
*after* making the changes to the chain, while
FLAC__metadata_chain_check_if_tempfile_needed() does it *before* the changes.

This patch changes FLAC__metadata_chain_check_if_tempfile_needed() so that it
keeps some info (lbs_state, lbs_size) about estimated changes and then uses
it to check the block sizes.

It also simplifies FLAC__metadata_chain_check_if_tempfile_needed() a little.

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

3 years agotest/Makefile.lite: Remove call to old script
Erik de Castro Lopo [Thu, 12 May 2016 20:45:54 +0000 (06:45 +1000)]
test/Makefile.lite: Remove call to old script

3 years agoMakefile.lite: Improved solution to CFLAGS from environment
Erik de Castro Lopo [Wed, 11 May 2016 20:33:22 +0000 (06:33 +1000)]
Makefile.lite: Improved solution to CFLAGS from environment

3 years agoMakefile.lite: Pick up `CFLAGS` from the environment
Erik de Castro Lopo [Thu, 12 May 2016 08:13:22 +0000 (18:13 +1000)]
Makefile.lite: Pick up `CFLAGS` from the environment

This allows extra CFLAGS to be set on the command line. Eg

     CFLAGS=Werror make -f Makefile.lite

3 years agolibFLAC: infer cpu type from compiler macros
Tim Blechmann [Wed, 11 May 2016 12:05:49 +0000 (14:05 +0200)]
libFLAC: infer cpu type from compiler macros

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
3 years agotest_libFLAC++: Fix memory leaks
Erik de Castro Lopo [Sun, 8 May 2016 07:28:56 +0000 (17:28 +1000)]
test_libFLAC++: Fix memory leaks

Memory leaks found using `cppcheck`.

3 years agolibFLAC: Add a workaround for a bug in MSVC2105 update2
Erik de Castro Lopo [Thu, 5 May 2016 07:21:20 +0000 (17:21 +1000)]
libFLAC: Add a workaround for a bug in MSVC2105 update2

MSVC2105 update2 compiles the C code:

    abs_residual_partition_sums[partition] =
                  (FLAC__uint32)_mm_cvtsi128_si32(mm_sum);

into this:

    movq    QWORD PTR [rsi], xmm2

while it should be:

    movd    eax, xmm2
    mov     QWORD PTR [rsi], rax

With this patch, MSVC emits:

    movq    QWORD PTR [rsi], xmm2
    mov     DWORD PTR [rsi+4], r9d

so the price of this workaround is 1 extra write instruction per
partition.

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

3 years agometadata_iterators.c: Limit padding size
Erik de Castro Lopo [Sun, 1 May 2016 10:57:15 +0000 (20:57 +1000)]
metadata_iterators.c: Limit padding size

Without this fix, its possible for libFLAC to create an oversized
padding metadata block when:

a) it merges existing padding blocks

or
b) it expands padding block during metadata changes

resulting in a corrupt FLAC file.

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

3 years agoWindows/MSVC: Add ENABLE_64_BIT_WORDS macro
Erik de Castro Lopo [Sun, 1 May 2016 10:55:10 +0000 (20:55 +1000)]
Windows/MSVC: Add ENABLE_64_BIT_WORDS macro

Allow setting of ENABLE_64_BIT_WORDS preprocessor variable for
libFLAC_dynamic, libFLAC_static and test_libFLAC projects and x64
platform.

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

3 years agobitwrite.c: Tweaks
Erik de Castro Lopo [Sun, 1 May 2016 10:40:24 +0000 (20:40 +1000)]
bitwrite.c: Tweaks

* Removes unused FLAC__WORD_ALL_ONES definition.
* Add comment that unused bits of accumulator can contain garbage.
* Turn assert inside FLAC__bitwriter_write_utf8_uint32 into runtime
  check (similar to FLAC__bitwriter_write_utf8_uint64() function).

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

3 years agolibFLAC: Add metadata size checks to FLAC library
Erik de Castro Lopo [Sun, 1 May 2016 10:34:26 +0000 (20:34 +1000)]
libFLAC: Add metadata size checks to FLAC library

This follows on from the previous patch.

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

3 years agoflac/metaflac: Limit the size of metadata blocks
Erik de Castro Lopo [Sun, 1 May 2016 10:30:37 +0000 (20:30 +1000)]
flac/metaflac: Limit the size of metadata blocks

Limit allow image file size to slightly less than 2^24 bytes so that
the file size plus extra house keeping data is strictly less that
2^24 bytes in size.

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

3 years agoFix 'make distcheck' target
Erik de Castro Lopo [Wed, 27 Apr 2016 00:19:45 +0000 (10:19 +1000)]
Fix 'make distcheck' target

Last commit added a new file which was not added to `EXTRA_DIST`.

3 years agocuesheet.c: Allow quotes around ISRC field
Erik de Castro Lopo [Tue, 26 Apr 2016 07:55:36 +0000 (17:55 +1000)]
cuesheet.c: Allow quotes around ISRC field

With this change, flac now accepts cuesheets where the ISRC field is
enclosed in double quotes. Added a test for this as well.

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

3 years agolibFLAC/stream_decoder.c: Fix typo
Erik de Castro Lopo [Sun, 20 Mar 2016 09:42:27 +0000 (20:42 +1100)]
libFLAC/stream_decoder.c: Fix typo

Introduced in 1be4f9537e.

3 years agoconfigure.ac: Force FLAC__HAS_OGG to 0 or 1
Erik de Castro Lopo [Sun, 20 Mar 2016 09:14:01 +0000 (20:14 +1100)]
configure.ac: Force FLAC__HAS_OGG to 0 or 1

3 years agolibFLAC: Reduce FLAC__HAS_OGG #ifdef crud
Erik de Castro Lopo [Sun, 20 Mar 2016 08:28:41 +0000 (19:28 +1100)]
libFLAC: Reduce FLAC__HAS_OGG #ifdef crud

3 years agolibFLAC/stream_decoder.c: Fix compiling with integer only
Erik de Castro Lopo [Sun, 20 Mar 2016 06:49:39 +0000 (17:49 +1100)]
libFLAC/stream_decoder.c: Fix compiling with integer only

Was failing to compile on IA32 with FLAC__INTEGER_ONLY_LIBRARY
defined.

Reported-by: "Joakim Landberg" <joakim.landberg@intel.com>
3 years agostream_decoder.c: Set obj->num_comments before return
Erik de Castro Lopo [Sun, 20 Mar 2016 04:49:21 +0000 (15:49 +1100)]
stream_decoder.c: Set obj->num_comments before return

Make sure obj-num_comments gets set on failure conditions.

Patch-from: Robert Shih <robertshih@google.com>

3 years agolibFLAC/cpu.c: Use `sigemptyset` instead of `__sigemptyset`
Erik de Castro Lopo [Mon, 14 Mar 2016 07:14:31 +0000 (18:14 +1100)]
libFLAC/cpu.c: Use `sigemptyset` instead of `__sigemptyset`

The former is POSIX while the later is a GNU glibc-ism that does not
exist in (for example) the Musl C library that is used in OpenWrt.

Reported-by: <neheb@hushmail.com>
3 years agoAnother Windows build fix
Erik de Castro Lopo [Thu, 11 Feb 2016 06:52:42 +0000 (17:52 +1100)]
Another Windows build fix

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

3 years agotest/: Remove two redundant scripts
Erik de Castro Lopo [Thu, 11 Feb 2016 06:50:10 +0000 (17:50 +1100)]
test/: Remove two redundant scripts

* test_bin.sh looks like it was a personal use script for the original
  developer Josh Coalson and referenced directories outside the actual
  repository.
* test_wrapper.sh was trivial and un-used.

3 years agoFix autotool warnings
Erik de Castro Lopo [Wed, 10 Feb 2016 10:24:41 +0000 (21:24 +1100)]
Fix autotool warnings

3 years agomicrobench: Add fallback to gettimeofday()
Dave Yeo [Wed, 3 Feb 2016 04:19:59 +0000 (20:19 -0800)]
microbench: Add fallback to gettimeofday()

Some operating systems such as OS/2 don't have any of the CLOCK* API
functions so add gettimeofday() as a fallback.

Signed-off-by: Dave Yeo <dave.r.yeo@gmail.com>
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
3 years agoMore Windows fixes
Erik de Castro Lopo [Tue, 9 Feb 2016 05:56:32 +0000 (16:56 +1100)]
More Windows fixes

These fixes got lost in an earlier commit.

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

3 years agoMore `make distcheck` fixes
Erik de Castro Lopo [Tue, 9 Feb 2016 05:47:30 +0000 (16:47 +1100)]
More `make distcheck` fixes

* Add two missing files to repo.
* Add files to Makefile.am `EXTRA_DIST` list.

3 years agotest_libFLAC: Fix `make distcheck` target
Erik de Castro Lopo [Mon, 8 Feb 2016 20:01:29 +0000 (07:01 +1100)]
test_libFLAC: Fix `make distcheck` target

3 years agoRetire FLAC__float and FLAC__double types
Thomas Zander [Mon, 8 Feb 2016 09:43:37 +0000 (10:43 +0100)]
Retire FLAC__float and FLAC__double types

Usage of internal aliases for float and double do not provide
substantial value. For integer-only libs, the macro
FLAC__INTEGER_ONLY_LIBRARY is used in the appropriate places
already.

Also, adapt copyright messages to include 2016.

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

3 years agoMake AVX and AVX2 instructions a configure option
Dave Yeo [Mon, 25 Jan 2016 06:09:50 +0000 (22:09 -0800)]
Make AVX and AVX2 instructions a configure option

Handy for toolchains or operating systems that don't support AVX or AVX2
like OS/2.

Signed-off-by: Dave Yeo <dave.r.yeo@gmail.com>
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
3 years agolibFLAC: Remove win_utf8_io dependency
Erik de Castro Lopo [Fri, 5 Feb 2016 00:02:44 +0000 (11:02 +1100)]
libFLAC: Remove win_utf8_io dependency

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

3 years agosrc/share/utf8/utf8.c: Windows API usage fixes
Erik de Castro Lopo [Thu, 4 Feb 2016 02:42:33 +0000 (13:42 +1100)]
src/share/utf8/utf8.c: Windows API usage fixes

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

3 years agoRemove src/share/utf8/Makefile.am
Erik de Castro Lopo [Tue, 2 Feb 2016 23:41:53 +0000 (10:41 +1100)]
Remove src/share/utf8/Makefile.am

This file was redundant.

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

3 years agowin_utf8_io: Fix compile error
Erik de Castro Lopo [Mon, 1 Feb 2016 22:33:12 +0000 (09:33 +1100)]
win_utf8_io: Fix compile error

The function `set_filename_utf8` was defined as static, but the
prototype was missing `static`.

3 years agotest_streams: Use fopen instead of flac_fopen
Erik de Castro Lopo [Mon, 1 Feb 2016 22:19:58 +0000 (09:19 +1100)]
test_streams: Use fopen instead of flac_fopen

test_streams doesn't create/open files with non-ascii filenames,
so there's no need in unicode support.

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

3 years agoFix debug build for VS2005
Erik de Castro Lopo [Mon, 1 Feb 2016 22:16:31 +0000 (09:16 +1100)]
Fix debug build for VS2005

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

3 years agoshare/utf8: Add missing check
Erik de Castro Lopo [Sun, 31 Jan 2016 23:58:47 +0000 (10:58 +1100)]
share/utf8: Add missing check

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

3 years agoRefactoring of win_utf8_io
Erik de Castro Lopo [Sun, 31 Jan 2016 01:42:23 +0000 (12:42 +1100)]
Refactoring of win_utf8_io

* Simplifies *print functions.
* Improves file related functions.
* Preparation to move all file related functions into libFLAC.

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

3 years agosrc/share/Makefile.am: Fix EXTRA_DIST
Erik de Castro Lopo [Sun, 31 Jan 2016 01:35:53 +0000 (12:35 +1100)]
src/share/Makefile.am: Fix EXTRA_DIST

* Remove reference to deleted file charsetmap.h.
* Move utf8/iconvert.h from EXTRA_DIST to utf8_libutf8_la_SOURCES.

Reported-by: lvqcl <lvqcl.mail@gmail.com>
3 years agolocale_hack.h: Fix comment
Erik de Castro Lopo [Sat, 30 Jan 2016 22:55:15 +0000 (09:55 +1100)]
locale_hack.h: Fix comment

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

3 years agoRemove plugin_common library from MSVC build
Erik de Castro Lopo [Sat, 30 Jan 2016 22:51:52 +0000 (09:51 +1100)]
Remove plugin_common library from MSVC build

Previously src/plugin_common library was used by FLAC's own Winamp plugin
(MSVC/Windows) and by the XMMS plugin (*nix). The Winamp plugin is long
gone from FLAC tree, so plugin_common is unused on Windows.

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

3 years agoFix dependencies for MSVC
Erik de Castro Lopo [Sat, 30 Jan 2016 22:50:06 +0000 (09:50 +1100)]
Fix dependencies for MSVC

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

3 years agoRemove src/share/utf8/charsetmap.h
Erik de Castro Lopo [Sat, 30 Jan 2016 22:47:30 +0000 (09:47 +1100)]
Remove src/share/utf8/charsetmap.h

It was added in 2002 but is not used anywhere.

Reported-by: lvqcl <lvqcl.mail@gmail.com>
3 years agoWindows/MSVC utf8 build fixes
Erik de Castro Lopo [Thu, 28 Jan 2016 20:39:12 +0000 (07:39 +1100)]
Windows/MSVC utf8 build fixes

Files share/utf8/charset.c and share/utf8/iconvert.c aren't needed
under Windows. This patch removes them from MSVC build system.

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

3 years agomicrobench/util.c: Fix -Wshadow warning
Erik de Castro Lopo [Tue, 26 Jan 2016 05:20:00 +0000 (16:20 +1100)]
microbench/util.c: Fix -Wshadow warning

3 years agoFix ioctl/TIOCGWINSZ for OSX
Erik de Castro Lopo [Tue, 26 Jan 2016 02:35:10 +0000 (13:35 +1100)]
Fix ioctl/TIOCGWINSZ for OSX

3 years agosrc/flac/utils.c: Fix for OpenBSD
Erik de Castro Lopo [Tue, 26 Jan 2016 01:50:44 +0000 (12:50 +1100)]
src/flac/utils.c: Fix for OpenBSD

OpenBSD defineds `TIOCGWINSZ` in `termios.h` which is already being
included, so this fix should work on most POSIX systems.

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

3 years agoautogen.sh: Improve autoconf/automake detection on OpenBSD
Erik de Castro Lopo [Tue, 26 Jan 2016 01:47:58 +0000 (12:47 +1100)]
autogen.sh: Improve autoconf/automake detection on OpenBSD

OpenBSD needs the enviroment variables `AUTOCONF_VERSION` and
`AUTOMAKE_VERSION` to be set in order to find these tools.

The script now tests (individually) if they are already set and if they
aren't sets them to something that is known to work on OpenBSD 5.8

3 years agoconfigure.ac: Drop -Wunreachable-code from CFLAGS
Erik de Castro Lopo [Tue, 26 Jan 2016 01:33:01 +0000 (12:33 +1100)]
configure.ac: Drop -Wunreachable-code from CFLAGS

According to:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46158

this warning was removed in GCC 4.5.

3 years agoconfigure.ac: Remove redundant `XIPH_ADD_CFLAGS([-Wextra])`
Erik de Castro Lopo [Sun, 24 Jan 2016 23:12:33 +0000 (10:12 +1100)]
configure.ac: Remove redundant `XIPH_ADD_CFLAGS([-Wextra])`

3 years agodoc: specify that quantized LPC shift must be non-negative
Tristan Matthews [Sun, 24 Jan 2016 16:41:50 +0000 (11:41 -0500)]
doc: specify that quantized LPC shift must be non-negative

Refs http://sourceforge.net/p/flac/bugs/424/

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
3 years agoFix linking of microbenchmark program
Erik de Castro Lopo [Sat, 23 Jan 2016 21:21:23 +0000 (08:21 +1100)]
Fix linking of microbenchmark program

On some setups, benchmark_residual linkage fails with an undefined
reference to clock_gettime(). Adding -lrt fixes that.

Patch-from: Ozkan Sezer <sezeroz@gmail.com>

3 years agolibFLAC/lpc.c: Fix comments
Erik de Castro Lopo [Sat, 23 Jan 2016 21:12:55 +0000 (08:12 +1100)]
libFLAC/lpc.c: Fix comments

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

3 years agoClean up #includes
Erik de Castro Lopo [Sat, 23 Jan 2016 21:08:50 +0000 (08:08 +1100)]
Clean up #includes

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

3 years agoFix three more cppcheck warnings
Erik de Castro Lopo [Fri, 22 Jan 2016 21:29:32 +0000 (08:29 +1100)]
Fix three more cppcheck warnings

* src/flac/vorbiscomment.c:203: Uninitialized variable: converted.
* src/flac/vorbiscomment.c:210: Uninitialized variable: converted.
* src/test_libFLAC++/decoders.cpp:507: Memory leak: decoder.

3 years agoFix some cppcheck reports
Julien Nabet [Fri, 22 Jan 2016 19:57:24 +0000 (20:57 +0100)]
Fix some cppcheck reports

* src/libFLAC/metadata_iterators.c:3247: (error) va_list `va` was opened
  but not closed with va_end().
* src/share/grabbag/snprintf.c:66: (error) va_list `va` was opened but
  not closed with va_end().
* src/utils/flactimer/main.cpp:84: (warning) Either the condition `!fout`
  is redundant or there is possible null pointer dereference.

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

3 years agomacros.h: Make FLAC_CHECK_RETURN print to stderr
Erik de Castro Lopo [Tue, 19 Jan 2016 07:16:26 +0000 (18:16 +1100)]
macros.h: Make FLAC_CHECK_RETURN print to stderr

Also comment the fact that this macro should only be used for things
that are extremely unlikely to fail.

3 years agograbbag: Fix comment in header
Erik de Castro Lopo [Tue, 19 Jan 2016 07:08:42 +0000 (18:08 +1100)]
grabbag: Fix comment in header

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

3 years agoiffscan: Fix printf format strings
Erik de Castro Lopo [Tue, 19 Jan 2016 07:07:14 +0000 (18:07 +1100)]
iffscan: Fix printf format strings

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

3 years agometadata_iterators.c: Add missing check for is_writable
Erik de Castro Lopo [Fri, 15 Jan 2016 20:57:26 +0000 (07:57 +1100)]
metadata_iterators.c: Add missing check for is_writable

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

3 years agoflacdiff: Improve error msg output
Erik de Castro Lopo [Sun, 10 Jan 2016 02:04:29 +0000 (13:04 +1100)]
flacdiff: Improve error msg output

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

3 years agoFix description of --rice-partition-order in flac -H
Thomas Zander [Sat, 9 Jan 2016 10:27:29 +0000 (11:27 +0100)]
Fix description of --rice-partition-order in flac -H

This is more of a "human language versus programmer parlor" issue.
src/flac/main.c will return usage error for an argument greater
than FLAC__MAX_RICE_PARTITION_ORDER (15u).
While in programming "0..16" usually means "from zero to 15", in
natural human-to-human talk, it would rather mean "from zero to 16".
This changes the wording a bit to avoid this misunderstanding.

Closes: http://sourceforge.net/p/flac/bugs/352/
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
3 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>

3 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/

3 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>

3 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/

3 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

3 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

3 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.

3 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
default.

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

3 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>

3 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>

3 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>

3 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>

3 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>

3 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>

3 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>

3 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>
3 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>