2 years agogetopt.c: Pointer comparison fix
Erik de Castro Lopo [Tue, 17 Jan 2017 07:28:28 +0000 (18:28 +1100)]
getopt.c: Pointer comparison fix

* Remove <stdint.h> because MSVC 2005 (and probably 2008) don't have it.
* Fix pointer difference caclulation between `nameend` and `nextchar`.

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

2 years agoOnly compile and run tests when running 'make check'
David Seifert [Sun, 15 Jan 2017 09:37:03 +0000 (10:37 +0100)]
Only compile and run tests when running 'make check'

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoFinal unsigned fixes
Erik de Castro Lopo [Mon, 16 Jan 2017 08:31:22 +0000 (19:31 +1100)]
Final unsigned fixes

Found using the Makefile.lite build system.

2 years agoYet more unsigned fixes
Erik de Castro Lopo [Mon, 16 Jan 2017 07:28:31 +0000 (18:28 +1100)]
Yet more unsigned fixes

2 years agobitmath.h: MSVS unsigned fix
Erik de Castro Lopo [Sun, 15 Jan 2017 05:25:40 +0000 (16:25 +1100)]
bitmath.h: MSVS unsigned fix

The orignal code had `unsigned long` inside `#ifdef MSVC`. It was then changed
to `uint64_t` which was incorrect because on Windows `sizze long == 4`.
Change it now to `uint32_t` which is always correct regardless of OS, compiler
or architecture.

2 years agolibFLAC/cpu.c: Replace memory.h include with string.h
sezero [Sat, 14 Jan 2017 22:56:56 +0000 (01:56 +0300)]
libFLAC/cpu.c: Replace memory.h include with string.h

cpu.c was the only source to use memory.h instead of string.h.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoHonor user's $(htmldir) and do not override GNU defaults for $(docdir)
David Seifert [Fri, 13 Jan 2017 17:42:30 +0000 (18:42 +0100)]
Honor user's $(htmldir) and do not override GNU defaults for $(docdir)

* HTML files should be installed to $(htmldir), and $(docdir) should
  not be changed, as this is a user flag in the GNU conventions.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoWhen using libtool, use LTLIBICONV instead.
David Seifert [Fri, 13 Jan 2017 17:42:31 +0000 (18:42 +0100)]
When using libtool, use LTLIBICONV instead.

* This is required, as otherwise -Wl,--as-needed could fail.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoMake building/installing examples optional
David Seifert [Fri, 13 Jan 2017 17:42:29 +0000 (18:42 +0100)]
Make building/installing examples optional

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agobitmath.h: More unsigned fixes
Erik de Castro Lopo [Sun, 15 Jan 2017 01:20:52 +0000 (12:20 +1100)]
bitmath.h: More unsigned fixes

2 years agoYet more purging of `unsigned` type
Erik de Castro Lopo [Sat, 14 Jan 2017 19:47:51 +0000 (06:47 +1100)]
Yet more purging of `unsigned` type

2 years agoinclude/FLAC: More unsigned fixes
Erik de Castro Lopo [Sat, 14 Jan 2017 09:02:15 +0000 (20:02 +1100)]
include/FLAC: More unsigned fixes

These fixes are in the public API, but FLAC would have been extremely
unlikely to work in any system where `unsigned` was not 32 bits.
Therefore we do not treat this as an API change.

2 years agoflac/utils.c: Workaround for DJGPP missing wcswidth()
sezero [Fri, 13 Jan 2017 15:20:35 +0000 (18:20 +0300)]
flac/utils.c: Workaround for DJGPP missing wcswidth()

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoSupport nasm coff obj format for djgpp
sezero [Fri, 13 Jan 2017 14:51:06 +0000 (17:51 +0300)]
Support nasm coff obj format for djgpp

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoPurge usage of `unsigned` type
Erik de Castro Lopo [Sat, 14 Jan 2017 06:26:39 +0000 (17:26 +1100)]
Purge usage of `unsigned` type

As pointed out by Ozkan Sezer, on some platforms `int32_t` is actually
a typedef for `long` so `unsigned` cannot be used interchangably with
`FLAC__uint32`. Fix is to switch from `unsigned` to explicit sized ISO
C types defined in <stdint.h>.

2 years agoconfigure.ac: relax linux OS detection
Peter Korsgaard [Mon, 9 Jan 2017 21:19:01 +0000 (22:19 +0100)]
configure.ac: relax linux OS detection

Not all linux hosts match the *-pc-linux-gnu wildcard, causing build
failures for older glibc versions where we need to link with -lrt for
clock_gettime - E.G.:

 - arm-unknown-linux-musleabihf
 - powerpc-unknown-linux-gnuspe
 - bfin-linux-linux-uclibc

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agolibFLAC/cpu.c: Fix build issue on OpenBSD/i386
Erik de Castro Lopo [Fri, 13 Jan 2017 10:30:55 +0000 (21:30 +1100)]
libFLAC/cpu.c: Fix build issue on OpenBSD/i386

Patch-from: Christian Weisgerber <naddy@mips.inka.de>

2 years agostream_encoder.c: Make compression_levels_ array const
Erik de Castro Lopo [Fri, 6 Jan 2017 09:01:18 +0000 (20:01 +1100)]
stream_encoder.c: Make compression_levels_ array const

As pointed out by github user @randomascii, the `compression_levels_`
struct could and should be const.

Closes: https://github.com/xiph/flac/issues/26

2 years agoFix build with MSVC if UNICODE is enabled
Erik de Castro Lopo [Tue, 3 Jan 2017 19:30:42 +0000 (06:30 +1100)]
Fix build with MSVC if UNICODE is enabled

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

2 years agolibFLAC/cpu.c: Fix CPU detecton
Erik de Castro Lopo [Mon, 2 Jan 2017 17:46:20 +0000 (04:46 +1100)]
libFLAC/cpu.c: Fix CPU detecton

Patch-from: Janne Hyv√§rinen <cse@sci.fi>

2 years agoVersion 1.3.2 1.3.2
Erik de Castro Lopo [Sun, 1 Jan 2017 00:54:07 +0000 (11:54 +1100)]
Version 1.3.2

2 years agotest/test_metaflac.sh: Comment only
Erik de Castro Lopo [Sun, 1 Jan 2017 00:52:04 +0000 (11:52 +1100)]
test/test_metaflac.sh: Comment only

2 years agolibFLAC: Remove commented out assert
Erik de Castro Lopo [Sat, 24 Dec 2016 11:05:07 +0000 (22:05 +1100)]
libFLAC: Remove commented out assert

Pointed out by c.helmrich@ecodis.de. It was added during debugging
in commit c06a44969, but was never meant to stay.

2 years agoMakefile.lite: Fix running of tests
Erik de Castro Lopo [Wed, 21 Dec 2016 05:42:15 +0000 (16:42 +1100)]
Makefile.lite: Fix running of tests

* Generate `test/common.sh` from `test/common.sh.in`.
* Move `is_win` setting to `test_common.sh`.

2 years agolibFLAC/cpu.c: Add CPP guard
Erik de Castro Lopo [Wed, 21 Dec 2016 05:16:13 +0000 (16:16 +1100)]
libFLAC/cpu.c: Add CPP guard

2 years agoMore Makefile.lite fixes
Erik de Castro Lopo [Wed, 21 Dec 2016 05:14:46 +0000 (16:14 +1100)]
More Makefile.lite fixes

Patch-from: Robert Kausch <robert.kausch@freac.org>

2 years agoAdd missing files to Makefile.am
Erik de Castro Lopo [Sun, 11 Dec 2016 09:20:47 +0000 (20:20 +1100)]
Add missing files to Makefile.am

2 years agoMakefile.lite fixes
Erik de Castro Lopo [Sun, 11 Dec 2016 09:17:49 +0000 (20:17 +1100)]
Makefile.lite fixes

Patch-from: Robert Kausch <robert.kausch@freac.org>

2 years agoFix PACKAGE_VERSION in MSVC files
Erik de Castro Lopo [Sun, 11 Dec 2016 09:11:58 +0000 (20:11 +1100)]

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

2 years agodoc/html/changelog.html: Add credits
Erik de Castro Lopo [Tue, 6 Dec 2016 19:05:52 +0000 (06:05 +1100)]
doc/html/changelog.html: Add credits

2 years agodoc/html/changelog.html: Add OS/SSE assumptions
Erik de Castro Lopo [Tue, 6 Dec 2016 09:29:15 +0000 (20:29 +1100)]
doc/html/changelog.html: Add OS/SSE assumptions

2 years agodoc/html/changelog.html: More updates for 1.3.2 release
Erik de Castro Lopo [Tue, 6 Dec 2016 09:04:18 +0000 (20:04 +1100)]
doc/html/changelog.html: More updates for 1.3.2 release

2 years agolibFLAC/metadata_object.c: Fix typo in number
Erik de Castro Lopo [Tue, 6 Dec 2016 08:44:37 +0000 (19:44 +1100)]
libFLAC/metadata_object.c: Fix typo in number

As pointed out by Evan Ramos there was typo, `32786` instead of

2 years agolibFLAC/cpu.c: Improve logic
Erik de Castro Lopo [Tue, 6 Dec 2016 08:37:52 +0000 (19:37 +1100)]
libFLAC/cpu.c: Improve logic

Only call `FLAC__cpu_have_cpuid_asm_ia32` if `FLAC__HAS_NASM` is

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

2 years agoUpdate version in MSVS project files
Erik de Castro Lopo [Mon, 5 Dec 2016 08:35:53 +0000 (19:35 +1100)]
Update version in MSVS project files

2 years agoAnother bulk update of copyright dates
Erik de Castro Lopo [Mon, 5 Dec 2016 07:57:47 +0000 (18:57 +1100)]
Another bulk update of copyright dates

2 years agodoc/html/changelog.html: Update for 1.3.2 release
Erik de Castro Lopo [Sun, 4 Dec 2016 19:49:59 +0000 (06:49 +1100)]
doc/html/changelog.html: Update for 1.3.2 release

2 years agoBulk update copyright dates
Erik de Castro Lopo [Sun, 4 Dec 2016 19:35:39 +0000 (06:35 +1100)]
Bulk update copyright dates

2 years agoconfigure.ac: Fix description of --disable-sse
Erik de Castro Lopo [Sun, 4 Dec 2016 18:37:44 +0000 (05:37 +1100)]
configure.ac: Fix description of --disable-sse

2 years agoconfigure.ac: Remove unused config flags
Erik de Castro Lopo [Sun, 4 Dec 2016 18:33:51 +0000 (05:33 +1100)]
configure.ac: Remove unused config flags


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

2 years agovcxproj: Remove unused config flags
Erik de Castro Lopo [Sun, 4 Dec 2016 18:31:24 +0000 (05:31 +1100)]
vcxproj: Remove unused config flags

Specifically, FLAC__NO_SSE_OS and FLAC__SSE_OS.

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

2 years agolibFLAC/cpu.c: Whitespace fixes
Erik de Castro Lopo [Sun, 4 Dec 2016 06:41:40 +0000 (17:41 +1100)]
libFLAC/cpu.c: Whitespace fixes

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

2 years agolibFLAC/cpu.c: Remove OS SSE detection
Erik de Castro Lopo [Sun, 4 Dec 2016 06:36:58 +0000 (17:36 +1100)]
libFLAC/cpu.c: Remove OS SSE detection

Assume that all OSes that are usable today support SSE.

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

2 years agosrc/share/grabbag/seektable.c: Fix typo inside assert
Erik de Castro Lopo [Fri, 2 Dec 2016 07:02:50 +0000 (18:02 +1100)]
src/share/grabbag/seektable.c: Fix typo inside assert

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

2 years agoCorrect additional 'MEATADATA' typos.
Ralph Giles [Thu, 27 Oct 2016 15:47:09 +0000 (08:47 -0700)]
Correct additional 'MEATADATA' typos.

Thanks to Matthew Gregan for the report.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoFlac-in-mp4 draft v0.0.3.
Ralph Giles [Tue, 4 Oct 2016 16:46:26 +0000 (09:46 -0700)]
Flac-in-mp4 draft v0.0.3.

Draft updates in response to feedback from Yusuke Nakamura.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoFlac-in-mp4 draft v0.0.2.
Ralph Giles [Tue, 4 Oct 2016 15:49:09 +0000 (08:49 -0700)]
Flac-in-mp4 draft v0.0.2.

Draft updates in response to feedback from David Evans.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoFlac-in-mp4 draft v0.0.1.
Ralph Giles [Tue, 4 Oct 2016 15:46:00 +0000 (08:46 -0700)]
Flac-in-mp4 draft v0.0.1.

Draft updates in response to feedback from Timothy B. Terriberry
and Jean-Yves Avenard.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agoFlac-in-mp4 draft v0.0.0.
Ralph Giles [Tue, 4 Oct 2016 15:41:07 +0000 (08:41 -0700)]
Flac-in-mp4 draft v0.0.0.

We've been working on a draft spec for encapsulation of FLAC
in the ISO Base Media File Format (mp4). This is the initial
draft created by Monty Montgomery based on Yusuke Nakamura's
Opus-in-mp4 draft.

More details at https://bugzilla.mozilla.org/show_bug.cgi?id=1286097

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agocpu.c: Really fix compiler warnings
Erik de Castro Lopo [Mon, 12 Sep 2016 07:27:03 +0000 (17:27 +1000)]
cpu.c: Really fix compiler warnings

2 years agocpu.c: Fix compiler warning on PowerPC
Erik de Castro Lopo [Sun, 11 Sep 2016 03:35:46 +0000 (13:35 +1000)]
cpu.c: Fix compiler warning on PowerPC

2 years agoFix compiler warning from gcc-6.1.1
Erik de Castro Lopo [Thu, 8 Sep 2016 10:39:16 +0000 (20:39 +1000)]
Fix compiler warning from gcc-6.1.1

2 years agostream_decoder: reset has_seek_table before read_metadata_seektable_()
Max Kellermann [Thu, 14 Jul 2016 08:22:43 +0000 (10:22 +0200)]
stream_decoder: reset has_seek_table before read_metadata_seektable_()

If a seek table has already been read successfully, then the
has_seek_table flag is true.  Now imagine the file comes with another
seek table, which doesn't make sense, but libFLAC accepts it happily.
If reading this second seek table fails (for example allocation
failure), read_metadata_seektable_() returns false, but the
has_seek_table flag is still true.  If the calling application happens
to ignore this failure, and at some point tries to seek, the process
will crash due to NULL pointer dereference.  This would sure be an
application bug that needs to be fixed, but libFLAC's internal state
is inconsistent, so let's fix this up.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agostream_decoder: fix memory leak after seek table read error
Max Kellermann [Thu, 14 Jul 2016 08:06:23 +0000 (10:06 +0200)]
stream_decoder: fix memory leak after seek table read error

When read_metadata_seektable_() fails, the has_seek_table flag is
never set to true, and thus free() is never called.

Example valgrind output:

 11,185,464 bytes in 1 blocks are definitely lost in loss record 62 of 62
    at 0x4C2BC0F: malloc (vg_replace_malloc.c:299)
    by 0x4C2DE6F: realloc (vg_replace_malloc.c:785)
    by 0x40A7880: safe_realloc_ (alloc.h:159)
    by 0x40A7911: safe_realloc_mul_2op_ (alloc.h:205)
    by 0x40AB6B5: read_metadata_seektable_ (stream_decoder.c:1654)
    by 0x40AAB2D: read_metadata_ (stream_decoder.c:1422)
    by 0x40A9C79: FLAC__stream_decoder_process_until_end_of_metadata (stream_decoder.c:1055)

It is easy to craft a FLAC file which leaks megabytes of memory on
every attempt to open the file.

This patch fixes the problem by removing checks which are unnecessary
(and harmful).  Checking the has_seek_table flag is not enough, as
described above.  The NULL check is not harmful, but is not helpful
either, because free(NULL) is documented to be legal.

After running this code block, we're in a well-known safe state, no
matter how inconsistent pointer and flag may have been before, for
whatever reasons.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2 years agolibFLAC: Fix cpuid detecton on old Cyrix CPUs
Erik de Castro Lopo [Wed, 13 Jul 2016 09:45:53 +0000 (19:45 +1000)]
libFLAC: Fix cpuid detecton on old Cyrix CPUs

Some old CPUs (eg Cyrix) set EDX but not ECX when executing CPUID.
One of the solutions is to clear ECX before calling cpuid. From
https://bugzilla.mozilla.org/show_bug.cgi?id=1096651#c9 bug

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

2 years agolibFLAC: Set decoding status if write callback failed
Erik de Castro Lopo [Wed, 13 Jul 2016 09:41:14 +0000 (19:41 +1000)]
libFLAC: Set decoding status if write callback failed

Previously, it the write callback failed the error status
would be set to `FLAC__STREAM_DECODER_READ_FRAME`. Now it

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

2 years agolibFLAC/metadata_object.c: Clean up
Erik de Castro Lopo [Sun, 10 Jul 2016 06:12:32 +0000 (16:12 +1000)]
libFLAC/metadata_object.c: Clean up

* Remove Yoda conditionals.
* Drop some un-needed asserts.

2 years agometadata_object.c: Remove un-needed asserts
Erik de Castro Lopo [Sun, 10 Jul 2016 01:18:34 +0000 (11:18 +1000)]
metadata_object.c: Remove un-needed asserts

These asserts were being triggered by AFL (American Fuzzy Lop) and
serve seemingly no useful purpose. The are only enabled in debug builds
where they abort the program which is otherwise in a safe state.

Removing these asserts will potentially allow AFL to turn up other
problems elsewhere.

2 years agostream_decoder: fix integer underflow due to malformed wasted_bits
Max Kellermann [Fri, 8 Jul 2016 19:29:41 +0000 (21:29 +0200)]
stream_decoder: fix integer underflow due to malformed wasted_bits

It is pretty easy for a malformed FLAC file to underflow the "bps"
variable.  In the debug build, this results in an assertion failure in

    FLAC__ASSERT(bits <= 32);

In non-debug builds, this simply makes
FLAC__bitreader_read_raw_uint32() fail because
bitreader_read_from_client_() doesn't find enough buffer space for
2**32-1 bits.  But since the failing FLAC_ASSERT() is reasonable, this
should be caught in the FLAC__bitreader_read_raw_uint32() caller.

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

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(),
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

 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.

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

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

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>

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

2 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

2 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).

2 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

2 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

2 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

2 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

2 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

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

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

2 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

2 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

2 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

2 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>
2 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`.

2 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] =

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

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

2 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

b) it expands padding block during metadata changes

resulting in a corrupt FLAC file.

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

2 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

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

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

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

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

2 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

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>