Commit Graph

3792 Commits

Author SHA1 Message Date
Martijn van Beurden
02891daa7a Retune FLAC compression levels
This patch changes a the settings associated with compression
levels 6, 7 and 8. With this patch, -e is no longer used, but
instead apodization functions are added. This should improve
compression with at least 95% of all material while not changing
the speed much. Decoding ways, 6 and 8 stay the same, and 7 is
slowed a bit, which makes it as fast as 8.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-11-11 06:19:23 -08:00
Ralph Giles
69c2318b7b Fix indenting on the bswap32 autoconf macro.
We generally prefer spaces to tabs.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-11-04 21:18:48 -08:00
Ralph Giles
87408b3661 Clean up bswap32 autoconf macro.
Improve 'checking' message and don't hog the cache namespace.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-11-04 21:18:48 -08:00
Ralph Giles
7a671e7c41 Use a configure check for bswap16 instead of gcc version #ifdefs.
Fixes a build problem on apple clang.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-11-04 21:18:48 -08:00
Ralph Giles
1f30b3e711 Add autoconf macro to check for the bswap16 intrinsic.
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-11-04 21:18:48 -08:00
Erik de Castro Lopo
e0fbe71935 stream_encoder.c : Add apodization field to CompressionLevels struct.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-16 08:25:33 +11:00
Erik de Castro Lopo
d2de3a1a19 autogen.sh : Use long names for options to autoreconf. 2014-10-16 08:25:29 +11:00
Erik de Castro Lopo
f0a17e965b libFLAC/fixed_intrin_sse2.c : Fix comments.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-07 06:34:21 +11:00
Erik de Castro Lopo
11b5d51b63 Add AVX2 CPU support stream encoder.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-04 09:42:57 +10:00
Erik de Castro Lopo
a75b870592 Add AVX/AVX2/FMA support to CPU detection code.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-04 09:14:21 +10:00
Erik de Castro Lopo
ad2ae45bb7 libFLAC/stream_encoder.c : Reduce about of hackery.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-04 09:13:10 +10:00
Erik de Castro Lopo
35c14b10a4 Refactoring and simplifying of CPU detection.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-04 09:05:15 +10:00
Erik de Castro Lopo
7cb032c322 Remove support for AMD's 3Dnow.
AMD stopped release new chips withe 3DNow in 2010.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-04 09:01:36 +10:00
Erik de Castro Lopo
347afd878c src/libFLAC/window.c : Add 'f' to float literals to avoid compiler warnings.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-10-03 06:51:43 +10:00
Erik de Castro Lopo
d66f6754bf src/flac/decode.c : Decoder buffering improvements on Windows.
On Windows, decoding flac files is also prone to producing fragmented
files. Avoid fragmentation on NTFS by using Windows specific functions to
tell Windows the size of the file beforehand.

Patch-from: Janne Hyvärinen <cse@sci.fi>
2014-10-03 06:45:28 +10:00
Erik de Castro Lopo
e863247777 stream_encoder.c : Only set 10MB output buffer on _WIN32.
Commig 6a6207b52a set the size of the encoder output buffer to 10MB
but this fix is really only needed on Windows, so wrap it in an #ifdef.
2014-09-29 09:06:37 +10:00
Erik de Castro Lopo
25db9b2cce Improve malformed vorbiscomment handling.
A few minor tweaks on a patch from Janne Hyvärinen <cse@sci.fi>.

fixup
2014-09-27 09:28:45 +10:00
Erik de Castro Lopo
cf780068de metaflac : Fix typo in error message.
Patch-from: Janne Hyvärinen <cse@sci.fi>
2014-09-26 06:28:49 +10:00
Erik de Castro Lopo
cf732a8e86 libFLAC/cpu.c : Refactor for readability.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-24 06:41:59 +10:00
Erik de Castro Lopo
6a6207b52a stream_encoder.c : Give the encoder a larger stdio buffer.
Windows in particular can experience slow encoding speeds on highly
fragmented disks. Using setvbuf to increase the size of the buffer to
10Meg.

This is probably not needed on Linux/Unix, but is very unlikely to
to cause any negative effects.

Patch-from: Janne Hyvärinen <cse@sci.fi>
2014-09-24 06:35:17 +10:00
Erik de Castro Lopo
142cc51cc7 flac : Add help output for --ignore-chunk-sizes option.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-24 06:28:26 +10:00
Erik de Castro Lopo
9572984e87 libFLAC/window.c : Whitespace. 2014-09-23 06:16:31 +10:00
Erik de Castro Lopo
1c7e3f100f Windows specific vsnprintf fixes.
* Changes flac_snprintf (in src/share/grabbag/snprintf.c) and its copy
  local_snprintf (src/libFLAC/metadata_iterators.c) to be almost sane.

* Adds flac_vsnprintf (src/share/grabbag/snprintf.c) and its copy
  local_vsnprintf (src/share/win_utf8_io/win_utf8_io.c).

* Changes stats_print_info in src/flac/utils.c so it uses flac_vsnprintf
  instead of vsnprintf. This makes return value checking unnecessary.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-22 18:29:36 +10:00
Erik de Castro Lopo
e0ac5d46f0 win_utf8_io.c : Comment only.
Explains why flac is currently incompatible with extended-length paths.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-22 18:25:09 +10:00
Martijn van Beurden
29a28338c3 Add partial_tukey and punchout_tukey apodization functions
Adds two new apodization functions that seem to perform better than
the apodization functions currently in the codebase and fixes three
existing windows as well.

Its important to note that this patch only affects the encoder stage
that evaluates various possible predictors. Audio encoded with these
new windows will still decode with existing legacy decoders.

= Theory =
These functions are used to window the  audio data at the predictor
stage. These news functions enable the use of only part of the signal
to generate a predictor. This helps  because short transients can
introduce noise into the predictor. The  predictor becomes very good
at prediciting one part of the  signal, instead of mediocre for the
whole block.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-09-22 18:03:24 +10:00
Erik de Castro Lopo
ffa55423e0 flac/utils.c : Fix calculation of a tag length.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-21 21:11:46 +10:00
Erik de Castro Lopo
ea0d5ddadc lpc_intrin_sse41.c : Optimize decoding 24 bit files on 32 bit platforms.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-21 09:54:59 +10:00
Erik de Castro Lopo
fa85e3ce66 lpc_intrin* : Remove unused code.
Which in turn simplifies FLAC__lpc_restore_signal_16_intrin_sse2()
function.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-21 09:34:53 +10:00
Erik de Castro Lopo
71875b0c75 fixed_intrin_sse[23].c : Add new, simpler SSE code.
It's simpler but not faster so it is disabled by default. Maybe it
will be faster on newer CPUs though..

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-21 09:34:32 +10:00
Erik de Castro Lopo
6abc480387 stream_encoder_intrin_sse[23].c : Optimize of int32 -> uint64 conversion.
Optimizes int32 -> uint64 conversion by doing zero extension (int32 ->
uint32 -> uint64) instead of sign extension (int32 -> int64 -> uint64).

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-21 08:48:20 +10:00
Yuta NAKAI
97bcc6f51a win_utf8_io.c: Use fputws instead of fwprintf.
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2014-09-21 08:44:52 +10:00
Erik de Castro Lopo
b373c8ecb4 Minor clean up of win_utf8_io.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-21 08:06:48 +10:00
Erik de Castro Lopo
d6d33e21e7 vorbiscomment.c : Do not write empty vorbiscomment fields.
That is, only write vorbis comment fields if they are non-empty.

Patch-from: Janne Hyvärinen <cse@sci.fi>
2014-09-19 17:51:17 +10:00
Erik de Castro Lopo
4fa58808df fixed_intrin_sse[23].c : Simplify XMM -> int64 conversion.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-18 21:47:36 +10:00
Erik de Castro Lopo
ed530f6a4a cpu.h : Only define FLAC__SSE_SUPPORTED if FLAC__HAS_X86INTRIN is set.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-18 21:47:11 +10:00
Erik de Castro Lopo
b60f16bbc8 Remove old/broken PPC/Altivec code.
* Removes FLAC__lpc_restore_signal_asm_ppc_altivec_16*
  from lpc.h and stream_decoder.c
* Removes PPC-specific code from cpu.c and cpu.h
* Removes PPC stuff from libFLAC/Makefile.lite and build/*.mk
* Removes as/gas/PPC-specific stuff from configure.ac and
  libFLAC/Makefile.am*
* Removes libFLAC/ppc folder and remove "src/libFLAC/ppc*/Makefile"
  lines from configure.ac

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-09-17 23:21:39 +10:00
Erik de Castro Lopo
d399e31ec6 win_utf8_io.c : Remove redundant line.
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2014-08-09 13:03:59 +10:00
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