Commit Graph

537 Commits

Author SHA1 Message Date
Mads Kiilerich
0a52a40111 tests/cpp_test.cc: improve error reporting in check_title
The test somehow briefly failed for me. This will help debug if it happens again.
2022-10-27 09:58:02 +05:00
Mads Kiilerich
bc2e8bebe4 src/wavlike.c: Fix wavlike_subchunk_parse skipping of erroneous subchunks, closes #374
Drop invalid +4 as in 65eabcbf7.
2022-10-27 09:58:02 +05:00
Mads Kiilerich
cc5be43f09 tests/error_test.c: introduce wav_list_recover_test to cover #374
The test is currently been negated so it expects to hit the problem.
That will change when the problem is fixed.
2022-10-27 09:58:02 +05:00
Jörn Heusipp
bd951f9a47 Make sndfile.h independent of build system variables
Fixes <https://github.com/libsndfile/libsndfile/issues/868>.
2022-09-12 10:39:37 +02:00
IOhannes m zmölnig
cefd7b59df tests: Use fuzzy comparison in test-suite
Using exact comparison ("a == b") when comparing expected with computed
test data fails the test-suite on many architectures (including, but not
limited to armhf and arm64).

Instead, use epsilon(for now, FLT_EPSILON and DBL_EPSILON) to compare
floating point numbers for equality.


Closes: https://github.com/libsndfile/libsndfile/issues/866

Signed-off-by: IOhannes m zmölnig <zmoelnig@iem.at>
2022-09-09 13:04:00 +05:00
Arthur Taylor
d1c87ec1c7 mpeg: Disable experimental writing MPEG subformats in WAV 2021-10-22 23:57:30 -07:00
Arthur Taylor
f401000fd0 Skip format_check_test for asymmetric MPEG Layer I/II
libmpg123 supports decoding MPEG Layers I, II, and III, but we only have
encode support for Layer III. Skip checks for I and II as they don't
have write support.
2021-03-25 10:26:15 -07:00
Arthur Taylor
64ce116687 Fix command_test Subformat count 2021-03-25 10:26:15 -07:00
Arthur Taylor
163f725631 Rename mp3 -> mpeg (file sources and function names) 2021-03-25 10:26:15 -07:00
Arthur Taylor
dae19b9502 Rename SF_FORMAT_MP3 to SF_FORMAT_MPEG 2021-03-25 10:26:15 -07:00
Arthur Taylor
663a59aa6e mpeg: Add MPEG Encode, Decode and Tests
Use SF_FORMAT_MP3 major and SF_FORMAT_MPEG_LAYER_(I|II|III) subformats.
2021-03-25 10:26:15 -07:00
evpobr
dadf54b91e ci: Fix test failure 2021-03-14 22:08:01 +05:00
evpobr
4ff3b84eff msvc: Fix annoying conversion warnings #304 2021-03-06 11:41:47 +05:00
bobsayshilol
aa3346cc6e
tests: Make temporary filenames unique per test (#704)
When two tests share a temporary filename they can cause ctest to fail
when run in parallel mode since both would attempt to operate on the
same file if scheduled to run at the same time.

To fix this, filenames in the smaller tests have been individually
renamed, and for the bigger tests a prefix has been added to make them
unique.

The complete list of conflicting filenames (which were then manually
inspected) was generated by running the following command in 'tests':

    for file in $(grep -hoER \"\\w+\\.\\w+\" | sort | uniq -d)
        do echo $file
        grep -Rn $file
        echo
    done | less
2021-02-21 11:11:34 +01:00
David Seifert
26b4ae781d
Delete temporary files for invalid opus versions
* Previously, temporary files in the testsuite weren't cleaned up
  properly, and would fail if unique filenames (#704) were used.
2021-02-20 16:18:19 +01:00
evpobr
d11a64c7c4 Deprecate ENABLE_SNDFILE_WINDOWS_PROTOTYPES define
Use standard `_WIN32` define instead. Any sane compiler on Windows
platfrom defines `_WIN32`.

The `wpath` parameter type has been changed to an equivalent type that
does not require the inclusion of the `windows.h` header.
2021-02-18 16:56:34 +05:00
evpobr
610c6392cb Fix deprecated function warning
The `GetVersionEx` function  has been deprecated.

Since it doesn't make much sense here, it has been deleted.
2021-02-17 13:44:15 +05:00
bobsayshilol
5ba69401c1
Fix pedantic warnings (#703)
* Fix warnings about incorrect format specifiers.
GCC only wants to see void pointers for %p formatters, so cast as appropriate.

* Fix a warning about an invalid enum value.
The following warning was observed when compiling with -pedantic:

    warning: ISO C restricts enumerator values to range of 'int' (2147483648 is too large)

The values of these enums don't escape wav_read_header() and are only used to set bits in a bitmask, so simply use the next bit rather than jumping to a huge number.

* Give anonymous unions a name.
This fixes the 'anonymous unions are a C11 extension' warning when compiling with -pedantic.

* Use flexible array members rather than zero sized arrays.
This flagged up the following warning when compiling with -pedantic:
    warning: zero size arrays are an extension [-Wzero-length-array]

* Safely return the smallest value of a short.
GCC gives the following warning when compiling with -pedantic:

    warning: overflow in conversion from 'int' to 'short int' changes value from '32768' to '-32768' [-Woverflow]

This looks intentional from the surrounding code, so return -32768 in a legal way rather than depending on undefined behaviour.

* Use the same min/max approach with all compilers.
The GCC specific code gives the following warning from GCC when compiled with -pedantic:

    warning: ISO C forbids braced-groups within expressions [-pedantic]

This code was also a fundamentally different way of calculating min/max since it didn't evaluate the inputs more than once, which meant there was potentially a difference in behaviour when the library was built with different compilers if the evaluation of 'a' or 'b' had side effects.
2021-02-14 10:16:33 +05:00
bobsayshilol
ecb9672aaa
Fix int normalisation when reading in floats with the replacement reader (#702)
* Use the correct scale when normalising an integer read on the fallback floating point path.
Without this the values were only being scaled to a short's max value.

* Add a second pass over the floating point tests that enables the replacement read functionality.
These cover the issue fixed by the previous commit.

* Add an entry to CHANGELOG.md for #702.
2021-02-14 09:45:07 +05:00
evpobr
e01ee91591 Fix Clang warnings 2020-09-04 10:03:09 +05:00
evpobr
a9f4037de1 Fix warnings reported by Clang 10 2020-08-31 16:59:01 +05:00
evpobr
fe50b95615 CMake: Fix MinGW with Clang compiler warnings 2020-08-31 09:30:42 +05:00
evpobr
acfcd147da Move public headers to include directory 2020-08-26 11:59:26 +05:00
evpobr
41bba15973 Fix compiler warnings
Fix GCC 10.2.0 with -Wall -Wextra warnings.

src/ogg.c: Fix compiler warning

-Wsign-compare in ogg_stream_seek_page_search().

src/misc_test.c: Fix compiler warnings

-Wunused-parameter, -Wunused-variable in filesystem_full_test().

Windows platforms only.

src/ms_adpcm.c: Fix compiler warnings

-Wmaybe-uninitialized in msadpcm_encode_block().

src/ogg.c: Fix compiler warning

Comparison of distinct pointer types lacks a cast in
ogg_read_first_page().
2020-08-20 12:33:20 +05:00
Moonbase59
3a57ea117b Add BWF v2 loudness parameters
Closes: https://github.com/erikd/libsndfile/issues/479
2019-08-27 07:28:25 +10:00
evpobr
22c2fa64c2 tests/command_test.c: Fix format specifiers
Closes: #472
2019-07-02 20:59:35 +10:00
Arthur Taylor
326e4533f3 Opus file support
Ogg: Introduce new functions ogg_sync_fseek(), ogg_ftell(), ogg_next_page(),
ogg_stream_next_page(), ogg_sync_last_page_before(), and
ogg_stream_unpack_page(). Use ogg_sync_* for ogg_read_first_page(). Bump libogg
version requirement from 1.1.3 to 1.3.0 as LibOgg 1.3.0 is required for
ogg_stream_pageout_fill() and ogg_stream_flush_fill().

Opus: Add opus support. Document added commands
SFC_(GET|SET)_ORIGINAL_SAMPLERATE. Added or extended tests ogg_opus_test,
compression_size_test, floating_point_test, lossy_comp_test, string_test,
external_libs_test. Change Opus to non-experimental.
2019-02-20 19:30:30 +11:00
Erik de Castro Lopo
bef2abc9e8 tests/command_test.c: Fix ASAN test failure 2019-01-02 12:24:21 +11:00
Erik de Castro Lopo
ba8a7577c6
Add support for more than 1000 cue points in WAV and AIFF files (#434)
This work was originally submitted by Diemo Schwarz <schwarz@ircam.fr> in
PR https://github.com/erikd/libsndfile/pull/197 which was rebased and
cleaned up.

Closes: https://github.com/erikd/libsndfile/pull/197
2018-12-23 20:32:56 +11:00
Arthur Taylor
81a71e08c0 Fix lossy_comp_test sdlcomp_test_(float|double) for Vorbis (#426)
While experimenting, determined that Vobis' analysis stops working on
non-normalized floating point input outside the range of [2000.0, -2000.0], and
seems to get worse the larger the magnitude. As the sdlcomp_test_float and
sldcomp_test_double tests work with non-normalized floats with a magnitude of
32000.0, this explains why they do not work for Vorbis.

This patch fixes the test by reducing the magnitude of the test data at encode
and restoring it at decode if it detects Vorbis, mantaining the same 32000.0
overall magnitude so the envelope values for the test are the same as they are
for other tests and format.

It is unknown at this time if the input range magnitude of 2000.0 is  a
limitation of Vorbis or libvorbis.
2018-10-11 09:26:56 +11:00
evpobr
123cb9f9a5 tests/vrtual_io_test.c: Fix typo
Closes: https://github.com/erikd/libsndfile/issues/417
2018-09-20 07:13:50 +10:00
Michael Panzlaff
7ea3f9d874 src/wav.c: Fix WAV Sampler Chunk tune parsing
Fix parsing of instrument fine tuning instrument field. There is still
a possible rounding error involved which might require further
investigation at some stage.

Update the test as well.
2018-04-29 12:13:42 +10:00
David Seifert
4ab74d919f Fix out-of-tree building 2018-04-21 09:23:25 +10:00
Erik de Castro Lopo
dc56b25f41 tests/error_test.c: Add unrecognised file test 2018-03-17 13:05:25 +11:00
Arthur Taylor
4043ec289f lossy_comp_test: Add tests for NMS_ADPCM in WAV files. 2018-03-08 18:13:03 +11:00
Arthur Taylor
64e5a3f182 Add NMS ADPCM codec implementation and support
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2018-02-03 19:44:33 +11:00
Erik de Castro Lopo
5d4d1feca0 Remove redundant libsndfile.def.in 2017-10-31 18:42:40 +11:00
Erik de Castro Lopo
9b4fdaccc1 tests/header_test.tpl: Fix a memory leak
Found using AddressSanitizer.
2017-10-26 19:21:06 +11:00
David Seifert
b17f14d613 Make git checkout buildable out-of-tree
Currently, libsndfile requires in-tree bootstrapping and creation
of the tarball. For Gentoo, some users might want to build the
latest git checkout. This commit makes out-of-tree building of all
the necessary dependencies possible.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2017-10-08 18:23:58 +11:00
Erik de Castro Lopo
cc5e831a75 A couple of minor cstyle fixes 2017-10-01 16:33:41 +11:00
David Seifert
e6c42ff027 Make build system completely non-recursive 2017-09-26 19:35:56 +10:00
Erik de Castro Lopo
beee21e5c2 Revert "tests/Makefile.am: Switch away from GNU make rules"
This reverts commit ff26310437.

The GNU make rules actually work. The old style suffix rules do not.
2017-08-10 20:22:18 +10:00
Henner Zeller
f96e5a2047 Add test for flac regression update-header-before-write
Explicitly writing the header with SFC_UPDATE_HEADER_NOW before
the first sf_write() was making sf_write() calls fail. This is a
test to verify that the fix works.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2017-08-10 20:09:55 +10:00
Erik de Castro Lopo
9923b2a0a2 src/aiff.c: Remove INST chunk writing
This code had egregious errors in the way things were being passed
to psf_binheader_writef and neither the compiler nor the tests
caught it. It was however found when adding safety macros to enforce
correct type being passed to psf_binheader_writef.
2017-05-16 21:03:22 +10:00
evpobr
44269a0892 Tests: Fix win32_ordinal_test 2017-05-06 01:55:14 +10:00
Erik de Castro Lopo
b506de463d Fix MSAN errors
Fix multiple errors uncovered by Clang's Memory Sanitizer.

Closes: https://github.com/erikd/libsndfile/issues/248
2017-05-04 18:42:24 +10:00
Erik de Castro Lopo
cecc9a7498 RF64 tweaks
* Comments.
* Improve the `rf64_long_file_downgrade_test` test.
2017-04-18 20:07:10 +10:00
Erik de Castro Lopo
ff26310437 tests/Makefile.am: Switch away from GNU make rules
Avoid `'%'-style pattern rules are a GNU make extension` warnings.
2017-04-16 19:58:15 +10:00
Erik de Castro Lopo
bf83b95fd9 RF64: Fix an RF64_AUTO_DOWNGRADE bug
Also add a test for this. The test is disabled by default because it
needs to write a 4 Gig file.

Closes: https://github.com/erikd/libsndfile/issues/238
2017-04-16 19:11:45 +10:00
evpobr
a3287d88eb tests: Fix typos in fixes for MSVC
* src/test_main.c: Fix typo in HAVE_SYS_TYPES_H definition
* tests/win32_ordinal_test.c: Use correct "direct.h" header instead of "dirent.h"

Related: https://github.com/erikd/libsndfile/issues/154, https://github.com/erikd/libsndfile/pull/234
2017-04-15 07:45:45 +10:00