Commit Graph

3309 Commits

Author SHA1 Message Date
Erik de Castro Lopo 006b8356d5 Fix all instances of '#if HAVE_CONFIG_H'.
Should be '#ifdef HAVE_CONFIG_H'.

Closes: https://sourceforge.net/p/flac/bugs/410/
2014-03-24 12:06:49 +11:00
Erik de Castro Lopo 49d9d742e2 metadata_object.c : Fix handling of zero length vorbis comment string.
Previously if a zero length string was passed in, the pointer would be
stored regardless of the copy parameter. If the original source pointer
was reassigned to something else bad things could happen.

Closes:  https://sourceforge.net/p/flac/bugs/377/
2014-03-23 21:41:01 +11:00
Erik de Castro Lopo 697dbdee8f Revert "Attempt to fix differences between x86 FPU and SSE calculations."
This reverts commit 70b078cfd5.

The code in the patch we're reverting probably only works for one
compiler and could easily stop working with the next release of
that compiler.
2014-03-23 19:58:44 +11:00
Erik de Castro Lopo 70b078cfd5 Attempt to fix differences between x86 FPU and SSE calculations.
The x86 FPU holds intermediate results in larger registers than what
the SSE unit uses, resulting in slighlty different encodings of audio
data. Attempt to fix this by modifying libFLAC/lpc.c to store calculation
results in a FLAC__read before adding it to a sum.

At the moment this works, but I could easily imagine a new version of
the compiler optimising this store to the FLAC__real away leaving us
in the same situation we have now.

Patch-from: Oliver Stöneberg on sourceforge.net
Closes: https://sourceforge.net/p/flac/bugs/409/
2014-03-21 19:26:08 +11:00
Erik de Castro Lopo bc2b8c6e16 configure.ac : Add -Wunreachable-code to GCC CFLAGS. 2014-03-21 18:52:24 +11:00
Erik de Castro Lopo 95bc23a811 configure.ac : Add AC_PROG_MKDIR_P.
Closes: https://sourceforge.net/p/flac/bugs/404/
2014-03-21 18:27:41 +11:00
Erik de Castro Lopo d7e6d91fba Fix build issue on OSX with GCC 4.2/Xcode.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-21 17:45:21 +11:00
Erik de Castro Lopo cf55fc7bd7 Add a test to validate that FLAC__MD5Final clears the MD5Context.
Closes: https://sourceforge.net/p/flac/bugs/407/
2014-03-15 18:31:00 +11:00
Erik de Castro Lopo 9863998c99 configure.ac : Make --enable-sse the default.
SSE can still be disabled by configuring with --disable-sse but SSE
will be enabled by default.
2014-03-15 16:47:52 +11:00
Erik de Castro Lopo 7e85023c9f Slight improvements to application metadata tests. 2014-03-15 10:45:40 +11:00
Erik de Castro Lopo 99d5154f43 libFLAC/cpu.c : Detect SSE correctly on Windows when compiling with MinGW.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:40:56 +11:00
Erik de Castro Lopo 47bd9964fa stream_encoder/decoder : Comment fixes.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Erik de Castro Lopo f931d13411 libFLAC/format.c : Remove MSVC6 specific hack.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Erik de Castro Lopo bdcbce4bfa lpc_asm.nasm : Whitespace.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Erik de Castro Lopo d36ef6298b Whitespace.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Erik de Castro Lopo 25ac67a5f1 Remove _MSC_VER specific FLAC__I64L definition.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Erik de Castro Lopo 3f3e178cb0 src/test_seeking : Remove un-needed local__strtoull.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Erik de Castro Lopo 4bc1220b32 Move FLAC__STRCASECMP definition to compat.h.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Erik de Castro Lopo f5902a474c Fix pragma warning.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-14 15:33:11 +11:00
Fengwei Yin 7cbecbae9f Using uintptr_t to simplify pointer handling a little bit
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-03-14 15:32:50 +11:00
Martijn van Beurden 163b734010 Repairs test_grabbag.sh
The change from /bin/sh to /bin/bash -e (commit 1d3d50) broke
the cuesheet tests. This should fix it

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-03-14 15:32:39 +11:00
Erik de Castro Lopo 15e28a4b94 src/libFLAC/ : CPU feature detection improvements.
CPU detection used to depend on ASM code. Now CPU features are
also detected when only FLAC__HAS_X86INTRIN is defined.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-03-02 21:36:45 +11:00
Erik de Castro Lopo ace63cc828 stream_encoder.c : ifdef cleanup.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-02-25 18:38:20 +11:00
Erik de Castro Lopo b334fb2a5c Fix typos in comments.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-02-24 21:47:20 +11:00
Erik de Castro Lopo cf0e42ae6e Don't use intrinsics when they are slower.
More thorough en-/decoding tests show that sometimes the functions
that use intrinsics are slower (or not really faster) than old
plain C functions.

After this patch the encoder doesn't use these new functions
when their usefulness is questionable.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-02-24 21:46:05 +11:00
Erik de Castro Lopo 4be8ed8efe src/share/utf8/charset.c : Fix typo in conditional.
Typo in the conditional to check the exit condition in ascii_strcasecmp.
It checks for (!*s1 || !*s1) instead of (!*s1 || !*s2). The typo did
not affect the result of the function as the loop  is exited before
changing s1 or s2 anyway.

The problem was found by cppcheck which is run automatically on the
Debian sources. Results here:
http://cppcheck.sourceforge.net/devinfo/daca2-cppcheck1.63/daca2.html

Patch-from: Robert Kausch <robert.kausch@freac.org>
2014-02-03 18:48:27 +11:00
Erik de Castro Lopo 71c9555366 bitmath.h : Fixes for FLAC__bitmath_ilog2_wide().
Existing version had a number of problems:
1) it didn't compile with MSVS
2) it returned correct results only when compiles with GNUC
3) it mentioned LGPL which isn't good for a BSD-licensed library

LGPL -> BSD issue documented here:
http://lists.xiph.org/pipermail/flac-dev/2013-September/004356.html

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-02-02 10:42:20 +11:00
Erik de Castro Lopo 96011ffa60 src/flac/encode.c : Improve perf of format_input() when compiled with MSVC.
MSVS profiler shows that the encoder spends too much time inside format_input()
when the input is 24-bit. Increases encoding speed:

FLAC -5: from 27.1 to 24.2 seconds
FLAC -8: from 76.2 to 73.1 seconds
(MSVS 2010, 32-bit flac.exe, 24-bit stereo input file)

For GCC compiles the encoding speed remains the same. I suspect that GCC is
smart enough to use strict aliasing rule to optimize the code, and MSVS doesn't
even know about it.

Path-from: lvqcl <lvqcl.mail@gmail.com>
2014-02-02 09:00:32 +11:00
Erik de Castro Lopo 26b9546149 Add sse2 intrinscics code for lpc_restore_signal_...()
The new functions are analogous to FLAC__lpc_restore_signal_asm_ia32_mmx.
FLAC uses them for x86-64 arch and also for ia32 if NASM is not available.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-02-02 08:55:56 +11:00
Erik de Castro Lopo d163ef4567 libFLAC/stream_encoder.c : Fall back to intrinsics if NASM is not available.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-02-01 20:34:55 +11:00
Erik de Castro Lopo 4813311031 src/flac/main.c : Change the default beahviour when compression fails.
Previously the flac executable would return a non-zero exit code when the
output file was bigger than the input file and this could be disabled with
the --no-error-on-compression-fail option.

New beaviour is to print the failure message but return a zero exit code
in the above situation, and only return a non-zero exit code with the
--error--on-compression-fail option. The --no-error-on-compression-fail
command line option has been retained.
2014-02-01 19:52:25 +11:00
Erik de Castro Lopo 37a97a5992 src/flac/encode.c : Improve message when compression fails.
As suggested by Brian Willoughby this is not an "ERROR" but a "FAILURE".
Also list a couple of possible causes of this failure and remove the
suggestion to contact the developers.
2014-02-01 19:42:48 +11:00
Erik de Castro Lopo 8e89bade87 src/flac/main.c : Add --no-error-on-compression-fail to --help output. 2014-02-01 18:04:54 +11:00
Erik de Castro Lopo 59cfca0030 stream_encoder : Remove un-needed conversion from __m128i to FLAC__uint64.
Encoding speed slightly increased (1...2% for FLAC -8).

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-31 20:54:59 +11:00
Erik de Castro Lopo 4618512de2 Add a fast shift for int64 values.
This patch changes the code from:
	(FLAC__int32)(xmm.m128i_i64[0] >> lp_quantization)
into:
	_mm_cvtsi128_si32(_mm_srli_epi64(xmm, lp_quantization));

Encoding of 24-bit .wav files with 32-bit FLAC became noticeably faster.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-31 20:36:23 +11:00
Erik de Castro Lopo a03999f570 lpc_intrin_sse2.c : Add RESIDUAL16_RESULT macro.
RESIDUAL16_RESULT is analogous to the existing RESIDUAL_RESULT macro
and simplifies the code a little.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-30 22:17:08 +11:00
Erik de Castro Lopo 1d920993f1 Remove redundant inline macro def.
The inline macro already exists in include/share/compat.h.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-30 21:57:21 +11:00
Erik de Castro Lopo 57297eea26 Add __INTEL_COMPILER to _MSC_VER #ifdefs.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-30 21:53:41 +11:00
Erik de Castro Lopo d40e986a1e Add FLAC__SSE_SUPPORTED and FLAC__SSE2_SUPPORTED flags.
* Allow compiling using GCC GCC w/o SSE support.
* Allow SSE4.1 intrinsic functions to be enabled.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-30 21:49:55 +11:00
Erik de Castro Lopo c2747bec1c lpc_asm.nasm : More 'mov cl' -> 'mov ecx' fixes.
According to Agner Fog in optimizing_assembly.pdf:

  "... write to a partial register may result in false dependencies
   between instructions, so it is better to avoid it."

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-18 07:55:19 +11:00
Erik de Castro Lopo 7e9278934e libFLAC : Add asm versions for two _wide() functions.
GCC generates slow ia32 code for FLAC__lpc_restore_signal_wide() and
FLAC__lpc_compute_residual_from_qlp_coefficients_wide() so 24-bit
encoding/decoding is slower for GCC compile than for MSVS or ICC
compile. This patch adds ia32 asm versions of these functions.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-07 21:35:08 +11:00
Erik de Castro Lopo 8e4a45ac86 libFLAC/ia32/lpc_asm.nasm : Match calls and returns.
According to Agner Fog, "...you must make sure that all calls
are matched with returns. Never jump out of a subroutine without
a return and never use a return as an indirect jump."

(see paragraph 3.15 in microarchitecture.pdf and
examples 3.5a and 3.5b in optimizing_assembly.pdf)

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-07 21:27:09 +11:00
Erik de Castro Lopo 6cd8b42438 Add FLAC__ prefix to precompute_partition_info_sums....
Most non-static functions have FLAC__ prefix, but they were missing
from the precompute_partition_info_sums_* functions.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-07 21:27:00 +11:00
Erik de Castro Lopo b84f07248e compat.h : Simplify definition of FLAC__U64L.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-01-07 21:26:45 +11:00
Gustavo Zacarias d65ede3e87 Fix Makefile.am altivec logic
Besides SPE (FSL e500v? cores) there are other powerpc processors
that don't support altivec instructions so only enable them when it's
100% sure that the target has it.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2013-12-20 05:57:33 +11:00
Erik de Castro Lopo a6a4b6f205 Detect Clang masquerading as GCC.
Autoconf detects the Clang compiler as GNU GCC (clang sets defines like
__GNUC__ etc) but Clang is *not* completely compatible. If we detect
Clang we set ac_vc_c_compiler_gnu to 'no'.
2013-11-22 18:13:40 +11:00
Erik de Castro Lopo 8e2eea6322 Silence warning message when doxygen disabled. 2013-10-15 18:01:28 +11:00
Erik de Castro Lopo 64f34e6e99 libFLAC/stream_encoder.c : Fix MSVS profiler hot spot.
Patch-from: vqcl <lvqcl.mail@gmail.com>
2013-10-10 21:32:07 +11:00
Erik de Castro Lopo 55049aad8b win_utf8_io_static.vcproj : LF -> CRLF conversion. 2013-10-10 19:22:06 +11:00
Erik de Castro Lopo cf28c0144b Adds use of restrict keyword to improve encoding speed.
Restrict works very poorly in Visual Studio (much slower than without)
so defined flac_restrict in share/compat.h and use that in:

    lpc_compute_residual...()
    lpc_restore_signal...()

As a result, FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41()
offers no advantage for 64-bit compiles and was removed from x86-64 part
of stream_encoder.c

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2013-10-10 18:24:19 +11:00