Commit Graph

3405 Commits

Author SHA1 Message Date
Erik de Castro Lopo
a87019e761 win_utf8_io.c : Fix potential memory leak.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-08-09 13:02:58 +10:00
Erik de Castro Lopo
e0f638faa0 win_utf8_io.c : Use vsnprintf_s instead of vsprintf.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-08-09 13:01:31 +10:00
Erik de Castro Lopo
01d1aa7b54 libFLAC/cpu.c : Refactor disabling SSE into a single function.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-08-09 12:51:35 +10:00
Erik de Castro Lopo
7c66452886 include/share/endswap.h : Improvements to fallthrough ENDSWAP_*.
According to patch author GCC can optimize expressions like
"(a<<8)|(a>>8)", but has problems with "(a<<8)+(a>>8)".

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-08-09 12:49:38 +10:00
Erik de Castro Lopo
e9d805dd43 libFLAC/lpc_intrin_sse.c : New SSE code to calculate autocorrelation.
Accelerate FLAC__lpc_compute_autocorrelation_intrin_sse_lag_NN routines for
AMD and newer Intel CPUs (means Core i aka Nehalem and newer). Unfortunately
it's slower on older Intel CPUs.

According to tests at HA:

    <http://www.hydrogenaud.io/forums/index.php?s=&showtopic=101082&view=findpost&p=870753>

  CPU                 flac -5           flac -8

  Athlon XP           +5 %              +2.4 %
  Athlon 64 X2        +9 %              +4 %
  Core i              +7 %              +1 % ... +2.7 %
  Core 2              ?                 -3.5 %

According to Steam HW survey <http://store.steampowered.com/hwsurvey/>
69% of Steam users have SSE4.2 which means that the new code is faster for
them. There are also AMD users that don't have SSE4.2, so 75% of Steam users
should benefit from this patch.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-08-09 12:49:27 +10:00
Martijn van Beurden
0ae3e4689d Various documentation fixes, merge with website
The html documentation was diff'ed to the current website pages
and all difference were merged into the page they weren't yet
incorporated. This includes lots of small fixes and
improvements.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-08-09 12:23:56 +10:00
Martijn van Beurden
27846708fe Fix bug when using -p switch during compression
When using the -p switch during encoding, the encoder should try
different qlp predictor precision steps. However, some faulty code
was too severely restricting the possible steps. This patch lifts
the restriction to match a restriction coded a little further in
the process. This doesn't make using -p worth your while, but at
least it doesn't create larger files now

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-07-28 21:40:00 +10:00
Erik de Castro Lopo
6a28facd7c libFLAC/cpu.c : Simplify OS SSE support detection.
Simplify the code that tries to detect whether OS supports SSE instructions.

a) Linux: "old" vs "new" sigaction

OBSOLETE_SIGCONTEXT_FLAVOR was disabled in Mar 2007 in commit 1ca3a445f.
According to <http://unixhelp.ed.ac.uk/CGI/man-cgi?sigaction>: "Support for
SA_SIGINFO was added in Linux 2.2" (released in Jan 1999). If noone wants to
use FLAC with Linux kernel 2.0 then it's safe to delete this code.

b) MSVC: try/catch vs. sigill_handler

TRY_CATCH_FLAVOR was enabled in Jan 2009 in commit a832ef32. According to the
comment in cpu.c, "sigill_handler flavor resulted in several crash reports on
win32". Also this sigill_handler flavor is not thread-safe.

c) MinGW: fxsave/fxrestore vs. sigill_handler

The code was added Mar 2014 in commit 99d5154f. It's better to use FXSR flavor
instead of sigill_handler flavor. The reasons are the same as for MSVC.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-28 20:49:17 +10:00
Erik de Castro Lopo
02591f6b4b libFLAC : SSE optimisations.
Add new function:

    FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41()

and rewrite function:

    FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2()

Testing shows noticeable speed increase on Intel Core i3/5/7 (up to 30%
for -8 mode), AMD Athlon64, Phenom, Bulldozer/Piledriver, but no increase
or even very small speed decrease (~2% for -8 mode) on Intel Core2.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-28 20:46:16 +10:00
Erik de Castro Lopo
8ce310dda2 libFLAC/bitreader.c : Remove redundant/incorrect comment.
This comment should have been removed in commit eb0c5a37.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-27 21:24:31 +10:00
Erik de Castro Lopo
36e03def10 libFLAC/bitreader : Remove un-needed FLAC__CPUInfo field from FLAC__BitReader.
In FLAC 1.2.0, a new field 'FLAC__CPUInfo cpu_info' was added to the
FLAC__BitReader struct. It became useless in 1.3.0 because of various
bitreader optimizations.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-27 21:21:50 +10:00
Erik de Castro Lopo
1930ae104c configure.ac : Fix --disable-sse option.
Based on a patch from lvqcl <lvqcl.mail@gmail.com>.
2014-07-27 21:18:13 +10:00
Erik de Castro Lopo
f73c82a73d configure.ac : Erase default -O2 when setting -O3.
Previously CFLAGS had a -O3 at the start and a -O2 at the end. According
to the GCC docs:

    https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Optimize-Options.html

    "If you use multiple -O options, with or without level numbers,
    the last such option is the one that is effective" which means that
    GCC doesn't try to use SIMD to vectorize the code, etc."
2014-07-27 10:24:44 +10:00
Erik de Castro Lopo
221bdc409d configure.ac : Set default CFLAGS to something sensible.
Preserve the CFLAGS value from the time the configure script is run.
2014-07-26 18:24:52 +10:00
Erik de Castro Lopo
865041b7ca flac and metaflac : Don't always call setlocale() in Windows.
Windows (MSVC, MinGW) versions of setlocale don't care about LC_*
environment variables. For example, flac cannot pass the test for
--until and --skip options the script calls it with --skip=0:01.1001
and it expects decimal comma (--skip=0:01,1001) on some locales.

Solve this (on Windows) by calling setlocale(LC_ALL, "") if some
LC_* variable is set to "C".

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-19 18:17:28 +10:00
Erik de Castro Lopo
491475e61a libFLAC/.../crc.h : Remove un-nneded parens in FLAC__CRC16_UPDATE macro.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-19 18:13:17 +10:00
Erik de Castro Lopo
7251201819 flac/main.c : Improved option validation with --force-raw-format.
Patch-from:  lvqcl <lvqcl.mail@gmail.com>
2014-07-13 20:53:19 +10:00
Erik de Castro Lopo
879a0ce2a5 test/test_flac.sh : Add --force-raw-format as needed.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-13 20:38:59 +10:00
Erik de Castro Lopo
b08c520d33 include/share/endswap.h : Fix default ENDSWAP_16.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-13 20:37:00 +10:00
Erik de Castro Lopo
4a63f10f78 build/config.mk : Define CPU_IS_LITTLE_ENDIAN as needed.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-13 20:35:14 +10:00
Erik de Castro Lopo
31948291a2 Makefile.ams: Add MSVS project files to EXTRA_DIST.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-09 19:02:35 +10:00
Erik de Castro Lopo
1988855b82 test_replaygain.sh : Add --force-raw-format option.
This test was failing due to the lack of this option.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-08 21:12:18 +10:00
Erik de Castro Lopo
9443151da3 src/flac/utils.c : Make sure get_console_width() returns value > 0.
Previous version of get_console_width() may return 0 which will result in
a division by 0 in stats_print_name():

	console_width = get_console_width();
	len = strlen_console(name)+2;
	console_chars_left = console_width  - (len % console_width);

Bug-report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739613
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-08 18:25:19 +10:00
Erik de Castro Lopo
d043785d41 Add project files for Visual Studio 2010 and later.
Also allows building for x86-64 Windows.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-06 20:48:53 +10:00
Erik de Castro Lopo
eb0c5a3792 libFLAC : Remove FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap().
This function was un-used because it showed no speed improvement over the
C version. As a result the bitreader_read_from_client_() function can be
made static again.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-06 20:27:31 +10:00
Erik de Castro Lopo
c43691586a libFLAC : Remove FLAC__precompute_partition_info_sums_32bit_asm_ia32_().
This function offer no speed up from the C version of the function and were
commented out after the release of 1.3.0. We will now drop them completely.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-06 20:21:04 +10:00
Miroslav Lichvar
f081524c19 stream_encoder : Improve selection of residual accumulator width
In the precompute_partition_info_sums_ function, instead of selecting
64-bit accumulator when the signal bps is larger than 16, revert to the
original approach based on partition size, but make room for few extra
bits to not overflow with unusual signals where the average residual
magnitude may be larger than bps.

It slightly improves the performance with standard encoding levels and
16-bit files as the 17-bit side channel can still be processed with the
32-bit accumulator and correctly selects the 64-bit accumulator with
very large 16-bit partitions.

This is related to commits 6f7ec60c and 187e596e.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-07-04 21:22:44 +10:00
Erik de Castro Lopo
71246dcc81 test_libFLAC/test_libFLAC.vcproj : One more CPU_IS_LITTLE_ENDIAN fix.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-04 09:02:21 +10:00
Erik de Castro Lopo
5e8854fa84 src/ : Remove un-needed MSVC6 workaround.
MSVC6 was not able to cast from a uint64_t to a double and this
commit removes some #ifdef hackery designed to work around this
problem.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-04 08:32:01 +10:00
Erik de Castro Lopo
eda98c49a8 test_libFLAC/endswap.c : Add casts to prevent compiler warnings. 2014-07-03 20:24:33 +10:00
Erik de Castro Lopo
e51058343b test_libFLAC/test_libFLAC.vcproj : Add define for CPU_IS_LITTLE_ENDIAN. 2014-07-03 19:19:08 +10:00
Ralph Giles
22d4893d28 Fix bswap16 issue on Debian 6.
Versions of GCC prior to 4.8 didn't provide an implementation
of __builtin_bswap16 on x86_64. Detect those versions and
supply a fallback implementation. A cleaner fix would be
to detect bswap16 independently of bswap32 in configure
and handle them separately.

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

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-07-03 18:59:49 +10:00
Erik de Castro Lopo
7422e084f4 test_libFLAC : Fix Windows build after addidion of endian tests.
* Use "share/compat.h" instead of <stdint.h>.
* Update test_libFLAC.vcproj project file.
* Update Makefile.lite build system.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-03 05:38:12 +10:00
Erik de Castro Lopo
c6ff539ac0 src/flac/main.c : Improve raw format help text help.
The --endian and --sign options aren't just for raw input, but also
for raw output.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-03 05:35:59 +10:00
Erik de Castro Lopo
08cb913c98 src/flac/encode.c : Fix compression failure warning when encoding from stdin.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-07-02 18:33:33 +10:00
Erik de Castro Lopo
74d8133387 test_libFLAC/md5.c : Fix the tests.
The previous version of this test worked on amd64 and powerpc64 but
failed on armhf. Investigation show that the previous version of the
test data was generated for a case where the ARRAY_LEN macro was
exploiting undefined behaviour.
Fix was ditching the ARRAY_LEN macro and then recalculating the
target data.
2014-07-01 13:05:24 +10:00
Erik de Castro Lopo
c69a20944f test_libFLAC/endswap.c : Improvements.
* Print endian-ness of test host.
* Replace ugly macro with C code.
* Add tests for H2LE_16 and H2LE_32 macros.
2014-07-01 12:59:43 +10:00
Erik de Castro Lopo
6bd45d1115 src/test_libFLAC : Add tests for end swap macros. 2014-06-30 20:26:39 +10:00
Erik de Castro Lopo
4a38f75f85 src/flac/decode.c : Add comment about ubuf union. 2014-06-30 19:55:21 +10:00
Erik de Castro Lopo
0d1cb19525 include/share/endswap.h : Fix fallback ENDSWAP_16 macro. 2014-06-30 09:20:09 +10:00
Erik de Castro Lopo
3eb4094b85 src/flac/encode.c : Fix cast-align warning on ARM systems.
Use the union of pointers trick again.
2014-06-29 22:57:59 +10:00
Erik de Castro Lopo
7590d99b29 libFLAC/md5: Fix for cast-align warnings on ARM.
Rather than the buffer into format_input_() as a FLAC__byte pointer, pass
it as a pointer to a union of three pointers, one each for for FLAC__byte,
FLAC__int16 and FLAC_int32.
This should have zero measurable performance impact.
2014-06-29 21:53:01 +10:00
Erik de Castro Lopo
51c6567f62 libFLAC/md5.c : Massive refactoring of format_input_ function.
This refactoring is in preparation for fixing the cast-align warning when
compiling on ARM (and possibly others). Testing on stereo 16 bit files
suggests that the difference between the performance of this code and the
old code is negligible (tested only on amd64/linux).
2014-06-29 21:07:07 +10:00
Erik de Castro Lopo
699e7c457a include/share/endswap.h : Add endswapping of 16 bit values.
Also add macros H2LE_16 and H2LE_32, which do host to little-endian
swapping of 16 and 32 bit values respectively.
2014-06-29 20:20:06 +10:00
Erik de Castro Lopo
a8567d4b4e libFLAC/bitmath : Restore an ASSERT that was removed some time after 1.2.1.
Restore a FLAC__ASSERT() to bitmath functions FLAC__bitmath_ilog2 and
FLAC__bitmath_ilog2_wide functions. This prevents the return of an
"undefined" value.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-06-28 22:25:18 +10:00
Erik de Castro Lopo
9aa1546436 libFLAC/lpc_intrin_sseN.c : Disambiguate macro names.
Previously, the files lpc_intrin_sse2.c and lpc_intrin_sse41.c both defined
macros RESIDUAL_RESULT and DATA_RESULT. This situation made it impossible
to merge these files which we may do at some stage.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-06-28 22:25:18 +10:00
Erik de Castro Lopo
2c15052550 libFLAC: CPUID detecion improvements.
According to docs, it's incorrect to just call CPUID with EAX=1.
One must to ensure that this value is supported.

CPUs that don't support CPUID level 1 are very old, but...
if FLAC tests CPUID presence it should also test CPUID level support.

Also the function FLAC__cpu_have_cpuid_asm_ia32 was simplified
according to the docs at Intel website and in Wikipedia.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-06-28 22:25:18 +10:00
Erik de Castro Lopo
99257e177e flac: Fix channel order for mono files.
* The default channel mask for mono files was 0x0001 (front left) but it
  makes more sense to use 0x0004 (front center) for such files.

* Also FLAC will accept not only mono WAV files with 0x0001 mask, but also
  with 0x0002 (requested at https://sourceforge.net/p/flac/bugs/390/)
  and 0x0004 (e.g. SoX creates mono files with this mask).

* The comment about channel support was updated.

* The error message
     "Use --channel-map=none option to store channels in current order; FLAC files
     must also be decoded with --channel-map=none to restore correct order."
  is misleading: FLAC never changes the order of channels.
  Decoding with this options also sets the channel mask of the resulting WAV
  file to 0. Without this option the mask is equal to the value of
  WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-06-28 22:25:18 +10:00
Erik de Castro Lopo
1d12d98eda flac: Fix encoder and decode progress messages with --ogg.
Problem discussed here:

   http://lists.xiph.org/pipermail/flac-dev/2014-June/004808.html

The values for the interval between two updates (e->stats_mask,
e->stats_frames_interval) were set ~10 years ago, and it is small
for current CPUs. It was now been increased too (0x3f -> 0xff, etc).
The update interval is still less than 1 second.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-06-28 22:25:18 +10:00
Erik de Castro Lopo
a5c3a37c2a flac : Fix handling of raw input option.
FLAC was silently ignoring options for raw input for encoding mode (but
prints an error and aborts when _de_coding).

This can lead to bug reports such as https://sourceforge.net/p/flac/bugs/389/

FLAC now prints a message about options misuse for encoding mode.

Help messages were also updated.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-06-28 22:25:18 +10:00