update libsndfile to fix linux build

This commit is contained in:
marauder2k7 2025-10-28 17:10:28 +00:00
parent d4cc9a8324
commit 574ca023d9
87 changed files with 1022 additions and 818 deletions

View file

@ -359,7 +359,7 @@ if(NOT Python3_FOUND)
message(FATAL_ERROR "Failed to extract ${python_zip}") message(FATAL_ERROR "Failed to extract ${python_zip}")
endif() endif()
file(GLOB embedded_python_exe "${python_dir}/python*.exe") file(GLOB embedded_python_exe "${python_dir}/python.exe")
if(embedded_python_exe) if(embedded_python_exe)
set(Python_EXECUTABLE "${embedded_python_exe}" CACHE FILEPATH "Path to embedded Python" FORCE) set(Python_EXECUTABLE "${embedded_python_exe}" CACHE FILEPATH "Path to embedded Python" FORCE)
message(STATUS "Using embedded Python: ${Python_EXECUTABLE}") message(STATUS "Using embedded Python: ${Python_EXECUTABLE}")

View file

@ -5,12 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
* Disable autogen rules when autogen cannot be found
## [1.2.2] - 2023-08-13 ## [1.2.2] - 2023-08-13
### Fixed ### Fixed

View file

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.5...4.0) cmake_minimum_required (VERSION 3.5..3.18)
# MSVC runtime library flags are selected by an abstraction, CMake >= 3.15 # MSVC runtime library flags are selected by an abstraction, CMake >= 3.15
# This policy still need to be set even with cmake_minimum_required() command above. # This policy still need to be set even with cmake_minimum_required() command above.
@ -8,12 +8,10 @@ if (POLICY CMP0091)
return () return ()
endif () endif ()
if (CMAKE_VERSION VERSION_LESS 3.18) if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) cmake_policy (SET CMP0091 NEW)
cmake_policy (SET CMP0091 NEW) else ()
else () cmake_policy (SET CMP0091 OLD)
cmake_policy (SET CMP0091 OLD)
endif ()
endif () endif ()
endif () endif ()
@ -106,6 +104,11 @@ if (BUILD_REGTEST AND (NOT SQLITE3_FOUND))
set (BUILD_REGTEST OFF) set (BUILD_REGTEST OFF)
endif() endif()
cmake_dependent_option (ENABLE_CPU_CLIP "Enable tricky cpu specific clipper" ON "CPU_CLIPS_POSITIVE;CPU_CLIPS_NEGATIVE" OFF)
if (NOT ENABLE_CPU_CLIP)
set (CPU_CLIPS_POSITIVE FALSE)
set (CPU_CLIPS_NEGATIVE FALSE)
endif ()
cmake_dependent_option (ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise" OFF "WIN32;BUILD_SHARED_LIBS" OFF) cmake_dependent_option (ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise" OFF "WIN32;BUILD_SHARED_LIBS" OFF)
cmake_dependent_option (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS" OFF) cmake_dependent_option (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS" OFF)
@ -137,6 +140,7 @@ add_feature_info (ENABLE_EXPERIMENTAL ENABLE_EXPERIMENTAL "enable experimental c
add_feature_info (BUILD_TESTING BUILD_TESTING "build tests") add_feature_info (BUILD_TESTING BUILD_TESTING "build tests")
add_feature_info (BUILD_REGTEST BUILD_REGTEST "build regtest") add_feature_info (BUILD_REGTEST BUILD_REGTEST "build regtest")
add_feature_info (ENABLE_CPACK ENABLE_CPACK "enable CPack support") add_feature_info (ENABLE_CPACK ENABLE_CPACK "enable CPack support")
add_feature_info (ENABLE_CPU_CLIP ENABLE_CPU_CLIP "Enable tricky cpu specific clipper")
add_feature_info (ENABLE_BOW_DOCS ENABLE_BOW_DOCS "enable black-on-white html docs") add_feature_info (ENABLE_BOW_DOCS ENABLE_BOW_DOCS "enable black-on-white html docs")
add_feature_info (ENABLE_PACKAGE_CONFIG ENABLE_PACKAGE_CONFIG "generate and install package config file") add_feature_info (ENABLE_PACKAGE_CONFIG ENABLE_PACKAGE_CONFIG "generate and install package config file")
add_feature_info (INSTALL_PKGCONFIG_MODULE INSTALL_PKGCONFIG_MODULE "generate and install pkg-config module") add_feature_info (INSTALL_PKGCONFIG_MODULE INSTALL_PKGCONFIG_MODULE "generate and install pkg-config module")
@ -191,7 +195,7 @@ set_package_properties(Opus PROPERTIES
set_package_properties(Speex PROPERTIES TYPE OPTIONAL set_package_properties(Speex PROPERTIES TYPE OPTIONAL
URL "www.speex.org/" URL "www.speex.org/"
DESCRIPTION "an audio codec tuned for speech" DESCRIPTION "an audio codec tuned for speech"
PURPOSE "Enables experimental Speex support" PURPOSE "Enables experemental Speex support"
) )
set_package_properties (SQLite3 PROPERTIES set_package_properties (SQLite3 PROPERTIES
TYPE OPTIONAL TYPE OPTIONAL
@ -388,7 +392,7 @@ target_link_libraries (sndfile
PRIVATE PRIVATE
$<$<BOOL:${LIBM_REQUIRED}>:m> $<$<BOOL:${LIBM_REQUIRED}>:m>
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Ogg::ogg> $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Ogg::ogg>
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:vorbisenc> $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Vorbis::vorbisenc>
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:FLAC::FLAC> $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:FLAC::FLAC>
$<$<AND:$<BOOL:${ENABLE_EXPERIMENTAL}>,$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>,$<BOOL:${HAVE_SPEEX}>>:Speex::Speex> $<$<AND:$<BOOL:${ENABLE_EXPERIMENTAL}>,$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>,$<BOOL:${HAVE_SPEEX}>>:Speex::Speex>
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Opus::opus> $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Opus::opus>
@ -483,7 +487,7 @@ if (BUILD_SHARED_LIBS)
if (DEFINED SYMBOL_OS) if (DEFINED SYMBOL_OS)
add_custom_command ( add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/create_symbols_file.py ${SYMBOL_OS} ${SNDFILE_ABI_VERSION} > ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/create_symbols_file.py ${SYMBOL_OS} ${SNDFILE_ABI_VERSION} > ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}
COMMENT "Generating ${SYMBOL_FILENAME}..." COMMENT "Generating ${SYMBOL_FILENAME}..."
) )
@ -566,9 +570,8 @@ if (BUILD_PROGRAMS)
elseif ((NOT BEOS) AND ALSA_FOUND) elseif ((NOT BEOS) AND ALSA_FOUND)
target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS}) target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS})
target_link_libraries (sndfile-play PRIVATE ${ALSA_LIBRARIES}) target_link_libraries (sndfile-play PRIVATE ${ALSA_LIBRARIES})
elseif ((NOT BEOS) AND SNDIO_FOUND) elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
target_include_directories (sndfile-play PRIVATE ${SNDIO_INCLUDE_DIRS}) target_link_libraries (sndfile-play PRIVATE Sndio::Sndio)
target_link_libraries (sndfile-play PRIVATE ${SNDIO_LIBRARIES})
endif () endif ()
# sndfile-convert # sndfile-convert

View file

@ -16,7 +16,8 @@ EXTRA_DIST = sndfile.pc.in Scripts/android-configure.sh \
NEWS.OLD CHANGELOG.md Scripts/linux-to-win-cross-configure.sh \ NEWS.OLD CHANGELOG.md Scripts/linux-to-win-cross-configure.sh \
CMakeLists.txt $(cmake_files) Win32 SECURITY.md CMakeLists.txt $(cmake_files) Win32 SECURITY.md
cmake_files = cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \ cmake_files = cmake/ClipMode.cmake cmake/FindFLAC.cmake \
cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \
cmake/FindOgg.cmake cmake/FindVorbis.cmake cmake/FindSndio.cmake \ cmake/FindOgg.cmake cmake/FindVorbis.cmake cmake/FindSndio.cmake \
cmake/FindSpeex.cmake cmake/sqlite/FindSQLite3.cmake \ cmake/FindSpeex.cmake cmake/sqlite/FindSQLite3.cmake \
cmake/SndFileChecks.cmake cmake/TestInline.cmake \ cmake/SndFileChecks.cmake cmake/TestInline.cmake \
@ -24,7 +25,7 @@ cmake_files = cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \
cmake/FindOpus.cmake cmake/SndFileConfig.cmake.in \ cmake/FindOpus.cmake cmake/SndFileConfig.cmake.in \
cmake/CheckCPUArch.cmake cmake/CheckCPUArch.c.in \ cmake/CheckCPUArch.cmake cmake/CheckCPUArch.c.in \
cmake/Findmp3lame.cmake cmake/Findmpg123.cmake \ cmake/Findmp3lame.cmake cmake/Findmpg123.cmake \
cmake/FindFLAC.cmake cmake/SetupABIVersions.cmake cmake/SetupABIVersions.cmake
pkgconfig_DATA = sndfile.pc pkgconfig_DATA = sndfile.pc
@ -402,7 +403,6 @@ tests_scale_clip_test_LDADD = src/libsndfile.la
# Yes, this sucks, but GNU make patterns aren't portable, # Yes, this sucks, but GNU make patterns aren't portable,
# see also https://github.com/libsndfile/libsndfile/issues/369 # see also https://github.com/libsndfile/libsndfile/issues/369
if HAVE_AUTOGEN
SUFFIXES = .tpl .def SUFFIXES = .tpl .def
.tpl.def: .tpl.def:
@ -424,7 +424,6 @@ tests/utils.h : tests/utils.c
rm -f tests/utils.c && \ rm -f tests/utils.c && \
$(MAKE) $(AM_MAKEFLAGS) tests/utils.c; \ $(MAKE) $(AM_MAKEFLAGS) tests/utils.c; \
fi fi
endif
######## ########
# man/ # # man/ #
@ -456,7 +455,7 @@ if USE_OSSFUZZ_STATIC
FUZZ_LDADD = $(LIB_FUZZING_ENGINE) FUZZ_LDADD = $(LIB_FUZZING_ENGINE)
FUZZ_FLAG = FUZZ_FLAG =
else else
FUZZ_LDADD = ossfuzz/libstandaloneengine.la FUZZ_LDADD = libstandaloneengine.la
FUZZ_FLAG = FUZZ_FLAG =
endif endif
endif endif

View file

@ -127,7 +127,7 @@ You can pass additional options with `/D<parameter>=<value>` when you run
Useful libsndfile options: Useful libsndfile options:
* `BUILD_SHARED_LIBS` - build shared library (DLL under Windows) when `ON`, * `BUILD_SHARED_LIBS` - build shared library (DLL under Windows) when `ON`,
build static library otherwise. This option is `OFF` by default. build static library othervise. This option is `OFF` by default.
* `BUILD_PROGRAMS` - build libsndfile's utilities from `programs/` directory, * `BUILD_PROGRAMS` - build libsndfile's utilities from `programs/` directory,
`ON` by default. `ON` by default.
* `BUILD_EXAMPLES` - build examples, `ON` by default. * `BUILD_EXAMPLES` - build examples, `ON` by default.
@ -137,6 +137,8 @@ You can pass additional options with `/D<parameter>=<value>` when you run
option is available and set to `ON` if all dependency libraries were found. option is available and set to `ON` if all dependency libraries were found.
* `ENABLE_MPEG` - MP3 support. This option is available and set to `ON` if all * `ENABLE_MPEG` - MP3 support. This option is available and set to `ON` if all
dependency libraries were found. dependency libraries were found.
* `ENABLE_CPU_CLIP` - enable tricky cpu specific clipper. Enabled and set to
`ON` when CPU clips negative\positive. Don't touch it if you are not sure
* `ENABLE_BOW_DOCS` - enable black-on-white documentation theme, `OFF` by * `ENABLE_BOW_DOCS` - enable black-on-white documentation theme, `OFF` by
default. default.
* `ENABLE_EXPERIMENTAL` - enable experimental code. Don't use it if you are * `ENABLE_EXPERIMENTAL` - enable experimental code. Don't use it if you are
@ -163,7 +165,7 @@ You can pass additional options with `/D<parameter>=<value>` when you run
is native for MinGW ecosystem, Autotools constructs it using MinGW platform is native for MinGW ecosystem, Autotools constructs it using MinGW platform
rules from `sndfile` target. But when you build with CMake using native rules from `sndfile` target. But when you build with CMake using native
Windows compiler, the name is `sndfile.dll`. This is name for native Windows Windows compiler, the name is `sndfile.dll`. This is name for native Windows
platform, because Windows has no library naming rules. It is preferred platform, because Windows has no library naming rules. It is preffered
because you can search library using package manager or CMake's because you can search library using package manager or CMake's
`find_library` command on any platform using the same `sndfile` name. `find_library` command on any platform using the same `sndfile` name.
@ -181,6 +183,8 @@ Deprecated options:
* `DISABLE_EXTERNAL_LIBS` - disable Ogg, Vorbis and FLAC support. Replaced by * `DISABLE_EXTERNAL_LIBS` - disable Ogg, Vorbis and FLAC support. Replaced by
`ENABLE_EXTERNAL_LIBS` `ENABLE_EXTERNAL_LIBS`
* `DISABLE_CPU_CLIP` - disable tricky cpu specific clipper. Replaced by
`ENABLE_CPU_CLIP`
* `BUILD_STATIC_LIBS` - build static library. Use `BUILD_SHARED_LIBS` instead * `BUILD_STATIC_LIBS` - build static library. Use `BUILD_SHARED_LIBS` instead
### Linking from CMake projects ### Linking from CMake projects

View file

@ -31,13 +31,13 @@ class Preprocessor:
""" """
def __init__ (self): def __init__ (self):
self.comment_nest = 0 self.comment_nest = 0
self.leading_space_re = re.compile (r'^(\t+| )') self.leading_space_re = re.compile ('^(\t+| )')
self.trailing_space_re = re.compile (r'(\t+| )$') self.trailing_space_re = re.compile ('(\t+| )$')
self.define_hack_re = re.compile (r"(#\s*define\s+[a-zA-Z0-9_]+)\(") self.define_hack_re = re.compile ("(#\s*define\s+[a-zA-Z0-9_]+)\(")
def comment_nesting (self): def comment_nesting (self):
""" """
Return the current comment nesting. At the start and end of the file, Return the currect comment nesting. At the start and end of the file,
this value should be zero. Inside C comments it should be 1 or this value should be zero. Inside C comments it should be 1 or
(possibly) more. (possibly) more.
""" """
@ -55,7 +55,7 @@ class Preprocessor:
# Strip C++ style comments. # Strip C++ style comments.
if self.comment_nest == 0: if self.comment_nest == 0:
line = re.sub (r"( |\t*)//.*", '', line) line = re.sub ("( |\t*)//.*", '', line)
# Strip C style comments. # Strip C style comments.
open_comment = line.find ('/*') open_comment = line.find ('/*')
@ -108,51 +108,51 @@ class CStyleChecker:
self.error_count = 0 self.error_count = 0
self.line_num = 1 self.line_num = 1
self.orig_line = '' self.orig_line = ''
self.trailing_newline_re = re.compile (r'[\r\n]+$') self.trailing_newline_re = re.compile ('[\r\n]+$')
self.indent_re = re.compile (r"^\s*") self.indent_re = re.compile ("^\s*")
self.last_line_indent = "" self.last_line_indent = ""
self.last_line_indent_curly = False self.last_line_indent_curly = False
self.re_checks = \ self.re_checks = \
[ ( re.compile (r" "), "multiple space instead of tab" ) [ ( re.compile (" "), "multiple space instead of tab" )
, ( re.compile (r"\t "), "space after tab" ) , ( re.compile ("\t "), "space after tab" )
, ( re.compile (r"[^ ];"), "missing space before semi-colon" ) , ( re.compile ("[^ ];"), "missing space before semi-colon" )
, ( re.compile (r"{[^\s}]"), "missing space after open brace" ) , ( re.compile ("{[^\s}]"), "missing space after open brace" )
, ( re.compile (r"[^{\s]}"), "missing space before close brace" ) , ( re.compile ("[^{\s]}"), "missing space before close brace" )
, ( re.compile (r"[ \t]+$"), "contains trailing whitespace" ) , ( re.compile ("[ \t]+$"), "contains trailing whitespace" )
, ( re.compile (r",[^\s\n]"), "missing space after comma" ) , ( re.compile (",[^\s\n]"), "missing space after comma" )
, ( re.compile (r";[^\s]"), "missing space after semi-colon" ) , ( re.compile (";[^\s]"), "missing space after semi-colon" )
, ( re.compile (r"=[^\s\"'=]"), "missing space after assignment" ) , ( re.compile ("=[^\s\"'=]"), "missing space after assignment" )
# Open and close parenthesis. # Open and close parenthesis.
, ( re.compile (r"[^\s\(\[\*&']\("), "missing space before open parenthesis" ) , ( re.compile ("[^\s\(\[\*&']\("), "missing space before open parenthesis" )
, ( re.compile (r"\)(-[^>]|[^,'\s\n\)\]-])"), "missing space after close parenthesis" ) , ( re.compile ("\)(-[^>]|[^,'\s\n\)\]-])"), "missing space after close parenthesis" )
, ( re.compile (r"\s(do|for|if|when)\s.*{$"), "trailing open parenthesis at end of line" ) , ( re.compile ("\s(do|for|if|when)\s.*{$"), "trailing open parenthesis at end of line" )
, ( re.compile (r"\( [^;]"), "space after open parenthesis" ) , ( re.compile ("\( [^;]"), "space after open parenthesis" )
, ( re.compile (r"[^;] \)"), "space before close parenthesis" ) , ( re.compile ("[^;] \)"), "space before close parenthesis" )
# Open and close square brace. # Open and close square brace.
, ( re.compile (r"[^\s\(\]]\["), "missing space before open square brace" ) , ( re.compile ("[^\s\(\]]\["), "missing space before open square brace" )
, ( re.compile (r"\][^,\)\]\[\s\.-]"), "missing space after close square brace" ) , ( re.compile ("\][^,\)\]\[\s\.-]"), "missing space after close square brace" )
, ( re.compile (r"\[ "), "space after open square brace" ) , ( re.compile ("\[ "), "space after open square brace" )
, ( re.compile (r" \]"), "space before close square brace" ) , ( re.compile (" \]"), "space before close square brace" )
# Space around operators. # Space around operators.
, ( re.compile (r"[^\s][\*/%+-][=][^\s]"), "missing space around opassign" ) , ( re.compile ("[^\s][\*/%+-][=][^\s]"), "missing space around opassign" )
, ( re.compile (r"[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" ) , ( re.compile ("[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" )
# Parens around single argument to return. # Parens around single argument to return.
, ( re.compile (r"\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" ) , ( re.compile ("\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" )
# Parens around single case argument. # Parens around single case argument.
, ( re.compile (r"\s+case\s+\([a-zA-Z0-9_]+\)\s+:"), "parens around single case argument" ) , ( re.compile ("\s+case\s+\([a-zA-Z0-9_]+\)\s+:"), "parens around single case argument" )
# Open curly at end of line. # Open curly at end of line.
, ( re.compile (r"\)\s*{\s*$"), "open curly brace at end of line" ) , ( re.compile ("\)\s*{\s*$"), "open curly brace at end of line" )
# Pre and post increment/decrement. # Pre and post increment/decrment.
, ( re.compile (r"[^\(\[][+-]{2}[a-zA-Z0-9_]"), "space after pre increment/decrement" ) , ( re.compile ("[^\(\[][+-]{2}[a-zA-Z0-9_]"), "space after pre increment/decrement" )
, ( re.compile (r"[a-zA-Z0-9_][+-]{2}[^\)\,]]"), "space before post increment/decrement" ) , ( re.compile ("[a-zA-Z0-9_][+-]{2}[^\)\,]]"), "space before post increment/decrement" )
] ]
def get_error_count (self): def get_error_count (self):
@ -207,7 +207,7 @@ class CStyleChecker:
""" """
indent = len (self.indent_re.search (line).group ()) indent = len (self.indent_re.search (line).group ())
if re.search (r"^\s+}", line): if re.search ("^\s+}", line):
if not self.last_line_indent_curly and indent != self.last_line_indent: if not self.last_line_indent_curly and indent != self.last_line_indent:
None # self.error ("bad indent on close curly brace") None # self.error ("bad indent on close curly brace")
self.last_line_indent_curly = True self.last_line_indent_curly = True
@ -219,8 +219,8 @@ class CStyleChecker:
if check_re.search (line): if check_re.search (line):
self.error (msg) self.error (msg)
if re.search (r"[a-zA-Z0-9][<>!=^/&\|]{1,2}[a-zA-Z0-9]", line): if re.search ("[a-zA-Z0-9][<>!=^/&\|]{1,2}[a-zA-Z0-9]", line):
if not re.search (r".*#include.*[a-zA-Z0-9]/[a-zA-Z]", line): if not re.search (".*#include.*[a-zA-Z0-9]/[a-zA-Z]", line):
self.error ("missing space around operator") self.error ("missing space around operator")
self.last_line_indent = indent self.last_line_indent = indent

View file

@ -55,7 +55,7 @@ if test -n "$cfiles" ; then
fi fi
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Check the copyright notice of all files to be committed. # Check the copyright notice of all files to be commited.
user=`git config --global user.email` user=`git config --global user.email`
year=`date +"%Y"` year=`date +"%Y"`

View file

@ -22,7 +22,7 @@ function(read_definition DEFINITION_FILENAME TEMPLATE_FILENAME DATA)
string(REGEX MATCH "autogen definitions ([a-zA-Z\\._-]+);[${WS}]*" TEMPLATE_MATCH "${DEFINITION_CONTENTS}") string(REGEX MATCH "autogen definitions ([a-zA-Z\\._-]+);[${WS}]*" TEMPLATE_MATCH "${DEFINITION_CONTENTS}")
if (NOT TEMPLATE_MATCH) if (NOT TEMPLATE_MATCH)
message(FATAL_ERROR "${DEFINITION_FILENAME} does not contain an AutoGen definition.") message(FATAL_ERROR "${DEFINITION_FILENAME} doest not contain an AutoGen definition.")
endif() endif()
get_filename_component(DEFINITION_DIR "${DEFINITION_FILENAME}" PATH) get_filename_component(DEFINITION_DIR "${DEFINITION_FILENAME}" PATH)

View file

@ -0,0 +1,92 @@
include (CheckCSourceRuns)
include (CMakePushCheckState)
macro (CLIP_MODE)
if ((NOT DEFINED CPU_CLIPS_NEGATIVE) AND (NOT DEFINED CPU_CLIPS_POSITIVE))
set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion")
set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion")
message (STATUS "Checking processor clipping capabilities...")
if (CMAKE_CROSSCOMPILING)
set (CLIP_MSG "disabled")
set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE})
set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE})
else (NOT CMAKE_CROSSCOMPILING)
cmake_push_check_state ()
set (CMAKE_REQUIRED_QUIET TRUE)
if (LIBM_REQUIRED)
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
endif ()
check_c_source_runs (
"
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = 1.0 * 0x7FFFFFFF ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != 127)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
"
CPU_CLIPS_POSITIVE)
check_c_source_runs (
"
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = -8.0 * 0x10000000 ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != -128)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
"
CPU_CLIPS_NEGATIVE)
cmake_pop_check_state ()
if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE))
set (CLIP_MSG "positive")
elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE))
set (CLIP_MSG "negative")
elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE)
set (CLIP_MSG "both")
else ()
set (CLIP_MSG "none")
endif ()
endif (CMAKE_CROSSCOMPILING)
message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}")
endif ()
endmacro (CLIP_MODE)

View file

@ -4,7 +4,7 @@
# FLAC_INCLUDE_DIRS - where to find FLAC headers. # FLAC_INCLUDE_DIRS - where to find FLAC headers.
# FLAC_LIBRARIES - List of libraries when using libFLAC. # FLAC_LIBRARIES - List of libraries when using libFLAC.
# FLAC_FOUND - True if libFLAC found. # FLAC_FOUND - True if libFLAC found.
# FLAC_DEFINITIONS - FLAC compile definitions # FLAC_DEFINITIONS - FLAC compile definitons
if (FLAC_INCLUDE_DIR) if (FLAC_INCLUDE_DIR)
# Already in cache, be silent # Already in cache, be silent

View file

@ -58,7 +58,7 @@ if (MP3LAME_FOUND)
) )
if (MP3LAME_HIP_LIBRARY AND (NOT TARGET mp3lame::mpghip)) if (MP3LAME_HIP_LIBRARY AND (NOT TARGET mp3lame::mpghip))
add_library (mp3lame::mpghip STATIC IMPORTED) add_library (mp3lame::mpghip STATIC IMPORTED)
set_property (TARGET mp3lame::mpghip PROPERTY IMPORTED_LOCATION "${MP3LAME_HIP_LIBRARY}") set_property (mp3lame::mpghip PROPERTY IMPORTED_LOCATION "${MP3LAME_HIP_LIBRARY}")
set_property (TARGET mp3lame::mp3lame PROPERTY INTERFACE_LINK_LIBRARIES "mp3lame::mpghip") set_property (TARGET mp3lame::mp3lame PROPERTY INTERFACE_LINK_LIBRARIES "mp3lame::mpghip")
endif () endif ()
endif () endif ()

View file

@ -6,6 +6,7 @@ include (CheckTypeSize)
include (TestBigEndian) include (TestBigEndian)
include (TestInline) include (TestInline)
include (ClipMode)
include (TestLargeFiles) include (TestLargeFiles)
include (CheckCPUArch) include (CheckCPUArch)
@ -15,9 +16,10 @@ if (LARGE_FILES_DEFINITIONS)
add_definitions(${LARGE_FILES_DEFINITIONS}) add_definitions(${LARGE_FILES_DEFINITIONS})
endif () endif ()
if (NOT WIN32) if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
find_package (ALSA)
find_package (Sndio) find_package (Sndio)
elseif (NOT WIN32)
find_package (ALSA)
endif () endif ()
if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15)) if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15))
@ -102,7 +104,7 @@ check_type_size (wchar_t SIZEOF_WCHAR_T)
# Never checked # Never checked
# check_type_size (size_t SIZEOF_SIZE_T) # check_type_size (size_t SIZEOF_SIZE_T)
# Used in configure.ac # Used in configre.ac
# check_type_size (double SIZEOF_DOUBLE) # check_type_size (double SIZEOF_DOUBLE)
# check_type_size (float SIZEOF_FLOAT) # check_type_size (float SIZEOF_FLOAT)
# check_type_size (int SIZEOF_INT) # check_type_size (int SIZEOF_INT)
@ -194,6 +196,7 @@ if (CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
endif () endif ()
test_inline () test_inline ()
clip_mode ()
if (MSVC) if (MSVC)
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
@ -249,5 +252,5 @@ if (DEFINED ENABLE_STATIC_RUNTIME)
endif () endif ()
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
find_package (Python REQUIRED) find_package (PythonInterp REQUIRED)
endif() endif()

View file

@ -141,6 +141,9 @@ AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE], [${EXPERIMENTAL_CODE}], [Set to 1
AC_ARG_ENABLE([werror], AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles])]) [AS_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles])])
AC_ARG_ENABLE([cpu-clip],
[AS_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper])])
AC_ARG_ENABLE([bow-docs], AC_ARG_ENABLE([bow-docs],
[AS_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs])]) [AS_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs])])
@ -150,9 +153,6 @@ AC_ARG_ENABLE([sqlite],
AC_ARG_ENABLE([alsa], AC_ARG_ENABLE([alsa],
[AS_HELP_STRING([--disable-alsa], [disable ALSA support (default=autodetect)])], [], [enable_alsa=auto]) [AS_HELP_STRING([--disable-alsa], [disable ALSA support (default=autodetect)])], [], [enable_alsa=auto])
AC_ARG_ENABLE([sndio],
[AS_HELP_STRING([--disable-sndio], [disable Sndio support (default=autodetect)])], [], [enable_sndio=auto])
AC_ARG_ENABLE([external-libs], AC_ARG_ENABLE([external-libs],
[AS_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]])]) [AS_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]])])
@ -264,7 +264,7 @@ AC_SEARCH_LIBS([floor], [m], [], [
AC_CHECK_FUNCS([floor ceil fmod lrint lrintf]) AC_CHECK_FUNCS([floor ceil fmod lrint lrintf])
dnl ==================================================================================== dnl ====================================================================================
dnl Check for requirements for building plugins for other languages/environments. dnl Check for requirements for building plugins for other languages/enviroments.
dnl Octave maths environment http://www.octave.org/ dnl Octave maths environment http://www.octave.org/
AS_IF([test "x$cross_compiling" = "xno"], [ AS_IF([test "x$cross_compiling" = "xno"], [
@ -345,7 +345,7 @@ AS_IF([test -n "$PKG_CONFIG"], [
AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_XIPH_LIBS], [$HAVE_EXTERNAL_XIPH_LIBS], [Will be set to 1 if flac, ogg, vorbis, and opus are available.]) AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_XIPH_LIBS], [$HAVE_EXTERNAL_XIPH_LIBS], [Will be set to 1 if flac, ogg, vorbis, and opus are available.])
dnl ==================================================================================== dnl ====================================================================================
dnl Check for MPEG libraries liblame dnl Check for MPEG libraris liblame
ac_cv_lame="no" ac_cv_lame="no"
ac_cv_mpg123="no" ac_cv_mpg123="no"
@ -402,6 +402,22 @@ AS_IF([test "x$enable_sqlite" != "xno"], [
AC_DEFINE_UNQUOTED([HAVE_SQLITE3], [${ac_cv_sqlite3}], [Set to 1 if you have libsqlite3.]) AC_DEFINE_UNQUOTED([HAVE_SQLITE3], [${ac_cv_sqlite3}], [Set to 1 if you have libsqlite3.])
AM_CONDITIONAL([HAVE_SQLITE3], [test "x$ac_cv_sqlite3" = "x1"]) AM_CONDITIONAL([HAVE_SQLITE3], [test "x$ac_cv_sqlite3" = "x1"])
dnl ====================================================================================
dnl Determine if the processor can do clipping on float to int conversions.
AS_IF([test "x$enable_cpu_clip" != "xno"], [
MN_C_CLIP_MODE
], [
AS_ECHO(["checking processor clipping capabilities... disabled"])
ac_cv_c_clip_positive=0
ac_cv_c_clip_negative=0
])
AC_DEFINE_UNQUOTED([CPU_CLIPS_POSITIVE], [${ac_cv_c_clip_positive}],
[Host processor clips on positive float to int conversion.])
AC_DEFINE_UNQUOTED([CPU_CLIPS_NEGATIVE], [${ac_cv_c_clip_negative}],
[Host processor clips on negative float to int conversion.])
dnl ==================================================================================== dnl ====================================================================================
dnl Host OS specific stuff. dnl Host OS specific stuff.
@ -474,30 +490,17 @@ AS_IF([test "x$enable_alsa" != "xno"], [
]) ])
dnl ==================================================================================== dnl ====================================================================================
dnl Check for Sndio. dnl Check for OpenBSD's sndio.
SNDIO_LIBS=""
HAVE_SNDIO_H=0 HAVE_SNDIO_H=0
AS_IF([test "x$alsa_works" != "xyes"], [ AS_CASE([$host_os],
AS_IF([test "x$enable_sndio" != "xno"], [ [openbsd*], [
PKG_CHECK_MODULES([SNDIO], [sndio], [ AC_CHECK_HEADERS(sndio.h)
HAVE_SNDIO_H=1 AS_IF([test "x$ac_cv_header_sndio_h" = "xyes"], [
ac_cv_sndio="yes" SNDIO_LIBS="-lsndio"
], [ HAVE_SNDIO_H=1
ac_cv_sndio="no"
])
AS_IF([test "x$ac_cv_sndio" = "xno"], [
AS_IF([test "x$enable_sndio" = "xyes"], [
dnl explicitly passed --enable-sndio, hence error out loud and clearly
AC_MSG_ERROR([You explicitly requested sndio support, but sndio could not be found!])
], [
dnl did not explicitly pass --enable-sndio, relying on default automagic on
enable_sndio="no (auto)"
])
])
]) ])
], [
AC_MSG_WARN([You have requested ALSA already, disable ALSA if you want to use Sndio.])
]) ])
AC_DEFINE_UNQUOTED([HAVE_SNDIO_H], [${HAVE_SNDIO_H}], [Set to 1 if <sndio.h> is available.]) AC_DEFINE_UNQUOTED([HAVE_SNDIO_H], [${HAVE_SNDIO_H}], [Set to 1 if <sndio.h> is available.])
@ -529,7 +532,10 @@ AS_IF([test "x$ac_cv_sizeof_double" != "x8"], [
AC_MSG_WARN([[******************************************************************]]) AC_MSG_WARN([[******************************************************************]])
]) ])
AM_CONDITIONAL([HAVE_AUTOGEN], [test "x$ac_cv_prog_HAVE_AUTOGEN" = "xyes"]) AS_IF([test "x$ac_cv_prog_HAVE_AUTOGEN" = "xno"], [
AC_MSG_WARN([[Touching files in directory tests/.]])
touch tests/*.c tests/*.h
])
dnl ==================================================================================== dnl ====================================================================================
dnl Settings for the HTML documentation. dnl Settings for the HTML documentation.
@ -572,9 +578,17 @@ AS_IF([test "x$enable_werror" = "xyes"], [
AC_LANG_POP([C++]) AC_LANG_POP([C++])
]) ])
common_flags="-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wno-format-truncation" common_flags="-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wundef -Wuninitialized -Winit-self"
common_cflags="${common_flags}" common_cflags="${common_flags}"
dnl Clang doesn't know about -Wno-format-truncation
dnl and would spew tons of warnings otherwise.
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
common_cflags+=" -Wno-format-truncation"
])
common_cxxflags="${common_flags}" common_cxxflags="${common_flags}"
AS_IF([test "x$ax_cv_cxx_compiler_vendor" = "xgnu"], [
common_cxxflags+=" -Wno-format-truncation"
])
AX_APPEND_COMPILE_FLAGS([${common_cflags} -Wvla -Wbad-function-cast -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return], [CFLAGS]) AX_APPEND_COMPILE_FLAGS([${common_cflags} -Wvla -Wbad-function-cast -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return], [CFLAGS])

View file

@ -26,8 +26,8 @@ documented) [here](command.md).**
## Synopsis ## Synopsis
```c ```c
#include <stdio.h> #include <stdio.h>;
#include <sndfile.h> #include <sndfile.h>;
``` ```
| Name | Description | | Name | Description |

View file

@ -56,7 +56,7 @@ main (void)
static double data [BUFFER_LEN] ; static double data [BUFFER_LEN] ;
/* A SNDFILE is very much like a FILE in the Standard C library. The /* A SNDFILE is very much like a FILE in the Standard C library. The
** sf_open function return an SNDFILE* pointer when they successfully ** sf_open function return an SNDFILE* pointer when they sucessfully
** open the specified file. ** open the specified file.
*/ */
SNDFILE *infile, *outfile ; SNDFILE *infile, *outfile ;
@ -131,8 +131,8 @@ process_data (double *data, int count, int channels)
/* Process the data here. /* Process the data here.
** If the soundfile contains more then 1 channel you need to take care of ** If the soundfile contains more then 1 channel you need to take care of
** the data interleaving yourself. ** the data interleaving youself.
** Current we just apply a channel dependent gain. ** Current we just apply a channel dependant gain.
*/ */
for (chan = 0 ; chan < channels ; chan ++) for (chan = 0 ; chan < channels ; chan ++)

View file

@ -43,7 +43,7 @@ create_file (const char * fname, int format)
/* /*
** The SndfileHandle object will automatically close the file and ** The SndfileHandle object will automatically close the file and
** release all allocated memory when the object goes out of scope. ** release all allocated memory when the object goes out of scope.
** This is the Resource Acquisition Is Initialization idom. ** This is the Resource Acquisition Is Initailization idom.
** See : http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization ** See : http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
*/ */
} /* create_file */ } /* create_file */

View file

@ -111,7 +111,6 @@ class SndfileHandle
operator bool () const { return (p != SF_NULL) ; } operator bool () const { return (p != SF_NULL) ; }
bool operator == (const SndfileHandle &rhs) const { return (p == rhs.p) ; } bool operator == (const SndfileHandle &rhs) const { return (p == rhs.p) ; }
bool operator != (const SndfileHandle &rhs) const { return !(*this == rhs); }
sf_count_t frames (void) const { return p ? p->sfinfo.frames : 0 ; } sf_count_t frames (void) const { return p ? p->sfinfo.frames : 0 ; }
int format (void) const { return p ? p->sfinfo.format : 0 ; } int format (void) const { return p ? p->sfinfo.format : 0 ; }

View file

@ -10,8 +10,8 @@
# #
# Check whether -D_FORTIFY_SOURCE=2 can be added to CPPFLAGS without macro # Check whether -D_FORTIFY_SOURCE=2 can be added to CPPFLAGS without macro
# redefinition warnings, other cpp warnings or linker. Some distributions # redefinition warnings, other cpp warnings or linker. Some distributions
# (such as Ubuntu or Gentoo Linux) enable _FORTIFY_SOURCE globally in # (such as Gentoo Linux) enable _FORTIFY_SOURCE globally in their
# their compilers, leading to unnecessary warnings in the form of # compilers, leading to unnecessary warnings in the form of
# #
# <command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] # <command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
# <built-in>: note: this is the location of the previous definition # <built-in>: note: this is the location of the previous definition
@ -29,57 +29,19 @@
# LICENSE # LICENSE
# #
# Copyright (c) 2017 David Seifert <soap@gentoo.org> # Copyright (c) 2017 David Seifert <soap@gentoo.org>
# Copyright (c) 2019, 2023 Reini Urban <rurban@cpan.org> # Copyright (c) 2019 Reini Urban <rurban@cpan.org>
# #
# Copying and distribution of this file, with or without modification, are # Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice # permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any # and this notice are preserved. This file is offered as-is, without any
# warranty. # warranty.
#serial 10 #serial 4
AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[ AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
ac_save_cflags=$CFLAGS ac_save_cflags=$CFLAGS
ac_cwerror_flag=yes ac_cwerror_flag=yes
AX_CHECK_COMPILE_FLAG([-Werror],[CFLAGS="$CFLAGS -Werror"]) AX_CHECK_COMPILE_FLAG([-Werror],[CFLAGS="$CFLAGS -Werror"])
ax_add_fortify_3_failed=
AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=3 to CPPFLAGS])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([],
[[
#ifndef _FORTIFY_SOURCE
return 0;
#else
_FORTIFY_SOURCE_already_defined;
#endif
]]
)],
AC_LINK_IFELSE([
AC_LANG_SOURCE([[
#define _FORTIFY_SOURCE 3
#include <string.h>
int main(void) {
char *s = " ";
strcpy(s, "x");
return strlen(s)-1;
}
]]
)],
[
AC_MSG_RESULT([yes])
CFLAGS=$ac_save_cflags
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=3"
], [
AC_MSG_RESULT([no])
ax_add_fortify_3_failed=1
],
),
[
AC_MSG_RESULT([no])
ax_add_fortify_3_failed=1
])
if test -n "$ax_add_fortify_3_failed"
then
AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CPPFLAGS]) AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CPPFLAGS])
AC_LINK_IFELSE([ AC_LINK_IFELSE([
AC_LANG_PROGRAM([], AC_LANG_PROGRAM([],
@ -87,7 +49,7 @@ AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
#ifndef _FORTIFY_SOURCE #ifndef _FORTIFY_SOURCE
return 0; return 0;
#else #else
_FORTIFY_SOURCE_already_defined; this_is_an_error;
#endif #endif
]] ]]
)], )],
@ -95,7 +57,7 @@ AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
AC_LANG_SOURCE([[ AC_LANG_SOURCE([[
#define _FORTIFY_SOURCE 2 #define _FORTIFY_SOURCE 2
#include <string.h> #include <string.h>
int main(void) { int main() {
char *s = " "; char *s = " ";
strcpy(s, "x"); strcpy(s, "x");
return strlen(s)-1; return strlen(s)-1;
@ -115,5 +77,4 @@ AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
CFLAGS=$ac_save_cflags CFLAGS=$ac_save_cflags
]) ])
fi
]) ])

View file

@ -30,12 +30,33 @@
# #
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# #
# Copying and distribution of this file, with or without modification, are # This program is free software: you can redistribute it and/or modify it
# permitted in any medium without royalty provided the copyright notice # under the terms of the GNU General Public License as published by the
# and this notice are preserved. This file is offered as-is, without any # Free Software Foundation, either version 3 of the License, or (at your
# warranty. # option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 7 #serial 6
AC_DEFUN([AX_APPEND_COMPILE_FLAGS], AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) [AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])

View file

@ -23,12 +23,33 @@
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# #
# Copying and distribution of this file, with or without modification, are # This program is free software: you can redistribute it and/or modify it
# permitted in any medium without royalty provided the copyright notice # under the terms of the GNU General Public License as published by the
# and this notice are preserved. This file is offered as-is, without any # Free Software Foundation, either version 3 of the License, or (at your
# warranty. # option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 8 #serial 7
AC_DEFUN([AX_APPEND_FLAG], AC_DEFUN([AX_APPEND_FLAG],
[dnl [dnl

View file

@ -28,12 +28,33 @@
# #
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# #
# Copying and distribution of this file, with or without modification, are # This program is free software: you can redistribute it and/or modify it
# permitted in any medium without royalty provided the copyright notice # under the terms of the GNU General Public License as published by the
# and this notice are preserved. This file is offered as-is, without any # Free Software Foundation, either version 3 of the License, or (at your
# warranty. # option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 7 #serial 6
AC_DEFUN([AX_APPEND_LINK_FLAGS], AC_DEFUN([AX_APPEND_LINK_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) [AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])

View file

@ -29,29 +29,40 @@
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# #
# Copying and distribution of this file, with or without modification, are # This program is free software: you can redistribute it and/or modify it
# permitted in any medium without royalty provided the copyright notice # under the terms of the GNU General Public License as published by the
# and this notice are preserved. This file is offered as-is, without any # Free Software Foundation, either version 3 of the License, or (at your
# warranty. # option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 11 #serial 5
AC_DEFUN([AX_CHECK_COMPILE_FLAG], AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether the _AC_LANG compiler accepts $1], CACHEVAR, [ AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
if test x"m4_case(_AC_LANG, _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
[C], [$GCC],
[C++], [$GXX],
[Fortran], [$GFC],
[Fortran 77], [$G77],
[Objective C], [$GOBJC],
[Objective C++], [$GOBJCXX],
[no])" = xyes ; then
add_gnu_werror="-Werror"
fi
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1 $add_gnu_werror"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])]) [AS_VAR_SET(CACHEVAR,[no])])

View file

@ -29,12 +29,33 @@
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# #
# Copying and distribution of this file, with or without modification, are # This program is free software: you can redistribute it and/or modify it
# permitted in any medium without royalty provided the copyright notice # under the terms of the GNU General Public License as published by the
# and this notice are preserved. This file is offered as-is, without any # Free Software Foundation, either version 3 of the License, or (at your
# warranty. # option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 6 #serial 5
AC_DEFUN([AX_CHECK_LINK_FLAG], AC_DEFUN([AX_CHECK_LINK_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF

View file

@ -8,30 +8,15 @@
# #
# DESCRIPTION # DESCRIPTION
# #
# Determine the vendor of the C, C++ or Fortran compiler. The vendor is # Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun,
# returned in the cache variable $ax_cv_c_compiler_vendor for C, # hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft,
# $ax_cv_cxx_compiler_vendor for C++ or $ax_cv_fc_compiler_vendor for # watcom, etc. The vendor is returned in the cache variable
# (modern) Fortran. The value is one of "intel", "ibm", "pathscale", # $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
# "clang" (LLVM), "cray", "fujitsu", "sdcc", "sx", "nvhpc" (NVIDIA HPC
# Compiler), "portland" (PGI), "gnu" (GCC), "sun" (Oracle Developer
# Studio), "hp", "dec", "borland", "comeau", "kai", "lcc", "sgi",
# "microsoft", "metrowerks", "watcom", "tcc" (Tiny CC) or "unknown" (if
# the compiler cannot be determined).
#
# To check for a Fortran compiler, you must first call AC_FC_PP_SRCEXT
# with an appropriate preprocessor-enabled extension. For example:
#
# AC_LANG_PUSH([Fortran])
# AC_PROG_FC
# AC_FC_PP_SRCEXT([F])
# AX_COMPILER_VENDOR
# AC_LANG_POP([Fortran])
# #
# LICENSE # LICENSE
# #
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2008 Matteo Frigo # Copyright (c) 2008 Matteo Frigo
# Copyright (c) 2018-19 John Zaitseff <J.Zaitseff@zap.org.au>
# #
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
@ -59,61 +44,44 @@
# modified version of the Autoconf Macro, you may extend this special # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 32 #serial 16
AC_DEFUN([AX_COMPILER_VENDOR], [dnl AC_DEFUN([AX_COMPILER_VENDOR],
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [dnl [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
dnl If you modify this list of vendors, please add similar support dnl Please add if possible support to ax_compiler_version.m4
dnl to ax_compiler_version.m4 if at all possible. [# note: don't check for gcc first since some other compilers define __GNUC__
dnl vendors="intel: __ICC,__ECC,__INTEL_COMPILER
dnl Note: Do NOT check for GCC first since some other compilers ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__
dnl define __GNUC__ to remain compatible with it. Compilers that pathscale: __PATHCC__,__PATHSCALE__
dnl are very slow to start (such as Intel) are listed first. clang: __clang__
cray: _CRAYC
vendors=" fujitsu: __FUJITSU
intel: __ICC,__ECC,__INTEL_COMPILER gnu: __GNUC__
ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__,__ibmxl__ sun: __SUNPRO_C,__SUNPRO_CC
pathscale: __PATHCC__,__PATHSCALE__ hp: __HP_cc,__HP_aCC
clang: __clang__ dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
cray: _CRAYC borland: __BORLANDC__,__CODEGEARC__,__TURBOC__
fujitsu: __FUJITSU comeau: __COMO__
sdcc: SDCC,__SDCC kai: __KCC
sx: _SX lcc: __LCC__
nvhpc: __NVCOMPILER sgi: __sgi,sgi
portland: __PGI microsoft: _MSC_VER
gnu: __GNUC__ metrowerks: __MWERKS__
sun: __SUNPRO_C,__SUNPRO_CC,__SUNPRO_F90,__SUNPRO_F95 watcom: __WATCOMC__
hp: __HP_cc,__HP_aCC portland: __PGI
dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER tcc: __TINYC__
borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ unknown: UNKNOWN"
comeau: __COMO__ for ventest in $vendors; do
kai: __KCC case $ventest in
lcc: __LCC__ *:) vendor=$ventest; continue ;;
sgi: __sgi,sgi *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;;
microsoft: _MSC_VER esac
metrowerks: __MWERKS__ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
watcom: __WATCOMC__ #if !($vencpp)
tcc: __TINYC__ thisisanerror;
unknown: UNKNOWN #endif
" ])], [break])
for ventest in $vendors; do done
case $ventest in ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
*:) ])
vendor=$ventest ])
continue
;;
*)
vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")"
;;
esac
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#if !($vencpp)
thisisanerror;
#endif
]])], [break])
done
ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
])
])dnl

View file

@ -36,7 +36,7 @@
# and this notice are preserved. This file is offered as-is, without any # and this notice are preserved. This file is offered as-is, without any
# warranty. # warranty.
#serial 14 #serial 9
# for intel # for intel
AC_DEFUN([_AX_COMPILER_VERSION_INTEL], AC_DEFUN([_AX_COMPILER_VERSION_INTEL],
@ -442,20 +442,6 @@ AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl
ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
]) ])
# for NVHPC
AC_DEFUN([_AX_COMPILER_VERSION_NVHPC],[
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
__NVCOMPILER_MAJOR__,,
AC_MSG_FAILURE([[[$0]] unknown nvhpc major]))
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
__NVCOMPILER_MINOR__,,
AC_MSG_FAILURE([[[$0]] unknown nvhpc minor]))
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
[__NVCOMPILER_PATCHLEVEL__],,
AC_MSG_FAILURE([[[$0]] unknown nvhpc patch level]))
ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
])
# for PGI # for PGI
AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[ AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
@ -474,42 +460,6 @@ AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[
AC_DEFUN([_AX_COMPILER_VERSION_TCC],[ AC_DEFUN([_AX_COMPILER_VERSION_TCC],[
ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`] ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`]
]) ])
# for GNU
AC_DEFUN([_AX_COMPILER_VERSION_SDCC],[
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
/* avoid parse error with comments */
#if(defined(__SDCC_VERSION_MAJOR))
__SDCC_VERSION_MAJOR
#else
SDCC/100
#endif
,,
AC_MSG_FAILURE([[[$0]] unknown sdcc major]))
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
/* avoid parse error with comments */
#if(defined(__SDCC_VERSION_MINOR))
__SDCC_VERSION_MINOR
#else
(SDCC%100)/10
#endif
,,
AC_MSG_FAILURE([[[$0]] unknown sdcc minor]))
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
[
/* avoid parse error with comments */
#if(defined(__SDCC_VERSION_PATCH))
__SDCC_VERSION_PATCH
#elsif(defined(_SDCC_VERSION_PATCHLEVEL))
__SDCC_VERSION_PATCHLEVEL
#else
SDCC%10
#endif
],,
AC_MSG_FAILURE([[[$0]] unknown sdcc patch level]))
ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
])
# main entry point # main entry point
AC_DEFUN([AX_COMPILER_VERSION],[dnl AC_DEFUN([AX_COMPILER_VERSION],[dnl
AC_REQUIRE([AX_COMPILER_VENDOR]) AC_REQUIRE([AX_COMPILER_VENDOR])
@ -535,10 +485,8 @@ AC_DEFUN([AX_COMPILER_VERSION],[dnl
[microsoft],[_AX_COMPILER_VERSION_MICROSOFT], [microsoft],[_AX_COMPILER_VERSION_MICROSOFT],
[metrowerks],[_AX_COMPILER_VERSION_METROWERKS], [metrowerks],[_AX_COMPILER_VERSION_METROWERKS],
[watcom],[_AX_COMPILER_VERSION_WATCOM], [watcom],[_AX_COMPILER_VERSION_WATCOM],
[nvhpc],[_AX_COMPILER_VERSION_NVHPC],
[portland],[_AX_COMPILER_VERSION_PORTLAND], [portland],[_AX_COMPILER_VERSION_PORTLAND],
[tcc],[_AX_COMPILER_VERSION_TCC], [tcc],[_AX_COMPILER_VERSION_TCC],
[sdcc],[_AX_COMPILER_VERSION_SDCC],
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""]) [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""])
]) ])
]) ])

View file

@ -0,0 +1,124 @@
dnl @synopsis MN_C_CLIP_MODE
dnl
dnl Determine the clipping mode when converting float to int.
dnl @version 1.0 May 17 2003
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
dnl
dnl Permission to use, copy, modify, distribute, and sell this file for any
dnl purpose is hereby granted without fee, provided that the above copyright
dnl and this permission notice appear in all copies. No representations are
dnl made about the suitability of this software for any purpose. It is
dnl provided "as is" without express or implied warranty.
dnl Find the clipping mode in the following way:
dnl 1) If we are not cross compiling test it.
dnl 2) IF we are cross compiling, assume that clipping isn't done correctly.
AC_DEFUN([MN_C_CLIP_MODE],
[AC_CACHE_CHECK(processor clipping capabilities,
ac_cv_c_clip_type,
# Initialize to unknown
ac_cv_c_clip_positive=unknown
ac_cv_c_clip_negative=unknown
if test $ac_cv_c_clip_positive = unknown ; then
AC_TRY_RUN(
[[
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = 1.0 * 0x7FFFFFFF ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != 127)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
]],
ac_cv_c_clip_positive=yes,
ac_cv_c_clip_positive=no,
ac_cv_c_clip_positive=unknown
)
AC_TRY_RUN(
[[
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = -8.0 * 0x10000000 ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != -128)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
]],
ac_cv_c_clip_negative=yes,
ac_cv_c_clip_negative=no,
ac_cv_c_clip_negative=unknown
)
fi
if test $ac_cv_c_clip_positive = yes ; then
ac_cv_c_clip_positive=1
else
ac_cv_c_clip_positive=0
fi
if test $ac_cv_c_clip_negative = yes ; then
ac_cv_c_clip_negative=1
else
ac_cv_c_clip_negative=0
fi
[[
case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
"00")
ac_cv_c_clip_type="none"
;;
"10")
ac_cv_c_clip_type="positive"
;;
"01")
ac_cv_c_clip_type="negative"
;;
"11")
ac_cv_c_clip_type="both"
;;
esac
]]
)
]
)# MN_C_CLIP_MODE

View file

@ -1,6 +1,6 @@
dnl @synopsis MN_C99_FLEXIBLE_ARRAY dnl @synopsis MN_C99_FLEXIBLE_ARRAY
dnl dnl
dnl Does the compiler support the 1999 ISO C Standard "struct hack". dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
dnl @version 1.1 Mar 15 2004 dnl @version 1.1 Mar 15 2004
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com> dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
dnl dnl

View file

@ -14,11 +14,11 @@ output APIs. The following table summarizes which audio API is used where:
.Pp .Pp
.Bl -tag -width MacOSX10XXX -compact .Bl -tag -width MacOSX10XXX -compact
.It Linux .It Linux
ALSA, OSS or sndio ALSA or OSS
.It OpenBSD .It OpenBSD
sndio sndio
.It FreeBSD .It FreeBSD
/dev/dsp (OSS) or sndio /dev/dsp (OSS)
.It NetBSD .It NetBSD
/dev/audio /dev/audio
.It Solaris .It Solaris

View file

@ -1,8 +1,6 @@
#ifndef SNDFILE_FUZZ_HEADER_H #ifndef SNDFILE_FUZZ_HEADER_H
#define SNDFILE_FUZZ_HEADER_H #define SNDFILE_FUZZ_HEADER_H
#include <errno.h>
typedef struct typedef struct
{ {
sf_count_t offset ; sf_count_t offset ;
@ -34,9 +32,6 @@ static sf_count_t vfseek (sf_count_t offset, int whence, void *user_data)
break ; break ;
default : default :
// SEEK_DATA and SEEK_HOLE are not supported by this function.
errno = EINVAL ;
return -1 ;
break ; break ;
} }
@ -93,7 +88,8 @@ int sf_init_file(const uint8_t *data,
SNDFILE **sndfile, SNDFILE **sndfile,
VIO_DATA *vio_data, VIO_DATA *vio_data,
SF_VIRTUAL_IO *vio, SF_INFO *sndfile_info) SF_VIRTUAL_IO *vio, SF_INFO *sndfile_info)
{ { float* read_buffer = NULL ;
// Initialize the virtual IO structure. // Initialize the virtual IO structure.
vio->get_filelen = vfget_filelen ; vio->get_filelen = vfget_filelen ;
vio->seek = vfseek ; vio->seek = vfseek ;

View file

@ -51,7 +51,7 @@ usage_exit (const char *progname)
printf ("\nUsage : %s <infile1> <infile2> ... <outfile>\n\n", progname) ; printf ("\nUsage : %s <infile1> <infile2> ... <outfile>\n\n", progname) ;
puts ( puts (
" Create a new output file <outfile> containing the concatenated\n" " Create a new output file <outfile> containing the concatenated\n"
" audio data from <infile1> <infile2> ....\n" " audio data from froms <infile1> <infile2> ....\n"
"\n" "\n"
" The joined file will be encoded in the same format as the data\n" " The joined file will be encoded in the same format as the data\n"
" in infile1, with all the data in subsequent files automatically\n" " in infile1, with all the data in subsequent files automatically\n"

View file

@ -336,7 +336,7 @@ main (int argc, char * argv [])
if ((sfinfo.format & SF_FORMAT_SUBMASK) == SF_FORMAT_GSM610 && sfinfo.samplerate != 8000) if ((sfinfo.format & SF_FORMAT_SUBMASK) == SF_FORMAT_GSM610 && sfinfo.samplerate != 8000)
{ printf ( { printf (
"WARNING: GSM 6.10 data format only supports 8kHz sample rate. The converted\n" "WARNING: GSM 6.10 data format only supports 8kHz sample rate. The converted\n"
"output file will contain the input data converted to the GSM 6.10 data format\n" "ouput file will contain the input data converted to the GSM 6.10 data format\n"
"but not re-sampled.\n" "but not re-sampled.\n"
) ; ) ;
} ; } ;

View file

@ -161,7 +161,7 @@ main (int argc, char *argv [])
info.has_bext_fields = has_bext_fields_set (&info) ; info.has_bext_fields = has_bext_fields_set (&info) ;
if (filenames [0] == NULL) if (filenames [0] == NULL)
{ printf ("Error : No input file specified.\n\n") ; { printf ("Error : No input file specificed.\n\n") ;
exit (1) ; exit (1) ;
} ; } ;

View file

@ -52,26 +52,27 @@
#define ALSA_PCM_NEW_SW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <sys/time.h> #include <sys/time.h>
#endif
#if defined (__ANDROID__)
#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__)
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#elif HAVE_SNDIO_H #elif HAVE_SNDIO_H
#include <sndio.h> #include <sndio.h>
#elif defined (__ANDROID__)
#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__)
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#elif (OS_IS_WIN32 == 1)
#include <windows.h>
#include <mmsystem.h>
#elif (defined (sun) && defined (unix)) || defined(__NetBSD__) #elif (defined (sun) && defined (unix)) || defined(__NetBSD__)
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/audioio.h> #include <sys/audioio.h>
#elif (OS_IS_WIN32 == 1)
#include <windows.h>
#include <mmsystem.h>
#endif #endif
#define SIGNED_SIZEOF(x) ((int) sizeof (x)) #define SIGNED_SIZEOF(x) ((int) sizeof (x))
@ -348,71 +349,13 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
return total ; return total ;
} /* alsa_write_float */ } /* alsa_write_float */
/*------------------------------------------------------------------------------ #endif /* HAVE_ALSA_ASOUNDLIB_H */
** Sndio.
*/
#elif HAVE_SNDIO_H
static void
sndio_play (int argc, char *argv [])
{ struct sio_hdl *hdl ;
struct sio_par par ;
short buffer [BUFFER_LEN] ;
SNDFILE *sndfile ;
SF_INFO sfinfo ;
int k, readcount ;
for (k = 1 ; k < argc ; k++)
{ printf ("Playing %s\n", argv [k]) ;
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
{ puts (sf_strerror (NULL)) ;
continue ;
} ;
if (sfinfo.channels < 1 || sfinfo.channels > 2)
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
continue ;
} ;
if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL)
{ fprintf (stderr, "open sndio device failed") ;
return ;
} ;
sio_initpar (&par) ;
par.rate = sfinfo.samplerate ;
par.pchan = sfinfo.channels ;
par.bits = 16 ;
par.sig = 1 ;
par.le = SIO_LE_NATIVE ;
if (! sio_setpar (hdl, &par) || ! sio_getpar (hdl, &par))
{ fprintf (stderr, "set sndio params failed") ;
return ;
} ;
if (! sio_start (hdl))
{ fprintf (stderr, "sndio start failed") ;
return ;
} ;
while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
sio_write (hdl, buffer, readcount * sizeof (short)) ;
sio_close (hdl) ;
} ;
return ;
} /* sndio_play */
#elif defined (__ANDROID__)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
** Linux/OSS functions for playing a sound. ** Linux/OSS functions for playing a sound.
*/ */
#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__) #if !defined (__ANDROID__) && (defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__))
static int opensoundsys_open_device (int channels, int srate) ; static int opensoundsys_open_device (int channels, int srate) ;
@ -523,6 +466,8 @@ opensoundsys_open_device (int channels, int srate)
return fd ; return fd ;
} /* opensoundsys_open_device */ } /* opensoundsys_open_device */
#endif /* __linux__ */
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
** Mac OS X functions for playing a sound. ** Mac OS X functions for playing a sound.
*/ */
@ -537,7 +482,7 @@ opensoundsys_open_device (int channels, int srate)
** point to data instead of short*. It plain sucks! ** point to data instead of short*. It plain sucks!
*/ */
#elif (OS_IS_WIN32 == 1) #if (OS_IS_WIN32 == 1)
#define WIN32_BUFFER_LEN (1 << 15) #define WIN32_BUFFER_LEN (1 << 15)
@ -563,7 +508,7 @@ static void
win32_play_data (Win32_Audio_Data *audio_data) win32_play_data (Win32_Audio_Data *audio_data)
{ int thisread, readcount ; { int thisread, readcount ;
/* fill a buffer if there is more data and we can read it successfully */ /* fill a buffer if there is more data and we can read it sucessfully */
readcount = (audio_data->remaining > audio_data->bufferlen) ? audio_data->bufferlen : (int) audio_data->remaining ; readcount = (audio_data->remaining > audio_data->bufferlen) ? audio_data->bufferlen : (int) audio_data->remaining ;
short *lpData = (short *) (void *) audio_data->whdr [audio_data->current].lpData ; short *lpData = (short *) (void *) audio_data->whdr [audio_data->current].lpData ;
@ -718,11 +663,73 @@ win32_play (int argc, char *argv [])
} /* win32_play */ } /* win32_play */
#endif /* Win32 */
/*------------------------------------------------------------------------------
** OpenBSD's sndio.
*/
#if HAVE_SNDIO_H
static void
sndio_play (int argc, char *argv [])
{ struct sio_hdl *hdl ;
struct sio_par par ;
short buffer [BUFFER_LEN] ;
SNDFILE *sndfile ;
SF_INFO sfinfo ;
int k, readcount ;
for (k = 1 ; k < argc ; k++)
{ printf ("Playing %s\n", argv [k]) ;
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
{ puts (sf_strerror (NULL)) ;
continue ;
} ;
if (sfinfo.channels < 1 || sfinfo.channels > 2)
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
continue ;
} ;
if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL)
{ fprintf (stderr, "open sndio device failed") ;
return ;
} ;
sio_initpar (&par) ;
par.rate = sfinfo.samplerate ;
par.pchan = sfinfo.channels ;
par.bits = 16 ;
par.sig = 1 ;
par.le = SIO_LE_NATIVE ;
if (! sio_setpar (hdl, &par) || ! sio_getpar (hdl, &par))
{ fprintf (stderr, "set sndio params failed") ;
return ;
} ;
if (! sio_start (hdl))
{ fprintf (stderr, "sndio start failed") ;
return ;
} ;
while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
sio_write (hdl, buffer, readcount * sizeof (short)) ;
sio_close (hdl) ;
} ;
return ;
} /* sndio_play */
#endif /* sndio */
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
** Solaris. ** Solaris.
*/ */
#elif (defined (sun) && defined (unix)) || defined(__NetBSD__) #if (defined (sun) && defined (unix)) || defined(__NetBSD__)
static void static void
solaris_play (int argc, char *argv []) solaris_play (int argc, char *argv [])
@ -752,7 +759,7 @@ solaris_play (int argc, char *argv [])
return ; return ;
} ; } ;
/* Retrieve standard values. */ /* Retrive standard values. */
AUDIO_INITINFO (&audio_info) ; AUDIO_INITINFO (&audio_info) ;
audio_info.play.sample_rate = sfinfo.samplerate ; audio_info.play.sample_rate = sfinfo.samplerate ;
@ -823,35 +830,31 @@ main (int argc, char *argv [])
return 1 ; return 1 ;
} ; } ;
#if HAVE_ALSA_ASOUNDLIB_H #if defined (__ANDROID__)
if (access ("/proc/asound/cards", R_OK) == 0)
alsa_play (argc, argv) ;
else
return EXIT_FAILURE ;
#elif HAVE_SNDIO_H
sndio_play (argc, argv) ;
#elif defined (__ANDROID__)
puts ("*** Playing sound not yet supported on Android.") ; puts ("*** Playing sound not yet supported on Android.") ;
puts ("*** Please feel free to submit a patch.") ; puts ("*** Please feel free to submit a patch.") ;
return EXIT_FAILURE ; return 1 ;
#elif defined (__linux__)
#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__) #if HAVE_ALSA_ASOUNDLIB_H
if (access ("/proc/asound/cards", R_OK) == 0)
alsa_play (argc, argv) ;
else
#endif
opensoundsys_play (argc, argv) ;
#elif defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__)
opensoundsys_play (argc, argv) ; opensoundsys_play (argc, argv) ;
#elif HAVE_SNDIO_H
#elif (OS_IS_WIN32 == 1) sndio_play (argc, argv) ;
win32_play (argc, argv) ;
#elif (defined (sun) && defined (unix)) || defined(__NetBSD__) #elif (defined (sun) && defined (unix)) || defined(__NetBSD__)
solaris_play (argc, argv) ; solaris_play (argc, argv) ;
#elif (OS_IS_WIN32 == 1)
win32_play (argc, argv) ;
#else #else
puts ("*** Playing sound not supported on this platform.") ; puts ("*** Playing sound not supported on this platform.") ;
puts ("*** Please feel free to submit a patch.") ; puts ("*** Please feel free to submit a patch.") ;
return EXIT_FAILURE ; return 1 ;
#endif #endif
return EXIT_SUCCESS ; return 0 ;
} /* main */ } /* main */

View file

@ -45,7 +45,7 @@ with the libsndfile source code distribution.
Organization of Files Organization of Files
--------------------- ---------------------
The regression test program keeps its database file in the directory it The regession test program keeps its database file in the directory it
is run from. In addition, the database only contains information about is run from. In addition, the database only contains information about
the files, not the files themselves. the files, not the files themselves.

View file

@ -533,7 +533,7 @@ int dummy (void) ;
int int
dummy (void) dummy (void)
{ /* { /*
** Empty dummy function so the compiler doesn't whine about an ** Empty dummy fnction so tha compiler doesn't winge about an
** empty file. ** empty file.
*/ */
return 0 ; return 0 ;

View file

@ -26,8 +26,6 @@
Copyright: (c) 2001-2011 Apple, Inc. Copyright: (c) 2001-2011 Apple, Inc.
*/ */
#include "config.h"
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -27,8 +27,6 @@
Copyright: (c) 2001-2011 Apple, Inc. Copyright: (c) 2001-2011 Apple, Inc.
*/ */
#include "config.h"
#include "aglib.h" #include "aglib.h"
#include "ALACBitUtilities.h" #include "ALACBitUtilities.h"
#include "EndianPortable.h" #include "EndianPortable.h"

View file

@ -23,12 +23,9 @@
File: ALACDecoder.cpp File: ALACDecoder.cpp
*/ */
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include "alac_codec.h" #include "alac_codec.h"
@ -41,6 +38,11 @@
#include "ALACBitUtilities.h" #include "ALACBitUtilities.h"
#include "EndianPortable.h" #include "EndianPortable.h"
typedef enum
{ false = 0,
true = 1
} bool ;
// constants/data // constants/data
const uint32_t kMaxBitDepth = 32 ; // max allowed bit depth is 32 const uint32_t kMaxBitDepth = 32 ; // max allowed bit depth is 32

View file

@ -28,11 +28,8 @@
#define DebugMsg printf #define DebugMsg printf
// headers // headers
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include "sfendian.h" #include "sfendian.h"
@ -47,6 +44,12 @@
#include "ALACAudioTypes.h" #include "ALACAudioTypes.h"
#include "EndianPortable.h" #include "EndianPortable.h"
typedef enum
{
false = 0,
true = 1
} bool ;
static void GetConfig (ALAC_ENCODER *p, ALACSpecificConfig * config) ; static void GetConfig (ALAC_ENCODER *p, ALACSpecificConfig * config) ;
static int32_t EncodeStereo (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ; static int32_t EncodeStereo (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ;

View file

@ -27,8 +27,6 @@
Copyright: (c) 2004-2011 Apple, Inc. Copyright: (c) 2004-2011 Apple, Inc.
*/ */
#include "config.h"
#include "matrixlib.h" #include "matrixlib.h"
#include "ALACAudioTypes.h" #include "ALACAudioTypes.h"
#include "shift.h" #include "shift.h"

View file

@ -27,8 +27,6 @@
Copyright: (c) 2004-2011 Apple, Inc. Copyright: (c) 2004-2011 Apple, Inc.
*/ */
#include "config.h"
#include "matrixlib.h" #include "matrixlib.h"
#include "ALACAudioTypes.h" #include "ALACAudioTypes.h"

View file

@ -130,7 +130,7 @@ g723_test (double margin)
} ; } ;
} ; } ;
printf ("\n\nMax error of %d at position %d.\n", max_err, position) ; printf ("\n\nMax error of %d at postion %d.\n", max_err, position) ;
for (k = 0 ; k < BUFFER_SIZE ; k++) for (k = 0 ; k < BUFFER_SIZE ; k++)
{ if (error_function (data [k], orig [k], margin)) { if (error_function (data [k], orig [k], margin))

View file

@ -94,7 +94,7 @@
#define MAC6_MARKER (MAKE_MARKER ('M', 'A', 'C', '6')) #define MAC6_MARKER (MAKE_MARKER ('M', 'A', 'C', '6'))
#define ADP4_MARKER (MAKE_MARKER ('A', 'D', 'P', '4')) #define ADP4_MARKER (MAKE_MARKER ('A', 'D', 'P', '4'))
/* Predefined chunk sizes. */ /* Predfined chunk sizes. */
#define SIZEOF_AIFF_COMM 18 #define SIZEOF_AIFF_COMM 18
#define SIZEOF_AIFC_COMM_MIN 22 #define SIZEOF_AIFC_COMM_MIN 22
#define SIZEOF_AIFC_COMM 24 #define SIZEOF_AIFC_COMM 24
@ -1702,7 +1702,7 @@ static int
aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize) aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize)
{ const char * type_str ; { const char * type_str ;
basc_CHUNK bc ; basc_CHUNK bc ;
sf_count_t count ; int count ;
count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ; count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ;
count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ; count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ;

View file

@ -885,7 +885,7 @@ alac_pakt_encode (const SF_PRIVATE *psf, uint32_t * pakt_size_out)
plac = psf->codec_data ; plac = psf->codec_data ;
info = plac->pakt_info ; info = plac->pakt_info ;
allocated = 100 + 4 * info->count ; allocated = 100 + 2 * info->count ;
if ((data = calloc (1, allocated)) == NULL) if ((data = calloc (1, allocated)) == NULL)
return NULL ; return NULL ;

View file

@ -291,7 +291,6 @@ static int
au_read_header (SF_PRIVATE *psf) au_read_header (SF_PRIVATE *psf)
{ AU_FMT au_fmt ; { AU_FMT au_fmt ;
int marker, dword ; int marker, dword ;
sf_count_t data_end ;
memset (&au_fmt, 0, sizeof (au_fmt)) ; memset (&au_fmt, 0, sizeof (au_fmt)) ;
psf_binheader_readf (psf, "pm", 0, &marker) ; psf_binheader_readf (psf, "pm", 0, &marker) ;
@ -318,15 +317,14 @@ au_read_header (SF_PRIVATE *psf)
return SFE_AU_EMBED_BAD_LEN ; return SFE_AU_EMBED_BAD_LEN ;
} ; } ;
data_end = (sf_count_t) au_fmt.dataoffset + (sf_count_t) au_fmt.datasize ;
if (psf->fileoffset > 0) if (psf->fileoffset > 0)
{ psf->filelength = data_end ; { psf->filelength = au_fmt.dataoffset + au_fmt.datasize ;
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ; psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
} }
else if (au_fmt.datasize == -1 || data_end == psf->filelength) else if (au_fmt.datasize == -1 || au_fmt.dataoffset + au_fmt.datasize == psf->filelength)
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ; psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
else if (data_end < psf->filelength) else if (au_fmt.dataoffset + au_fmt.datasize < psf->filelength)
{ psf->filelength = data_end ; { psf->filelength = au_fmt.dataoffset + au_fmt.datasize ;
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ; psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
} }
else else

View file

@ -162,7 +162,7 @@ avr_read_header (SF_PRIVATE *psf)
psf->endian = SF_ENDIAN_BIG ; psf->endian = SF_ENDIAN_BIG ;
psf->dataoffset = AVR_HDR_SIZE ; psf->dataoffset = AVR_HDR_SIZE ;
psf->datalength = (sf_count_t) hdr.frames * (hdr.rez / 8) ; psf->datalength = hdr.frames * (hdr.rez / 8) ;
if (psf->fileoffset > 0) if (psf->fileoffset > 0)
psf->filelength = AVR_HDR_SIZE + psf->datalength ; psf->filelength = AVR_HDR_SIZE + psf->datalength ;

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/python
# Copyright (C) 2006-2017 Erik de Castro Lopo <erikd@mega-nerd.com> # Copyright (C) 2006-2017 Erik de Castro Lopo <erikd@mega-nerd.com>
# #
@ -36,91 +36,79 @@
# correct. # correct.
import re
import sys
_whitespace_re = re.compile(r"\s+", re.MULTILINE) import re, string, sys
_whitespace_re = re.compile ("\s+", re.MULTILINE)
def find_binheader_writefs(data): def find_binheader_writefs (data):
lst = re.findall( lst = re.findall ('psf_binheader_writef\s*\(\s*[a-zA-Z_]+\s*,\s*\"[^;]+;', data, re.MULTILINE)
r'psf_binheader_writef\s*\(\s*[a-zA-Z_]+\s*,\s*"[^;]+;', data, re.MULTILINE return [_whitespace_re.sub (" ", x) for x in lst]
)
return [_whitespace_re.sub(" ", x) for x in lst]
def find_format_string (s):
def find_format_string(s): fmt = re.search ('"([^"]+)"', s)
fmt = re.search('"([^"]+)"', s)
if not fmt: if not fmt:
print(f"Bad format in :\n\n\t{s}\n\n") print ("Bad format in :\n\n\t%s\n\n" % s)
sys.exit(1) sys.exit (1)
fmt = fmt.groups() fmt = fmt.groups ()
if len(fmt) != 1: if len (fmt) != 1:
print(f"Bad format in :\n\n\t{s}\n\n") print ("Bad format in :\n\n\t%s\n\n" % s)
sys.exit(1) sys.exit (1)
return _whitespace_re.sub("", fmt[0]) return _whitespace_re.sub ("", fmt [0])
def get_param_list (data):
def get_param_list(data): dlist = re.search ("\((.+)\)\s*;", data)
dlist = re.search(r"\((.+)\)\s*;", data) dlist = dlist.groups ()[0]
dlist = dlist.groups()[0]
dlist = dlist.split(",") dlist = dlist.split(",")
dlist = [x.strip() for x in dlist] dlist = [x.strip() for x in dlist]
return dlist[2:] return dlist [2:]
def handle_file (fname):
def handle_file(fname):
errors = 0 errors = 0
data = open(fname, "r").read() data = open (fname, "r").read ()
# return errors # return errors
writefs = find_binheader_writefs(data) writefs = find_binheader_writefs (data)
for item in writefs: for item in writefs:
fmt = find_format_string(item) fmt = find_format_string (item)
params = get_param_list(item) params = get_param_list (item)
param_index = 0 param_index = 0
# print item # print item
for ch in fmt: for ch in fmt:
if ch in "Eet ": if ch in 'Eet ':
continue continue
if ch == "b": if ch == 'b':
if ( if params [param_index][:4] == "BHWv" and params [param_index + 1][:4] == "BHWz":
params[param_index][:4] == "BHWv"
and params[param_index + 1][:4] == "BHWz"
):
param_index += 2 param_index += 2
continue continue
if "BHW" + ch == params[param_index][:4]: if "BHW" + ch == params [param_index][:4]:
param_index += 1 param_index += 1
continue continue
if errors == 0: if errors == 0: sys.stdout.write ("\n")
sys.stdout.write("\n") print ("\n%s: error for format specifier '%c' (index %d) in:\n %s\n" % (fname, ch, param_index, item))
print(
f"\n{fname}: error for format specifier '{ch}' (index {param_index}) in:\n {item}\n"
)
errors += 1 errors += 1
# Break out of 'for ch in fmt' loop # Break out of 'for ch in fmt' loop
break break
return errors return errors
#===============================================================================
# =============================================================================== if len (sys.argv) > 1:
sys.stdout.write ("\n binheader_writef_check : ")
if len(sys.argv) > 1: sys.stdout.flush ()
sys.stdout.write("\n binheader_writef_check : ")
sys.stdout.flush()
errors = 0 errors = 0
for fname in sys.argv[1:]: for fname in sys.argv [1:]:
errors += handle_file(fname) errors += handle_file (fname)
if errors > 0: if errors > 0:
print(f"\nErrors : {errors}\n") print ("\nErrors : %d\n" % errors)
sys.exit(1) sys.exit (1)
print ("ok\n")
print("ok\n")

View file

@ -18,7 +18,6 @@
#include <config.h> #include <config.h>
#include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#if HAVE_UNISTD_H #if HAVE_UNISTD_H
@ -991,7 +990,6 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
double *doubleptr ; double *doubleptr ;
char c ; char c ;
int byte_count = 0, count = 0 ; int byte_count = 0, count = 0 ;
int read_bytes = 0 ;
if (! format) if (! format)
return psf_ftell (psf) ; return psf_ftell (psf) ;
@ -1000,7 +998,6 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
while ((c = *format++)) while ((c = *format++))
{ {
read_bytes = 0 ;
if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16)) if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
break ; break ;
@ -1017,7 +1014,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
intptr = va_arg (argptr, unsigned int*) ; intptr = va_arg (argptr, unsigned int*) ;
*intptr = 0 ; *intptr = 0 ;
ucptr = (unsigned char*) intptr ; ucptr = (unsigned char*) intptr ;
read_bytes = header_read (psf, ucptr, sizeof (int)) ; byte_count += header_read (psf, ucptr, sizeof (int)) ;
*intptr = GET_MARKER (ucptr) ; *intptr = GET_MARKER (ucptr) ;
break ; break ;
@ -1025,7 +1022,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
intptr = va_arg (argptr, unsigned int*) ; intptr = va_arg (argptr, unsigned int*) ;
*intptr = 0 ; *intptr = 0 ;
ucptr = (unsigned char*) intptr ; ucptr = (unsigned char*) intptr ;
read_bytes = header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ; byte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;
{ int k ; { int k ;
intdata = 0 ; intdata = 0 ;
for (k = 0 ; k < 16 ; k++) for (k = 0 ; k < 16 ; k++)
@ -1037,14 +1034,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case '1' : case '1' :
charptr = va_arg (argptr, char*) ; charptr = va_arg (argptr, char*) ;
*charptr = 0 ; *charptr = 0 ;
read_bytes = header_read (psf, charptr, sizeof (char)) ; byte_count += header_read (psf, charptr, sizeof (char)) ;
break ; break ;
case '2' : /* 2 byte value with the current endian-ness */ case '2' : /* 2 byte value with the current endian-ness */
shortptr = va_arg (argptr, unsigned short*) ; shortptr = va_arg (argptr, unsigned short*) ;
*shortptr = 0 ; *shortptr = 0 ;
ucptr = (unsigned char*) shortptr ; ucptr = (unsigned char*) shortptr ;
read_bytes = header_read (psf, ucptr, sizeof (short)) ; byte_count += header_read (psf, ucptr, sizeof (short)) ;
if (psf->rwf_endian == SF_ENDIAN_BIG) if (psf->rwf_endian == SF_ENDIAN_BIG)
*shortptr = GET_BE_SHORT (ucptr) ; *shortptr = GET_BE_SHORT (ucptr) ;
else else
@ -1054,7 +1051,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case '3' : /* 3 byte value with the current endian-ness */ case '3' : /* 3 byte value with the current endian-ness */
intptr = va_arg (argptr, unsigned int*) ; intptr = va_arg (argptr, unsigned int*) ;
*intptr = 0 ; *intptr = 0 ;
read_bytes = header_read (psf, sixteen_bytes, 3) ; byte_count += header_read (psf, sixteen_bytes, 3) ;
if (psf->rwf_endian == SF_ENDIAN_BIG) if (psf->rwf_endian == SF_ENDIAN_BIG)
*intptr = GET_BE_3BYTE (sixteen_bytes) ; *intptr = GET_BE_3BYTE (sixteen_bytes) ;
else else
@ -1065,7 +1062,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
intptr = va_arg (argptr, unsigned int*) ; intptr = va_arg (argptr, unsigned int*) ;
*intptr = 0 ; *intptr = 0 ;
ucptr = (unsigned char*) intptr ; ucptr = (unsigned char*) intptr ;
read_bytes = header_read (psf, ucptr, sizeof (int)) ; byte_count += header_read (psf, ucptr, sizeof (int)) ;
if (psf->rwf_endian == SF_ENDIAN_BIG) if (psf->rwf_endian == SF_ENDIAN_BIG)
*intptr = psf_get_be32 (ucptr, 0) ; *intptr = psf_get_be32 (ucptr, 0) ;
else else
@ -1075,7 +1072,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case '8' : /* 8 byte value with the current endian-ness */ case '8' : /* 8 byte value with the current endian-ness */
countptr = va_arg (argptr, sf_count_t *) ; countptr = va_arg (argptr, sf_count_t *) ;
*countptr = 0 ; *countptr = 0 ;
read_bytes = header_read (psf, sixteen_bytes, 8) ; byte_count += header_read (psf, sixteen_bytes, 8) ;
if (psf->rwf_endian == SF_ENDIAN_BIG) if (psf->rwf_endian == SF_ENDIAN_BIG)
countdata = psf_get_be64 (sixteen_bytes, 0) ; countdata = psf_get_be64 (sixteen_bytes, 0) ;
else else
@ -1086,7 +1083,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case 'f' : /* Float conversion */ case 'f' : /* Float conversion */
floatptr = va_arg (argptr, float *) ; floatptr = va_arg (argptr, float *) ;
*floatptr = 0.0 ; *floatptr = 0.0 ;
read_bytes = header_read (psf, floatptr, sizeof (float)) ; byte_count += header_read (psf, floatptr, sizeof (float)) ;
if (psf->rwf_endian == SF_ENDIAN_BIG) if (psf->rwf_endian == SF_ENDIAN_BIG)
*floatptr = float32_be_read ((unsigned char*) floatptr) ; *floatptr = float32_be_read ((unsigned char*) floatptr) ;
else else
@ -1096,7 +1093,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case 'd' : /* double conversion */ case 'd' : /* double conversion */
doubleptr = va_arg (argptr, double *) ; doubleptr = va_arg (argptr, double *) ;
*doubleptr = 0.0 ; *doubleptr = 0.0 ;
read_bytes = header_read (psf, doubleptr, sizeof (double)) ; byte_count += header_read (psf, doubleptr, sizeof (double)) ;
if (psf->rwf_endian == SF_ENDIAN_BIG) if (psf->rwf_endian == SF_ENDIAN_BIG)
*doubleptr = double64_be_read ((unsigned char*) doubleptr) ; *doubleptr = double64_be_read ((unsigned char*) doubleptr) ;
else else
@ -1120,7 +1117,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
charptr = va_arg (argptr, char*) ; charptr = va_arg (argptr, char*) ;
count = va_arg (argptr, size_t) ; count = va_arg (argptr, size_t) ;
memset (charptr, 0, count) ; memset (charptr, 0, count) ;
read_bytes = header_read (psf, charptr, count) ; byte_count += header_read (psf, charptr, count) ;
break ; break ;
case 'G' : case 'G' :
@ -1131,7 +1128,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count)) if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))
break ; break ;
read_bytes = header_gets (psf, charptr, count) ; byte_count += header_gets (psf, charptr, count) ;
break ; break ;
case 'z' : case 'z' :
@ -1155,7 +1152,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
case 'j' : /* Seek to position from current position. */ case 'j' : /* Seek to position from current position. */
count = va_arg (argptr, size_t) ; count = va_arg (argptr, size_t) ;
header_seek (psf, count, SEEK_CUR) ; header_seek (psf, count, SEEK_CUR) ;
read_bytes = count ; byte_count += count ;
break ; break ;
case '!' : /* Clear buffer, forcing re-read. */ case '!' : /* Clear buffer, forcing re-read. */
@ -1167,17 +1164,8 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
psf->error = SFE_INTERNAL ; psf->error = SFE_INTERNAL ;
break ; break ;
} ; } ;
if (read_bytes > 0 && byte_count > (INT_MAX - read_bytes))
{ psf_log_printf (psf, "Header size exceeds INT_MAX. Aborting.", c) ;
psf->error = SFE_INTERNAL ;
break ;
} else
{ byte_count += read_bytes ;
} ; } ;
} ; /*end while*/
va_end (argptr) ; va_end (argptr) ;
return byte_count ; return byte_count ;
@ -1773,14 +1761,18 @@ psf_f2i_clip_array (const float *src, int *dest, int count, int normalize)
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
#if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i] = 0x7FFFFFFF ; { dest [i] = 0x7FFFFFFF ;
continue ; continue ;
} ; } ;
#endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000)) if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i] = 0x80000000 ; { dest [i] = 0x80000000 ;
continue ; continue ;
} ; } ;
#endif
dest [i] = psf_lrintf (scaled_value) ; dest [i] = psf_lrintf (scaled_value) ;
} ; } ;
@ -1790,7 +1782,7 @@ psf_f2i_clip_array (const float *src, int *dest, int count, int normalize)
void void
psf_d2i_array (const double *src, int *dest, int count, int normalize) psf_d2i_array (const double *src, int *dest, int count, int normalize)
{ double normfact ; { double normfact ;
normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
@ -1807,14 +1799,18 @@ psf_d2i_clip_array (const double *src, int *dest, int count, int normalize)
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
#if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i] = 0x7FFFFFFF ; { dest [i] = 0x7FFFFFFF ;
continue ; continue ;
} ; } ;
#endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000)) if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i] = 0x80000000 ; { dest [i] = 0x80000000 ;
continue ; continue ;
} ; } ;
#endif
dest [i] = psf_lrint (scaled_value) ; dest [i] = psf_lrint (scaled_value) ;
} ; } ;

View file

@ -102,7 +102,7 @@
#define SF_MAX_CHANNELS 1024 #define SF_MAX_CHANNELS 1024
/* /*
* Macros for splitting the format file of SF_INFO into container type, * Macros for spliting the format file of SF_INFO into container type,
** codec type and endian-ness. ** codec type and endian-ness.
*/ */
#define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK) #define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK)
@ -305,7 +305,7 @@ void *psf_memdup (const void *src, size_t n) ;
int psf_isprint (int ch) ; int psf_isprint (int ch) ;
/*======================================================================================= /*=======================================================================================
** SF_PRIVATE struct - a pointer to this struct is passed back to the caller of the ** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the
** sf_open_XXXX functions. The caller however has no knowledge of the struct's ** sf_open_XXXX functions. The caller however has no knowledge of the struct's
** contents. ** contents.
*/ */
@ -402,7 +402,7 @@ typedef struct sf_private_tag
int scale_int_float ; int scale_int_float ;
/* Variables for handling pipes. */ /* Vairables for handling pipes. */
int is_pipe ; /* True if file is a pipe. */ int is_pipe ; /* True if file is a pipe. */
sf_count_t pipeoffset ; /* Number of bytes read from a pipe. */ sf_count_t pipeoffset ; /* Number of bytes read from a pipe. */
@ -439,7 +439,7 @@ typedef struct sf_private_tag
sf_count_t datalength ; /* Length in bytes of the audio data. */ sf_count_t datalength ; /* Length in bytes of the audio data. */
sf_count_t dataend ; /* Offset to file tailer. */ sf_count_t dataend ; /* Offset to file tailer. */
sf_count_t blockwidth ; /* Size in bytes of one set of interleaved samples. */ int blockwidth ; /* Size in bytes of one set of interleaved samples. */
int bytewidth ; /* Size in bytes of one sample (one channel). */ int bytewidth ; /* Size in bytes of one sample (one channel). */
void *dither ; void *dither ;
@ -947,7 +947,7 @@ int psf_find_write_chunk (WRITE_CHUNKS * pchk, const char * marker) ;
** **
** See : http://www.gratisoft.us/todd/papers/strlcpy.html ** See : http://www.gratisoft.us/todd/papers/strlcpy.html
** **
** These functions are available on *BSD, but are not available everywhere so we ** These functions are available on *BSD, but are not avaialble everywhere so we
** implement them here. ** implement them here.
** **
** The argument order has been changed to that of strncpy/strncat to cause ** The argument order has been changed to that of strncpy/strncat to cause
@ -964,7 +964,7 @@ void psf_strlcpy (char *dest, size_t n, const char *src) ;
static inline int psf_lrintf (float x) static inline int psf_lrintf (float x)
{ {
#ifdef USE_SSE2 #ifdef USE_SSE2
return _mm_cvtss_si32 (_mm_load_ss (&x)) ; return _mm_cvtss_si32 (_mm_load_ss (&x)) ;
#else #else
return lrintf (x) ; return lrintf (x) ;
#endif #endif
@ -973,7 +973,7 @@ static inline int psf_lrintf (float x)
static inline int psf_lrint (double x) static inline int psf_lrint (double x)
{ {
#ifdef USE_SSE2 #ifdef USE_SSE2
return _mm_cvtsd_si32 (_mm_load_sd (&x)) ; return _mm_cvtsd_si32 (_mm_load_sd (&x)) ;
#else #else
return lrint (x) ; return lrint (x) ;
#endif #endif

View file

@ -1,6 +1,12 @@
/* Set to 1 if the compile is GNU GCC. */ /* Set to 1 if the compile is GNU GCC. */
#cmakedefine01 COMPILER_IS_GCC #cmakedefine01 COMPILER_IS_GCC
/* Target processor clips on negative float to int conversion. */
#cmakedefine01 CPU_CLIPS_NEGATIVE
/* Target processor clips on positive float to int conversion. */
#cmakedefine01 CPU_CLIPS_POSITIVE
/* Target processor is big endian. */ /* Target processor is big endian. */
#cmakedefine01 CPU_IS_BIG_ENDIAN #cmakedefine01 CPU_IS_BIG_ENDIAN

View file

@ -461,7 +461,7 @@ double64_get_capability (SF_PRIVATE *psf)
unsigned char c [8] ; unsigned char c [8] ;
} data ; } data ;
data.d = 1.234567890123456789 ; /* Some arbitrary value. */ data.d = 1.234567890123456789 ; /* Some abitrary value. */
if (! psf->ieee_replace) if (! psf->ieee_replace)
{ /* If this test is true ints and floats are compatible and little endian. */ { /* If this test is true ints and floats are compatible and little endian. */
@ -517,9 +517,9 @@ d2i_clip_array (const double *src, int count, int *dest, double scale)
{ for (int i = 0 ; i < count ; i++) { for (int i = 0 ; i < count ; i++)
{ float tmp = scale * src [i] ; { float tmp = scale * src [i] ;
if (tmp > (1.0 * INT_MAX)) if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
dest [i] = INT_MAX ; dest [i] = INT_MAX ;
else if (tmp < (-1.0 * INT_MAX)) else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
dest [i] = INT_MIN ; dest [i] = INT_MIN ;
else else
dest [i] = psf_lrint (tmp) ; dest [i] = psf_lrint (tmp) ;

View file

@ -370,7 +370,7 @@ dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count)
if (bit_count < 0) if (bit_count < 0)
{ get_dwm = SF_TRUE ; { get_dwm = SF_TRUE ;
/* modify bit_count to ensure we have enough bits for finding dwm. */ /* modify bit_count to ensure we have enought bits for finding dwm. */
bit_count = pdwvw->dwm_maxsize ; bit_count = pdwvw->dwm_maxsize ;
} ; } ;
@ -428,7 +428,7 @@ static void
dwvw_encode_store_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int data, int new_bits) dwvw_encode_store_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int data, int new_bits)
{ int byte ; { int byte ;
/* Shift the bits into the reservoir. */ /* Shift the bits into the resevoir. */
pdwvw->bits = arith_shift_left (pdwvw->bits, new_bits) | (data & (arith_shift_left (1, new_bits) - 1)) ; pdwvw->bits = arith_shift_left (pdwvw->bits, new_bits) | (data & (arith_shift_left (1, new_bits) - 1)) ;
pdwvw->bit_count += new_bits ; pdwvw->bit_count += new_bits ;

View file

@ -66,7 +66,7 @@
#define SENSIBLE_SIZE (0x40000000) #define SENSIBLE_SIZE (0x40000000)
/* /*
** Neat solution to the Win32/OS2 binary file flag requirement. ** Neat solution to the Win32/OS2 binary file flage requirement.
** If O_BINARY isn't already defined by the inclusion of the system ** If O_BINARY isn't already defined by the inclusion of the system
** headers, set it to zero. ** headers, set it to zero.
*/ */

View file

@ -413,7 +413,7 @@ float32_get_capability (SF_PRIVATE *psf)
unsigned char c [4] ; unsigned char c [4] ;
} data ; } data ;
data.f = (float) 1.23456789 ; /* Some arbitrary value. */ data.f = (float) 1.23456789 ; /* Some abitrary value. */
if (! psf->ieee_replace) if (! psf->ieee_replace)
{ /* If this test is true ints and floats are compatible and little endian. */ { /* If this test is true ints and floats are compatible and little endian. */
@ -468,9 +468,9 @@ f2i_clip_array (const float *src, int count, int *dest, float scale)
{ for (int i = 0 ; i < count ; i++) { for (int i = 0 ; i < count ; i++)
{ float tmp = scale * src [i] ; { float tmp = scale * src [i] ;
if (tmp > (1.0 * INT_MAX)) if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
dest [i] = INT_MAX ; dest [i] = INT_MAX ;
else if (tmp < (-1.0 * INT_MAX)) else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
dest [i] = INT_MIN ; dest [i] = INT_MIN ;
else else
dest [i] = psf_lrintf (tmp) ; dest [i] = psf_lrintf (tmp) ;

View file

@ -187,7 +187,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
** to avoid having to branch when pulling apart the nibbles. ** to avoid having to branch when pulling apart the nibbles.
*/ */
count = ((samplesperblock - 2) | 7) + 2 ; count = ((samplesperblock - 2) | 7) + 2 ;
pimasize = sizeof (IMA_ADPCM_PRIVATE) + psf->sf.channels * (blockalign + samplesperblock + sizeof (short) * count) ; pimasize = sizeof (IMA_ADPCM_PRIVATE) + psf->sf.channels * (blockalign + samplesperblock + sizeof(short) * count) ;
if (! (pima = calloc (1, pimasize))) if (! (pima = calloc (1, pimasize)))
return SFE_MALLOC_FAILED ; return SFE_MALLOC_FAILED ;
@ -238,7 +238,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
case SF_FORMAT_AIFF : case SF_FORMAT_AIFF :
psf_log_printf (psf, "still need to check block count\n") ; psf_log_printf (psf, "still need to check block count\n") ;
pima->decode_block = aiff_ima_decode_block ; pima->decode_block = aiff_ima_decode_block ;
psf->sf.frames = (sf_count_t) pima->samplesperblock * pima->blocks / pima->channels ; psf->sf.frames = pima->samplesperblock * pima->blocks / pima->channels ;
break ; break ;
default : default :
@ -262,6 +262,9 @@ aiff_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
int chan, k, diff, bytecode, predictor ; int chan, k, diff, bytecode, predictor ;
short step, stepindx, *sampledata ; short step, stepindx, *sampledata ;
static int count = 0 ;
count ++ ;
pima->blockcount += pima->channels ; pima->blockcount += pima->channels ;
pima->samplecount = 0 ; pima->samplecount = 0 ;
@ -388,7 +391,7 @@ aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
static int static int
wavlike_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) wavlike_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
{ int chan, k, predictor, blockindx, indx, indxstart, diff ; { int chan, k, predictor, blockindx, indx, indxstart, diff ;
short step, bytecode, stepindx [2] = { 0 } ; short step, bytecode, stepindx [2] = { 0 };
pima->blockcount ++ ; pima->blockcount ++ ;
pima->samplecount = 0 ; pima->samplecount = 0 ;
@ -1002,3 +1005,4 @@ ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
return total ; return total ;
} /* ima_write_d */ } /* ima_write_d */

View file

@ -171,35 +171,35 @@ ircam_read_header (SF_PRIVATE *psf)
switch (encoding) switch (encoding)
{ case IRCAM_PCM_16 : { case IRCAM_PCM_16 :
psf->bytewidth = 2 ; psf->bytewidth = 2 ;
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ; psf->blockwidth = psf->sf.channels * psf->bytewidth ;
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_16 ; psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_16 ;
break ; break ;
case IRCAM_PCM_32 : case IRCAM_PCM_32 :
psf->bytewidth = 4 ; psf->bytewidth = 4 ;
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ; psf->blockwidth = psf->sf.channels * psf->bytewidth ;
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_32 ; psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_32 ;
break ; break ;
case IRCAM_FLOAT : case IRCAM_FLOAT :
psf->bytewidth = 4 ; psf->bytewidth = 4 ;
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ; psf->blockwidth = psf->sf.channels * psf->bytewidth ;
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT ; psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT ;
break ; break ;
case IRCAM_ALAW : case IRCAM_ALAW :
psf->bytewidth = 1 ; psf->bytewidth = 1 ;
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ; psf->blockwidth = psf->sf.channels * psf->bytewidth ;
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ALAW ; psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ALAW ;
break ; break ;
case IRCAM_ULAW : case IRCAM_ULAW :
psf->bytewidth = 1 ; psf->bytewidth = 1 ;
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ; psf->blockwidth = psf->sf.channels * psf->bytewidth ;
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ULAW ; psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ULAW ;
break ; break ;

View file

@ -104,7 +104,7 @@ mat4_open (SF_PRIVATE *psf)
psf->container_close = mat4_close ; psf->container_close = mat4_close ;
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ; psf->blockwidth = psf->bytewidth * psf->sf.channels ;
switch (subformat) switch (subformat)
{ case SF_FORMAT_PCM_16 : { case SF_FORMAT_PCM_16 :
@ -320,7 +320,7 @@ mat4_read_header (SF_PRIVATE *psf)
psf->filelength - psf->dataoffset, psf->sf.channels * psf->sf.frames * psf->bytewidth) ; psf->filelength - psf->dataoffset, psf->sf.channels * psf->sf.frames * psf->bytewidth) ;
} }
else if ((psf->filelength - psf->dataoffset) > psf->sf.channels * psf->sf.frames * psf->bytewidth) else if ((psf->filelength - psf->dataoffset) > psf->sf.channels * psf->sf.frames * psf->bytewidth)
psf->dataend = psf->dataoffset + (sf_count_t) rows * (sf_count_t) cols * psf->bytewidth ; psf->dataend = psf->dataoffset + rows * cols * psf->bytewidth ;
psf->datalength = psf->filelength - psf->dataoffset - psf->dataend ; psf->datalength = psf->filelength - psf->dataoffset - psf->dataend ;

View file

@ -114,7 +114,7 @@ mat5_open (SF_PRIVATE *psf)
psf->container_close = mat5_close ; psf->container_close = mat5_close ;
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ; psf->blockwidth = psf->bytewidth * psf->sf.channels ;
switch (subformat) switch (subformat)
{ case SF_FORMAT_PCM_U8 : { case SF_FORMAT_PCM_U8 :

View file

@ -48,36 +48,36 @@
/* Variable names from ITU G.726 spec */ /* Variable names from ITU G.726 spec */
struct nms_adpcm_state struct nms_adpcm_state
{ /* Log of the step size multiplier. Operated on by codewords. */ { /* Log of the step size multiplier. Operated on by codewords. */
short yl ; int yl ;
/* Quantizer step size multiplier. Generated from yl. */ /* Quantizer step size multiplier. Generated from yl. */
short y ; int y ;
/* Coefficients of the pole predictor */ /* Coefficents of the pole predictor */
short a [2] ; int a [2] ;
/* Coefficients of the zero predictor */ /* Coefficents of the zero predictor */
short b [6] ; int b [6] ;
/* Previous quantized deltas (multiplied by 2^14) */ /* Previous quantized deltas (multiplied by 2^14) */
short d_q [7] ; int d_q [7] ;
/* d_q [x] + s_ez [x], used by the pole-predictor for signs only. */ /* d_q [x] + s_ez [x], used by the pole-predictor for signs only. */
short p [3] ; int p [3] ;
/* Previous reconstructed signal values. */ /* Previous reconstructed signal values. */
short s_r [2] ; int s_r [2] ;
/* Zero predictor components of the signal estimate. */ /* Zero predictor components of the signal estimate. */
short s_ez ; int s_ez ;
/* Signal estimate, (including s_ez). */ /* Signal estimate, (including s_ez). */
short s_e ; int s_e ;
/* The most recent codeword (enc:generated, dec:inputted) */ /* The most recent codeword (enc:generated, dec:inputted) */
char Ik ; int Ik ;
char parity ; int parity ;
/* /*
** Offset into code tables for the bitrate. ** Offset into code tables for the bitrate.
@ -109,7 +109,7 @@ typedef struct
} NMS_ADPCM_PRIVATE ; } NMS_ADPCM_PRIVATE ;
/* Pre-computed exponential interval used in the antilog approximation. */ /* Pre-computed exponential interval used in the antilog approximation. */
static unsigned short table_expn [] = static unsigned int table_expn [] =
{ 0x4000, 0x4167, 0x42d5, 0x444c, 0x45cb, 0x4752, 0x48e2, 0x4a7a, { 0x4000, 0x4167, 0x42d5, 0x444c, 0x45cb, 0x4752, 0x48e2, 0x4a7a,
0x4c1b, 0x4dc7, 0x4f7a, 0x5138, 0x52ff, 0x54d1, 0x56ac, 0x5892, 0x4c1b, 0x4dc7, 0x4f7a, 0x5138, 0x52ff, 0x54d1, 0x56ac, 0x5892,
0x5a82, 0x5c7e, 0x5e84, 0x6096, 0x62b4, 0x64dd, 0x6712, 0x6954, 0x5a82, 0x5c7e, 0x5e84, 0x6096, 0x62b4, 0x64dd, 0x6712, 0x6954,
@ -117,21 +117,21 @@ static unsigned short table_expn [] =
} ; } ;
/* Table mapping codewords to scale factor deltas. */ /* Table mapping codewords to scale factor deltas. */
static short table_scale_factor_step [] = static int table_scale_factor_step [] =
{ 0x0, 0x0, 0x0, 0x0, 0x4b0, 0x0, 0x0, 0x0, /* 2-bit */ { 0x0, 0x0, 0x0, 0x0, 0x4b0, 0x0, 0x0, 0x0, /* 2-bit */
-0x3c, 0x0, 0x90, 0x0, 0x2ee, 0x0, 0x898, 0x0, /* 3-bit */ -0x3c, 0x0, 0x90, 0x0, 0x2ee, 0x0, 0x898, 0x0, /* 3-bit */
-0x30, 0x12, 0x6b, 0xc8, 0x188, 0x2e0, 0x551, 0x1150, /* 4-bit */ -0x30, 0x12, 0x6b, 0xc8, 0x188, 0x2e0, 0x551, 0x1150, /* 4-bit */
} ; } ;
/* Table mapping codewords to quantized delta interval steps. */ /* Table mapping codewords to quantized delta interval steps. */
static unsigned short table_step [] = static unsigned int table_step [] =
{ 0x73F, 0, 0, 0, 0x1829, 0, 0, 0, /* 2-bit */ { 0x73F, 0, 0, 0, 0x1829, 0, 0, 0, /* 2-bit */
0x3EB, 0, 0xC18, 0, 0x1581, 0, 0x226E, 0, /* 3-bit */ 0x3EB, 0, 0xC18, 0, 0x1581, 0, 0x226E, 0, /* 3-bit */
0x20C, 0x635, 0xA83, 0xF12, 0x1418, 0x19E3, 0x211A, 0x2BBA, /* 4-bit */ 0x20C, 0x635, 0xA83, 0xF12, 0x1418, 0x19E3, 0x211A, 0x2BBA, /* 4-bit */
} ; } ;
/* Binary search lookup table for quantizing using table_step. */ /* Binary search lookup table for quantizing using table_step. */
static short table_step_search [] = static int table_step_search [] =
{ 0, 0x1F6D, 0, -0x1F6D, 0, 0, 0, 0, /* 2-bit */ { 0, 0x1F6D, 0, -0x1F6D, 0, 0, 0, 0, /* 2-bit */
0x1008, 0x1192, 0, -0x219A, 0x1656, -0x1656, 0, 0, /* 3-bit */ 0x1008, 0x1192, 0, -0x219A, 0x1656, -0x1656, 0, 0, /* 3-bit */
0x872, 0x1277, -0x8E6, -0x232B, 0xD06, -0x17D7, -0x11D3, 0, /* 4-bit */ 0x872, 0x1277, -0x8E6, -0x232B, 0xD06, -0x17D7, -0x11D3, 0, /* 4-bit */
@ -179,23 +179,23 @@ static sf_count_t nms_adpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
** Maps [1,20480] to [1,1024] in an exponential relationship. This is ** Maps [1,20480] to [1,1024] in an exponential relationship. This is
** approximately ret = b^exp where b = e^(ln(1024)/ln(20480)) ~= 1.0003385 ** approximately ret = b^exp where b = e^(ln(1024)/ln(20480)) ~= 1.0003385
*/ */
static inline short static inline int
nms_adpcm_antilog (short exp) nms_adpcm_antilog (int exp)
{ int_fast32_t r ; { int ret ;
r = 0x1000 ; ret = 0x1000 ;
r += (((int_fast32_t) (exp & 0x3f) * 0x166b) >> 12) ; ret += (((exp & 0x3f) * 0x166b) >> 12) ;
r *= table_expn [(exp & 0x7c0) >> 6] ; ret *= table_expn [(exp & 0x7c0) >> 6] ;
r >>= (26 - (exp >> 11)) ; ret >>= (26 - (exp >> 11)) ;
return (short) r ; return ret ;
} /* nms_adpcm_antilog */ } /* nms_adpcm_antilog */
static void static void
nms_adpcm_update (struct nms_adpcm_state *s) nms_adpcm_update (struct nms_adpcm_state *s)
{ /* Variable names from ITU G.726 spec */ { /* Variable names from ITU G.726 spec */
short a1ul, fa1 ; int a1ul ;
int_fast32_t se ; int fa1 ;
int i ; int i ;
/* Decay and Modify the scale factor in the log domain based on the codeword. */ /* Decay and Modify the scale factor in the log domain based on the codeword. */
@ -206,7 +206,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
s->yl = 20480 ; s->yl = 20480 ;
s->y = nms_adpcm_antilog (s->yl) ; s->y = nms_adpcm_antilog (s->yl) ;
/* Update the zero predictor coefficients. */ /* Update the zero predictor coefficents. */
for (i = 0 ; i < 6 ; i++) for (i = 0 ; i < 6 ; i++)
{ s->b [i] = (s->b [i] * 0xff) >> 8 ; { s->b [i] = (s->b [i] * 0xff) >> 8 ;
if ((s->d_q [0] ^ s->d_q [i + 1]) >= 0) if ((s->d_q [0] ^ s->d_q [i + 1]) >= 0)
@ -215,14 +215,14 @@ nms_adpcm_update (struct nms_adpcm_state *s)
s->b [i] -= 128 ; s->b [i] -= 128 ;
} }
/* Update the pole predictor coefficients. */ /* Update the pole predictor coefficents. */
fa1 = s->a [0] >> 5 ; fa1 = s->a [0] >> 5 ;
if (fa1 < -256) if (fa1 < -256)
fa1 = -256 ; fa1 = -256 ;
else if (fa1 > 256) else if (fa1 > 256)
fa1 = 256 ; fa1 = 256 ;
s->a [0] = (s->a [0] * 0xff) >> 8 ; s->a [0] = (0xff * s->a [0]) >> 8 ;
if (s->p [0] != 0 && s->p [1] != 0 && ((s->p [0] ^ s->p [1]) < 0)) if (s->p [0] != 0 && s->p [1] != 0 && ((s->p [0] ^ s->p [1]) < 0))
s->a [0] -= 192 ; s->a [0] -= 192 ;
else else
@ -230,7 +230,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
fa1 = -fa1 ; fa1 = -fa1 ;
} }
s->a [1] = fa1 + ((s->a [1] * 0xfe) >> 8) ; s->a [1] = fa1 + ((0xfe * s->a [1]) >> 8) ;
if (s->p [0] != 0 && s->p [2] != 0 && ((s->p [0] ^ s->p [2]) < 0)) if (s->p [0] != 0 && s->p [2] != 0 && ((s->p [0] ^ s->p [2]) < 0))
s->a [1] -= 128 ; s->a [1] -= 128 ;
else else
@ -250,18 +250,19 @@ nms_adpcm_update (struct nms_adpcm_state *s)
s->a [0] = a1ul ; s->a [0] = a1ul ;
} ; } ;
/* Compute the zero predictor estimate and rotate past deltas. */ /* Compute the zero predictor estimate. Rotate past deltas too. */
se = 0 ; s->s_ez = 0 ;
for (i = 5 ; i >= 0 ; i--) for (i = 5 ; i >= 0 ; i--)
{ se += (int_fast32_t) s->d_q [i] * s->b [i] ; { s->s_ez += s->d_q [i] * s->b [i] ;
s->d_q [i + 1] = s->d_q [i] ; s->d_q [i + 1] = s->d_q [i] ;
} ; } ;
s->s_ez = se >> 14 ;
/* Complete the signal estimate. */ /* Compute the signal estimate. */
se += (int_fast32_t) s->a [0] * s->s_r [0] ; s->s_e = s->a [0] * s->s_r [0] + s->a [1] * s->s_r [1] + s->s_ez ;
se += (int_fast32_t) s->a [1] * s->s_r [1] ;
s->s_e = se >> 14 ; /* Return to scale */
s->s_ez >>= 14 ;
s->s_e >>= 14 ;
/* Rotate members to prepare for next iteration. */ /* Rotate members to prepare for next iteration. */
s->s_r [1] = s->s_r [0] ; s->s_r [1] = s->s_r [0] ;
@ -273,7 +274,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
static int16_t static int16_t
nms_adpcm_reconstruct_sample (struct nms_adpcm_state *s, uint8_t I) nms_adpcm_reconstruct_sample (struct nms_adpcm_state *s, uint8_t I)
{ /* Variable names from ITU G.726 spec */ { /* Variable names from ITU G.726 spec */
int_fast32_t dqx ; int dqx ;
/* /*
** The ordering of the 12-bit right-shift is a precision loss. It agrees ** The ordering of the 12-bit right-shift is a precision loss. It agrees
@ -307,17 +308,17 @@ nms_adpcm_codec_init (struct nms_adpcm_state *s, enum nms_enc_type type)
/* /*
** nms_adpcm_encode_sample() ** nms_adpcm_encode_sample()
** **
** Encode a linear 16-bit pcm sample into a 2, 3, or 4 bit NMS-ADPCM codeword ** Encode a linear 16-bit pcm sample into a 2,3, or 4 bit NMS-ADPCM codeword
** using and updating the predictor state. ** using and updating the predictor state.
*/ */
static uint8_t static uint8_t
nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl) nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl)
{ /* Variable names from ITU G.726 spec */ { /* Variable names from ITU G.726 spec */
int_fast32_t d ; int d ;
uint8_t I ; uint8_t I ;
/* Down scale the sample from 16 => ~14 bits. */ /* Down scale the sample from 16 => ~14 bits. */
sl = ((int_fast32_t) sl * 0x1fdf) / 0x7fff ; sl = (sl * 0x1fdf) / 0x7fff ;
/* Compute estimate, and delta from actual value */ /* Compute estimate, and delta from actual value */
nms_adpcm_update (s) ; nms_adpcm_update (s) ;
@ -406,7 +407,7 @@ nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl)
*/ */
static int16_t static int16_t
nms_adpcm_decode_sample (struct nms_adpcm_state *s, uint8_t I) nms_adpcm_decode_sample (struct nms_adpcm_state *s, uint8_t I)
{ int_fast32_t sl ; { int sl ;
nms_adpcm_update (s) ; nms_adpcm_update (s) ;
sl = nms_adpcm_reconstruct_sample (s, I) ; sl = nms_adpcm_reconstruct_sample (s, I) ;
@ -1090,7 +1091,7 @@ nms_adpcm_init (SF_PRIVATE *psf)
else else
pnms->blocks_total = psf->datalength / (pnms->shortsperblock * sizeof (short)) ; pnms->blocks_total = psf->datalength / (pnms->shortsperblock * sizeof (short)) ;
psf->sf.frames = (sf_count_t) pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ; psf->sf.frames = pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ;
psf->codec_close = nms_adpcm_close ; psf->codec_close = nms_adpcm_close ;
psf->seek = nms_adpcm_seek ; psf->seek = nms_adpcm_seek ;

View file

@ -211,16 +211,12 @@ ogg_read_first_page (SF_PRIVATE *psf, OGG_PRIVATE *odata)
int int
ogg_write_page (SF_PRIVATE *psf, ogg_page *page) ogg_write_page (SF_PRIVATE *psf, ogg_page *page)
{ int n ; { int bytes ;
n = psf_fwrite (page->header, 1, page->header_len, psf) ; bytes = psf_fwrite (page->header, 1, page->header_len, psf) ;
if (n == page->header_len) bytes += psf_fwrite (page->body, 1, page->body_len, psf) ;
n += psf_fwrite (page->body, 1, page->body_len, psf) ;
if (n != page->body_len + page->header_len) return bytes == page->header_len + page->body_len ;
return -1 ;
return n ;
} /* ogg_write_page */ } /* ogg_write_page */
sf_count_t sf_count_t
@ -387,7 +383,7 @@ ogg_stream_unpack_page (SF_PRIVATE *psf, OGG_PRIVATE *odata)
/* /*
** Unpack all the packets on the page. It is undocumented (like much of ** Unpack all the packets on the page. It is undocumented (like much of
** libOgg behavior) but all packets from a page read into the stream are ** libOgg behavior) but all packets from a page read into the stream are
** guaranteed to remain valid in memory until a new page is read into the ** guarenteed to remain valid in memory until a new page is read into the
** stream. ** stream.
*/ */
for (i = 1 ; ; i++) for (i = 1 ; ; i++)
@ -823,7 +819,7 @@ ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE* odata)
break ; break ;
} ; } ;
psf_log_printf (psf, "This Ogg bitstream contains some unknown data type.\n") ; psf_log_printf (psf, "This Ogg bitstream contains some uknown data type.\n") ;
return SFE_UNIMPLEMENTED ; return SFE_UNIMPLEMENTED ;
} /* ogg_stream_classify */ } /* ogg_stream_classify */

View file

@ -151,7 +151,7 @@ int ogg_stream_unpack_page (SF_PRIVATE *psf, OGG_PRIVATE *odata) ;
/* /*
** Seek within the Ogg virtual bitstream for a page containing target_gp. ** Seek within the Ogg virtual bitstream for a page containing target_gp.
** Performs a bisection search. If not found exactly, the best result is ** Preforms a bisection search. If not found exactly, the best result is
** returned in *best_gp. Found page is loaded into the virtual bitstream, ** returned in *best_gp. Found page is loaded into the virtual bitstream,
** ready for unpacking. Arguments pcm_start and pcm_end are the highest and ** ready for unpacking. Arguments pcm_start and pcm_end are the highest and
** lowest granule positions of the file. begin and end are the file offset ** lowest granule positions of the file. begin and end are the file offset

View file

@ -72,7 +72,7 @@
** - Samples shall refer to discrete PCM values, regardless of any channel ** - Samples shall refer to discrete PCM values, regardless of any channel
** considerations. This is the same as what libsndfile calls samples. ** considerations. This is the same as what libsndfile calls samples.
** - Samples/channel shall refer to groups of samples, one for each channel. ** - Samples/channel shall refer to groups of samples, one for each channel.
** This is what Opus calls samples, and what libsndfile calls frames. It ** This is what Opus calles samples, and what libsndfile calles frames. It
** has the advantage that its name is also the formula to calculate it. ** has the advantage that its name is also the formula to calculate it.
** **
** **
@ -827,16 +827,15 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
/* The first page MUST only contain the header, so flush it out now */ /* The first page MUST only contain the header, so flush it out now */
ogg_stream_packetin (&odata->ostream, &op) ; ogg_stream_packetin (&odata->ostream, &op) ;
while (ogg_stream_flush (&odata->ostream, &odata->opage)) for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
{ nn = ogg_write_page (psf, &odata->opage) ; { if (! (nn = ogg_write_page (psf, &odata->opage)))
if (nn < 0)
{ psf_log_printf (psf, "Opus : Failed to write header!\n") ; { psf_log_printf (psf, "Opus : Failed to write header!\n") ;
if (psf->error) if (psf->error)
return psf->error ; return psf->error ;
return SFE_INTERNAL ; return SFE_INTERNAL ;
} ; } ;
psf->dataoffset += nn ; psf->dataoffset += nn ;
} ; }
/* /*
** Metadata Tags (manditory) ** Metadata Tags (manditory)
@ -851,16 +850,15 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
vorbiscomment_write_tags (psf, &op, &opustags_ident, opus_get_version_string (), - (OGG_OPUS_COMMENT_PAD)) ; vorbiscomment_write_tags (psf, &op, &opustags_ident, opus_get_version_string (), - (OGG_OPUS_COMMENT_PAD)) ;
op.packetno = 2 ; op.packetno = 2 ;
ogg_stream_packetin (&odata->ostream, &op) ; ogg_stream_packetin (&odata->ostream, &op) ;
while (ogg_stream_flush (&odata->ostream, &odata->opage)) for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
{ nn = ogg_write_page (psf, &odata->opage) ; { if (! (nn = ogg_write_page (psf, &odata->opage)))
if (nn < 0)
{ psf_log_printf (psf, "Opus : Failed to write comments!\n") ; { psf_log_printf (psf, "Opus : Failed to write comments!\n") ;
if (psf->error) if (psf->error)
return psf->error ; return psf->error ;
return SFE_INTERNAL ; return SFE_INTERNAL ;
} ; } ;
psf->dataoffset += nn ; psf->dataoffset += nn ;
} ; }
return 0 ; return 0 ;
} /* ogg_opus_write_header */ } /* ogg_opus_write_header */
@ -1134,8 +1132,7 @@ ogg_opus_write_out (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus)
if (nbytes > 0) if (nbytes > 0)
{ oopus->u.encode.last_segments -= ogg_page_segments (&odata->opage) ; { oopus->u.encode.last_segments -= ogg_page_segments (&odata->opage) ;
oopus->pg_pos = oopus->pkt_pos ; oopus->pg_pos = oopus->pkt_pos ;
if (ogg_write_page (psf, &odata->opage) < 0) ogg_write_page (psf, &odata->opage) ;
return -1 ;
} }
else else
break ; break ;
@ -1451,7 +1448,7 @@ ogg_opus_analyze_file (SF_PRIVATE *psf)
oopus->pkt_pos = oopus->pg_pos - gp ; oopus->pkt_pos = oopus->pg_pos - gp ;
} }
else if (gp < oopus->pg_pos) else if (gp < oopus->pg_pos)
{ psf_log_printf (psf, "Opus : First data page is also the last, and granule position has an (ambiguous) offset.\n") ; { psf_log_printf (psf, "Opus : First data page is also the last, and granule position has an (ambigious) offset.\n") ;
return SFE_MALFORMED_FILE ; return SFE_MALFORMED_FILE ;
} ; } ;
oopus->u.decode.gp_start = oopus->pkt_pos ; oopus->u.decode.gp_start = oopus->pkt_pos ;
@ -1514,7 +1511,7 @@ ogg_opus_null_read (SF_PRIVATE *psf, sf_count_t offset)
return total ; return total ;
/* /*
** Ignore pre-skip skipping. The preskip was accounted for in the ** Ignore pre-skip skipping. The preskip was accounted for in the
** argument to offset, so we need to count it. ** arugment to offset, so we need to count it.
*/ */
oopus->loc = 0 ; oopus->loc = 0 ;
} ; } ;
@ -1612,7 +1609,7 @@ ogg_opus_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
/* Figure out the current position granule pos. Use the start of the /* Figure out the current position granule pos. Use the start of the
* current buffer, to avoid backwards seeking if the target is on the page * current buffer, to avoid backwards seeking if the target is on the page
* but before the current location. */ * but before the current locaiton. */
oopus->loc = 0 ; oopus->loc = 0 ;
current_gp = oopus->pkt_pos - (uint64_t) (oopus->len * oopus->sr_factor) ; current_gp = oopus->pkt_pos - (uint64_t) (oopus->len * oopus->sr_factor) ;
@ -1647,7 +1644,7 @@ ogg_opus_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
if (ret < 0) if (ret < 0)
{ /* { /*
** Page seek failed, what to do? Could be bad data. We can ** Page seek failed, what to do? Could be bad data. We can
** either fall-back to manual seeking or bail. Manual seeking ** either fall-back to manual seeking or bail. Manaul seeking
** from the beginning has the advantage of finding where the ** from the beginning has the advantage of finding where the
** file goes bad. ** file goes bad.
*/ */

View file

@ -79,7 +79,7 @@ vorbiscomment_read_tags (SF_PRIVATE *psf, ogg_packet *packet, vorbiscomment_iden
/* /*
** The smallest possible header is the ident string length plus two 4-byte ** The smallest possible header is the ident string length plus two 4-byte
** integers, (vendor string length, tags count.) ** integers, (vender string length, tags count.)
*/ */
if (packet->bytes < (ident ? ident->length : 0) + 4 + 4) if (packet->bytes < (ident ? ident->length : 0) + 4 + 4)
return SFE_MALFORMED_FILE ; return SFE_MALFORMED_FILE ;

View file

@ -82,6 +82,28 @@
/* How many seconds in the future to not bother bisection searching for. */ /* How many seconds in the future to not bother bisection searching for. */
#define VORBIS_SEEK_THRESHOLD 2 #define VORBIS_SEEK_THRESHOLD 2
typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ;
static int vorbis_read_header (SF_PRIVATE *psf) ;
static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
static int vorbis_close (SF_PRIVATE *psf) ;
static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
static int vorbis_byterate (SF_PRIVATE *psf) ;
static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ;
static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ;
static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ;
static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ;
typedef struct typedef struct
{ int id ; { int id ;
const char *name ; const char *name ;
@ -123,45 +145,6 @@ typedef struct
sf_count_t last_page ; sf_count_t last_page ;
} VORBIS_PRIVATE ; } VORBIS_PRIVATE ;
typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ;
static int vorbis_read_header (SF_PRIVATE *psf) ;
static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
static int vorbis_close (SF_PRIVATE *psf) ;
static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
static int vorbis_byterate (SF_PRIVATE *psf) ;
static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ;
static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ;
static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ;
static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
static int vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) ;
static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ;
static void vorbis_log_error (SF_PRIVATE *psf, int error) ;
static void
vorbis_log_error(SF_PRIVATE *psf, int error) {
switch (error)
{ case 0: return;
case OV_EIMPL: psf->error = SFE_UNIMPLEMENTED ; break ;
case OV_ENOTVORBIS: psf->error = SFE_MALFORMED_FILE ; break ;
case OV_EBADHEADER: psf->error = SFE_MALFORMED_FILE ; break ;
case OV_EVERSION: psf->error = SFE_UNSUPPORTED_ENCODING ; break ;
case OV_EFAULT:
case OV_EINVAL:
default: psf->error = SFE_INTERNAL ;
} ;
} ;
static int static int
vorbis_read_header (SF_PRIVATE *psf) vorbis_read_header (SF_PRIVATE *psf)
{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
@ -397,6 +380,7 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{ ogg_packet header ; { ogg_packet header ;
ogg_packet header_comm ; ogg_packet header_comm ;
ogg_packet header_code ; ogg_packet header_code ;
int result ;
vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ; vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ;
ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */ ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */
@ -406,9 +390,9 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
/* This ensures the actual /* This ensures the actual
* audio data will start on a new page, as per spec * audio data will start on a new page, as per spec
*/ */
while (ogg_stream_flush (&odata->ostream, &odata->opage)) while ((result = ogg_stream_flush (&odata->ostream, &odata->opage)) != 0)
if (ogg_write_page (psf, &odata->opage) < 0) { ogg_write_page (psf, &odata->opage) ;
return -1 ; } ;
} }
return 0 ; return 0 ;
@ -418,25 +402,44 @@ static int
vorbis_close (SF_PRIVATE *psf) vorbis_close (SF_PRIVATE *psf)
{ OGG_PRIVATE* odata = psf->container_data ; { OGG_PRIVATE* odata = psf->container_data ;
VORBIS_PRIVATE *vdata = psf->codec_data ; VORBIS_PRIVATE *vdata = psf->codec_data ;
int ret = 0 ;
if (odata == NULL || vdata == NULL) if (odata == NULL || vdata == NULL)
return 0 ; return 0 ;
/* Clean up this logical bitstream ; before exit we should see if we're /* Clean up this logical bitstream ; before exit we shuld see if we're
** followed by another [chained]. */ ** followed by another [chained]. */
if (psf->file.mode == SFM_WRITE) if (psf->file.mode == SFM_WRITE)
{ {
if (psf->write_current <= 0) if (psf->write_current <= 0)
ret = vorbis_write_header (psf, 0) ; vorbis_write_header (psf, 0) ;
if (ret == 0) vorbis_analysis_wrote (&vdata->vdsp, 0) ;
{ /* A write of zero samples tells Vorbis the stream is done and to while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
flush. */ {
ret = vorbis_write_samples (psf, odata, vdata, 0) ;
} ; /* analysis, assume we want to use bitrate management */
} ; vorbis_analysis (&vdata->vblock, NULL) ;
vorbis_bitrate_addblock (&vdata->vblock) ;
while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket))
{ /* weld the packet into the bitstream */
ogg_stream_packetin (&odata->ostream, &odata->opacket) ;
/* write out pages (if any) */
while (!odata->eos)
{ int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
if (result == 0) break ;
ogg_write_page (psf, &odata->opage) ;
/* this could be set above, but for illustrative purposes, I do
it here (to show that vorbis does know where the stream ends) */
if (ogg_page_eos (&odata->opage)) odata->eos = 1 ;
}
}
}
}
/* ogg_page and ogg_packet structs always point to storage in /* ogg_page and ogg_packet structs always point to storage in
libvorbis. They are never freed or manipulated directly */ libvorbis. They are never freed or manipulated directly */
@ -446,7 +449,7 @@ vorbis_close (SF_PRIVATE *psf)
vorbis_comment_clear (&vdata->vcomment) ; vorbis_comment_clear (&vdata->vcomment) ;
vorbis_info_clear (&vdata->vinfo) ; vorbis_info_clear (&vdata->vinfo) ;
return ret ; return 0 ;
} /* vorbis_close */ } /* vorbis_close */
int int
@ -685,40 +688,33 @@ vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens)
/*============================================================================== /*==============================================================================
*/ */
static int static void
vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames)
{ int ret ; {
vorbis_analysis_wrote (&vdata->vdsp, in_frames) ;
if ((ret = vorbis_analysis_wrote (&vdata->vdsp, in_frames)) != 0)
return ret ;
/* /*
** Vorbis does some data preanalysis, then divvies up blocks for ** Vorbis does some data preanalysis, then divvies up blocks for
** more involved (potentially parallel) processing. Get a single ** more involved (potentially parallel) processing. Get a single
** block for encoding now. ** block for encoding now.
*/ */
while ((ret = vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock)) == 1) while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
{ {
/* analysis, assume we want to use bitrate management */ /* analysis, assume we want to use bitrate management */
if ((ret = vorbis_analysis (&vdata->vblock, NULL)) != 0) vorbis_analysis (&vdata->vblock, NULL) ;
return ret ; vorbis_bitrate_addblock (&vdata->vblock) ;
if ((ret = vorbis_bitrate_addblock (&vdata->vblock)) != 0)
return ret ;
while ((ret = vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) == 1) while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket))
{ {
/* weld the packet into the bitstream */ /* weld the packet into the bitstream */
if ((ret = ogg_stream_packetin (&odata->ostream, &odata->opacket)) != 0) ogg_stream_packetin (&odata->ostream, &odata->opacket) ;
return ret ;
/* write out pages (if any) */ /* write out pages (if any) */
while (!odata->eos) while (!odata->eos)
{ ret = ogg_stream_pageout (&odata->ostream, &odata->opage) ; { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
if (ret == 0) if (result == 0)
break ; break ;
ogg_write_page (psf, &odata->opage) ;
if (ogg_write_page (psf, &odata->opage) < 0)
return -1 ;
/* This could be set above, but for illustrative purposes, I do /* This could be set above, but for illustrative purposes, I do
** it here (to show that vorbis does know where the stream ends) */ ** it here (to show that vorbis does know where the stream ends) */
@ -726,22 +722,16 @@ vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata
odata->eos = 1 ; odata->eos = 1 ;
} ; } ;
} ; } ;
if (ret != 0)
return ret ;
} ; } ;
if (ret != 0)
return ret ;
vdata->gp += in_frames ; vdata->gp += in_frames ;
return 0 ;
} /* vorbis_write_data */ } /* vorbis_write_data */
static sf_count_t static sf_count_t
vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens) vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
{ {
int i, m, j = 0, ret ; int i, m, j = 0 ;
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
int in_frames = lens / psf->sf.channels ; int in_frames = lens / psf->sf.channels ;
@ -750,17 +740,14 @@ vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
for (m = 0 ; m < psf->sf.channels ; m++) for (m = 0 ; m < psf->sf.channels ; m++)
buffer [m][i] = (float) (ptr [j++]) / 32767.0f ; buffer [m][i] = (float) (ptr [j++]) / 32767.0f ;
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames))) vorbis_write_samples (psf, odata, vdata, in_frames) ;
{ vorbis_log_error (psf, ret) ;
return 0 ;
} ;
return lens ; return lens ;
} /* vorbis_write_s */ } /* vorbis_write_s */
static sf_count_t static sf_count_t
vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens) vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
{ int i, m, j = 0, ret ; { int i, m, j = 0 ;
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
int in_frames = lens / psf->sf.channels ; int in_frames = lens / psf->sf.channels ;
@ -769,17 +756,14 @@ vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
for (m = 0 ; m < psf->sf.channels ; m++) for (m = 0 ; m < psf->sf.channels ; m++)
buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ; buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ;
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames))) vorbis_write_samples (psf, odata, vdata, in_frames) ;
{ vorbis_log_error (psf, ret) ;
return 0 ;
} ;
return lens ; return lens ;
} /* vorbis_write_i */ } /* vorbis_write_i */
static sf_count_t static sf_count_t
vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens) vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
{ int i, m, j = 0, ret ; { int i, m, j = 0 ;
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
int in_frames = lens / psf->sf.channels ; int in_frames = lens / psf->sf.channels ;
@ -788,17 +772,14 @@ vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
for (m = 0 ; m < psf->sf.channels ; m++) for (m = 0 ; m < psf->sf.channels ; m++)
buffer [m][i] = ptr [j++] ; buffer [m][i] = ptr [j++] ;
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0) vorbis_write_samples (psf, odata, vdata, in_frames) ;
{ vorbis_log_error (psf, ret) ;
return 0 ;
} ;
return lens ; return lens ;
} /* vorbis_write_f */ } /* vorbis_write_f */
static sf_count_t static sf_count_t
vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens) vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
{ int i, m, j = 0, ret ; { int i, m, j = 0 ;
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
int in_frames = lens / psf->sf.channels ; int in_frames = lens / psf->sf.channels ;
@ -807,10 +788,7 @@ vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
for (m = 0 ; m < psf->sf.channels ; m++) for (m = 0 ; m < psf->sf.channels ; m++)
buffer [m][i] = (float) ptr [j++] ; buffer [m][i] = (float) ptr [j++] ;
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0) vorbis_write_samples (psf, odata, vdata, in_frames) ;
{ vorbis_log_error (psf, ret) ;
return 0 ;
} ;
return lens ; return lens ;
} /* vorbis_write_d */ } /* vorbis_write_d */
@ -906,7 +884,7 @@ vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp)
return 0 ; return 0 ;
/* Search for a position a half large-block before our target. As Vorbis is /* Search for a position a half large-block before our target. As Vorbis is
** lapped, every sample position comes from two blocks, the "left" half of ** lapped, every sample position come from two blocks, the "left" half of
** one block and the "right" half of the previous block. The granule ** one block and the "right" half of the previous block. The granule
** position of an Ogg page of a Vorbis stream is the sample offset of the ** position of an Ogg page of a Vorbis stream is the sample offset of the
** last finished sample in the stream that can be decoded from a page. A ** last finished sample in the stream that can be decoded from a page. A

View file

@ -350,7 +350,7 @@ paf24_init (SF_PRIVATE *psf)
(PAF24_BLOCK_SIZE + PAF24_SAMPLES_PER_BLOCK * sizeof (int)) ; (PAF24_BLOCK_SIZE + PAF24_SAMPLES_PER_BLOCK * sizeof (int)) ;
/* /*
** Not exactly sure why this needs to be here but the tests ** Not exatly sure why this needs to be here but the tests
** fail without it. ** fail without it.
*/ */
psf->last_op = 0 ; psf->last_op = 0 ;

View file

@ -127,7 +127,7 @@ pcm_init (SF_PRIVATE *psf)
return SFE_INTERNAL ; return SFE_INTERNAL ;
} ; } ;
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ; psf->blockwidth = psf->bytewidth * psf->sf.channels ;
if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8) if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8)
chars = SF_CHARS_SIGNED ; chars = SF_CHARS_SIGNED ;
@ -1782,20 +1782,20 @@ static void
f2sc_clip_array (const float *src, signed char *dest, int count, int normalize) f2sc_clip_array (const float *src, signed char *dest, int count, int normalize)
{ float normfact, scaled_value ; { float normfact, scaled_value ;
normfact = normalize ? (8.0 * 0x10) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7F)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i] = 127 ; { dest [i] = 127 ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x10)) if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i] = -128 ; { dest [i] = -128 ;
continue ; continue ;
} ; } ;
dest [i] = psf_lrintf (scaled_value) ; dest [i] = psf_lrintf (scaled_value) >> 24 ;
} ; } ;
} /* f2sc_clip_array */ } /* f2sc_clip_array */
@ -1841,20 +1841,20 @@ static void
f2uc_clip_array (const float *src, unsigned char *dest, int count, int normalize) f2uc_clip_array (const float *src, unsigned char *dest, int count, int normalize)
{ float normfact, scaled_value ; { float normfact, scaled_value ;
normfact = normalize ? (8.0 * 0x10) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7F)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i] = 0xFF ; { dest [i] = 0xFF ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x10)) if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i] = 0 ; { dest [i] = 0 ;
continue ; continue ;
} ; } ;
dest [i] = psf_lrintf (scaled_value) + 128 ; dest [i] = (psf_lrintf (scaled_value) >> 24) + 128 ;
} ; } ;
} /* f2uc_clip_array */ } /* f2uc_clip_array */
@ -1907,25 +1907,25 @@ f2bes_clip_array (const float *src, short *dest, int count, int normalize)
float normfact, scaled_value ; float normfact, scaled_value ;
int value ; int value ;
normfact = normalize ? (8.0 * 0x1000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ ucptr [1] = 0xFF ; { ucptr [1] = 0xFF ;
ucptr [0] = 0x7F ; ucptr [0] = 0x7F ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x1000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [1] = 0x00 ; { ucptr [1] = 0x00 ;
ucptr [0] = 0x80 ; ucptr [0] = 0x80 ;
continue ; continue ;
} ; } ;
value = psf_lrintf (scaled_value) ; value = psf_lrintf (scaled_value) ;
ucptr [1] = value ; ucptr [1] = value >> 16 ;
ucptr [0] = value >> 8 ; ucptr [0] = value >> 24 ;
} ; } ;
} /* f2bes_clip_array */ } /* f2bes_clip_array */
@ -1978,25 +1978,25 @@ f2les_clip_array (const float *src, short *dest, int count, int normalize)
float normfact, scaled_value ; float normfact, scaled_value ;
int value ; int value ;
normfact = normalize ? (8.0 * 0x1000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ ucptr [0] = 0xFF ; { ucptr [0] = 0xFF ;
ucptr [1] = 0x7F ; ucptr [1] = 0x7F ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x1000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [0] = 0x00 ; { ucptr [0] = 0x00 ;
ucptr [1] = 0x80 ; ucptr [1] = 0x80 ;
continue ; continue ;
} ; } ;
value = psf_lrintf (scaled_value) ; value = psf_lrintf (scaled_value) ;
ucptr [0] = value ; ucptr [0] = value >> 16 ;
ucptr [1] = value >> 8 ; ucptr [1] = value >> 24 ;
} ; } ;
} /* f2les_clip_array */ } /* f2les_clip_array */
@ -2047,27 +2047,31 @@ f2let_clip_array (const float *src, tribyte *dest, int count, int normalize)
{ float normfact, scaled_value ; { float normfact, scaled_value ;
int value ; int value ;
normfact = normalize ? (8.0 * 0x100000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFFFF)) #if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i].bytes [0] = 0xFF ; { dest [i].bytes [0] = 0xFF ;
dest [i].bytes [1] = 0xFF ; dest [i].bytes [1] = 0xFF ;
dest [i].bytes [2] = 0x7F ; dest [i].bytes [2] = 0x7F ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x100000)) #endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i].bytes [0] = 0x00 ; { dest [i].bytes [0] = 0x00 ;
dest [i].bytes [1] = 0x00 ; dest [i].bytes [1] = 0x00 ;
dest [i].bytes [2] = 0x80 ; dest [i].bytes [2] = 0x80 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrintf (scaled_value) ; value = psf_lrintf (scaled_value) ;
dest [i].bytes [0] = value ; dest [i].bytes [0] = value >> 8 ;
dest [i].bytes [1] = value >> 8 ; dest [i].bytes [1] = value >> 16 ;
dest [i].bytes [2] = value >> 16 ; dest [i].bytes [2] = value >> 24 ;
} ; } ;
} /* f2let_clip_array */ } /* f2let_clip_array */
@ -2118,27 +2122,31 @@ f2bet_clip_array (const float *src, tribyte *dest, int count, int normalize)
{ float normfact, scaled_value ; { float normfact, scaled_value ;
int value ; int value ;
normfact = normalize ? (8.0 * 0x100000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFFFF)) #if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i].bytes [0] = 0x7F ; { dest [i].bytes [0] = 0x7F ;
dest [i].bytes [1] = 0xFF ; dest [i].bytes [1] = 0xFF ;
dest [i].bytes [2] = 0xFF ; dest [i].bytes [2] = 0xFF ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x100000)) #endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i].bytes [0] = 0x80 ; { dest [i].bytes [0] = 0x80 ;
dest [i].bytes [1] = 0x00 ; dest [i].bytes [1] = 0x00 ;
dest [i].bytes [2] = 0x00 ; dest [i].bytes [2] = 0x00 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrint (scaled_value) ; value = psf_lrint (scaled_value) ;
dest [i].bytes [0] = value >> 16 ; dest [i].bytes [0] = value >> 24 ;
dest [i].bytes [1] = value >> 8 ; dest [i].bytes [1] = value >> 16 ;
dest [i].bytes [2] = value ; dest [i].bytes [2] = value >> 8 ;
} ; } ;
} /* f2bet_clip_array */ } /* f2bet_clip_array */
@ -2198,6 +2206,7 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
#if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= 1.0 * 0x7FFFFFFF) if (scaled_value >= 1.0 * 0x7FFFFFFF)
{ ucptr [0] = 0x7F ; { ucptr [0] = 0x7F ;
ucptr [1] = 0xFF ; ucptr [1] = 0xFF ;
@ -2205,6 +2214,8 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
ucptr [3] = 0xFF ; ucptr [3] = 0xFF ;
continue ; continue ;
} ; } ;
#endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [0] = 0x80 ; { ucptr [0] = 0x80 ;
ucptr [1] = 0x00 ; ucptr [1] = 0x00 ;
@ -2212,6 +2223,7 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
ucptr [3] = 0x00 ; ucptr [3] = 0x00 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrintf (scaled_value) ; value = psf_lrintf (scaled_value) ;
ucptr [0] = value >> 24 ; ucptr [0] = value >> 24 ;
@ -2277,6 +2289,7 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
#if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ ucptr [0] = 0xFF ; { ucptr [0] = 0xFF ;
ucptr [1] = 0xFF ; ucptr [1] = 0xFF ;
@ -2284,6 +2297,8 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
ucptr [3] = 0x7F ; ucptr [3] = 0x7F ;
continue ; continue ;
} ; } ;
#endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [0] = 0x00 ; { ucptr [0] = 0x00 ;
ucptr [1] = 0x00 ; ucptr [1] = 0x00 ;
@ -2291,6 +2306,7 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
ucptr [3] = 0x80 ; ucptr [3] = 0x80 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrintf (scaled_value) ; value = psf_lrintf (scaled_value) ;
ucptr [0] = value ; ucptr [0] = value ;
@ -2342,20 +2358,20 @@ static void
d2sc_clip_array (const double *src, signed char *dest, int count, int normalize) d2sc_clip_array (const double *src, signed char *dest, int count, int normalize)
{ double normfact, scaled_value ; { double normfact, scaled_value ;
normfact = normalize ? (8.0 * 0x10) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7F)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i] = 127 ; { dest [i] = 127 ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x10)) if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i] = -128 ; { dest [i] = -128 ;
continue ; continue ;
} ; } ;
dest [i] = psf_lrintf (scaled_value) ; dest [i] = psf_lrintf (scaled_value) >> 24 ;
} ; } ;
} /* d2sc_clip_array */ } /* d2sc_clip_array */
@ -2401,20 +2417,20 @@ static void
d2uc_clip_array (const double *src, unsigned char *dest, int count, int normalize) d2uc_clip_array (const double *src, unsigned char *dest, int count, int normalize)
{ double normfact, scaled_value ; { double normfact, scaled_value ;
normfact = normalize ? (8.0 * 0x10) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7F)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i] = 255 ; { dest [i] = 255 ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x10)) if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i] = 0 ; { dest [i] = 0 ;
continue ; continue ;
} ; } ;
dest [i] = psf_lrint (src [i] * normfact) + 128 ; dest [i] = (psf_lrint (src [i] * normfact) >> 24) + 128 ;
} ; } ;
} /* d2uc_clip_array */ } /* d2uc_clip_array */
@ -2467,25 +2483,25 @@ d2bes_clip_array (const double *src, short *dest, int count, int normalize)
double normfact, scaled_value ; double normfact, scaled_value ;
int value ; int value ;
normfact = normalize ? (8.0 * 0x1000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ ucptr [1] = 0xFF ; { ucptr [1] = 0xFF ;
ucptr [0] = 0x7F ; ucptr [0] = 0x7F ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x1000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [1] = 0x00 ; { ucptr [1] = 0x00 ;
ucptr [0] = 0x80 ; ucptr [0] = 0x80 ;
continue ; continue ;
} ; } ;
value = psf_lrint (scaled_value) ; value = psf_lrint (scaled_value) ;
ucptr [1] = value ; ucptr [1] = value >> 16 ;
ucptr [0] = value >> 8 ; ucptr [0] = value >> 24 ;
} ; } ;
} /* d2bes_clip_array */ } /* d2bes_clip_array */
@ -2538,25 +2554,25 @@ d2les_clip_array (const double *src, short *dest, int count, int normalize)
int value ; int value ;
double normfact, scaled_value ; double normfact, scaled_value ;
normfact = normalize ? (8.0 * 0x1000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ ucptr [0] = 0xFF ; { ucptr [0] = 0xFF ;
ucptr [1] = 0x7F ; ucptr [1] = 0x7F ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x1000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [0] = 0x00 ; { ucptr [0] = 0x00 ;
ucptr [1] = 0x80 ; ucptr [1] = 0x80 ;
continue ; continue ;
} ; } ;
value = psf_lrint (scaled_value) ; value = psf_lrint (scaled_value) ;
ucptr [0] = value ; ucptr [0] = value >> 16 ;
ucptr [1] = value >> 8 ; ucptr [1] = value >> 24 ;
} ; } ;
} /* d2les_clip_array */ } /* d2les_clip_array */
@ -2607,27 +2623,31 @@ d2let_clip_array (const double *src, tribyte *dest, int count, int normalize)
{ int value ; { int value ;
double normfact, scaled_value ; double normfact, scaled_value ;
normfact = normalize ? (8.0 * 0x100000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFFFF)) #if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i].bytes [0] = 0xFF ; { dest [i].bytes [0] = 0xFF ;
dest [i].bytes [1] = 0xFF ; dest [i].bytes [1] = 0xFF ;
dest [i].bytes [2] = 0x7F ; dest [i].bytes [2] = 0x7F ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x100000)) #endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i].bytes [0] = 0x00 ; { dest [i].bytes [0] = 0x00 ;
dest [i].bytes [1] = 0x00 ; dest [i].bytes [1] = 0x00 ;
dest [i].bytes [2] = 0x80 ; dest [i].bytes [2] = 0x80 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrint (scaled_value) ; value = psf_lrint (scaled_value) ;
dest [i].bytes [0] = value ; dest [i].bytes [0] = value >> 8 ;
dest [i].bytes [1] = value >> 8 ; dest [i].bytes [1] = value >> 16 ;
dest [i].bytes [2] = value >> 16 ; dest [i].bytes [2] = value >> 24 ;
} ; } ;
} /* d2let_clip_array */ } /* d2let_clip_array */
@ -2678,27 +2698,31 @@ d2bet_clip_array (const double *src, tribyte *dest, int count, int normalize)
{ int value ; { int value ;
double normfact, scaled_value ; double normfact, scaled_value ;
normfact = normalize ? (8.0 * 0x100000) : 1.0 ; normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ scaled_value = src [i] * normfact ; { scaled_value = src [i] * normfact ;
if (scaled_value >= (1.0 * 0x7FFFFF)) #if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ dest [i].bytes [2] = 0xFF ; { dest [i].bytes [2] = 0xFF ;
dest [i].bytes [1] = 0xFF ; dest [i].bytes [1] = 0xFF ;
dest [i].bytes [0] = 0x7F ; dest [i].bytes [0] = 0x7F ;
continue ; continue ;
} ; } ;
if (scaled_value <= (-8.0 * 0x100000)) #endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000))
{ dest [i].bytes [2] = 0x00 ; { dest [i].bytes [2] = 0x00 ;
dest [i].bytes [1] = 0x00 ; dest [i].bytes [1] = 0x00 ;
dest [i].bytes [0] = 0x80 ; dest [i].bytes [0] = 0x80 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrint (scaled_value) ; value = psf_lrint (scaled_value) ;
dest [i].bytes [2] = value ; dest [i].bytes [2] = value >> 8 ;
dest [i].bytes [1] = value >> 8 ; dest [i].bytes [1] = value >> 16 ;
dest [i].bytes [0] = value >> 16 ; dest [i].bytes [0] = value >> 24 ;
} ; } ;
} /* d2bet_clip_array */ } /* d2bet_clip_array */
@ -2758,6 +2782,7 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
#if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ ucptr [3] = 0xFF ; { ucptr [3] = 0xFF ;
ucptr [2] = 0xFF ; ucptr [2] = 0xFF ;
@ -2765,6 +2790,8 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
ucptr [0] = 0x7F ; ucptr [0] = 0x7F ;
continue ; continue ;
} ; } ;
#endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [3] = 0x00 ; { ucptr [3] = 0x00 ;
ucptr [2] = 0x00 ; ucptr [2] = 0x00 ;
@ -2772,6 +2799,7 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
ucptr [0] = 0x80 ; ucptr [0] = 0x80 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrint (scaled_value) ; value = psf_lrint (scaled_value) ;
ucptr [0] = value >> 24 ; ucptr [0] = value >> 24 ;
@ -2837,6 +2865,7 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
for (int i = 0 ; i < count ; i++) for (int i = 0 ; i < count ; i++)
{ ucptr = (unsigned char*) &dest [i] ; { ucptr = (unsigned char*) &dest [i] ;
scaled_value = src [i] * normfact ; scaled_value = src [i] * normfact ;
#if CPU_CLIPS_POSITIVE == 0
if (scaled_value >= (1.0 * 0x7FFFFFFF)) if (scaled_value >= (1.0 * 0x7FFFFFFF))
{ ucptr [0] = 0xFF ; { ucptr [0] = 0xFF ;
ucptr [1] = 0xFF ; ucptr [1] = 0xFF ;
@ -2844,6 +2873,8 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
ucptr [3] = 0x7F ; ucptr [3] = 0x7F ;
continue ; continue ;
} ; } ;
#endif
#if CPU_CLIPS_NEGATIVE == 0
if (scaled_value <= (-8.0 * 0x10000000)) if (scaled_value <= (-8.0 * 0x10000000))
{ ucptr [0] = 0x00 ; { ucptr [0] = 0x00 ;
ucptr [1] = 0x00 ; ucptr [1] = 0x00 ;
@ -2851,6 +2882,7 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
ucptr [3] = 0x80 ; ucptr [3] = 0x80 ;
continue ; continue ;
} ; } ;
#endif
value = psf_lrint (scaled_value) ; value = psf_lrint (scaled_value) ;
ucptr [0] = value ; ucptr [0] = value ;

View file

@ -242,7 +242,7 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
} ; } ;
} ; } ;
if (psf->filelength - 8 != riff_size) if (psf->filelength != riff_size + 8)
psf_log_printf (psf, " Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ; psf_log_printf (psf, " Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ;
else else
psf_log_printf (psf, " Riff size : %D\n", riff_size) ; psf_log_printf (psf, " Riff size : %D\n", riff_size) ;

View file

@ -454,7 +454,7 @@ sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
ucptr = psds->read_data + 5 ; ucptr = psds->read_data + 5 ;
for (k = 0 ; k < 120 ; k += 2) for (k = 0 ; k < 120 ; k += 2)
{ sample = arith_shift_left (ucptr [k], 25) | arith_shift_left (ucptr [k + 1], 18) ; { sample = arith_shift_left (ucptr [k], 25) + arith_shift_left (ucptr [k + 1], 18) ;
psds->read_samples [k / 2] = (int) (sample - 0x80000000) ; psds->read_samples [k / 2] = (int) (sample - 0x80000000) ;
} ; } ;
@ -498,7 +498,7 @@ sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
ucptr = psds->read_data + 5 ; ucptr = psds->read_data + 5 ;
for (k = 0 ; k < 120 ; k += 3) for (k = 0 ; k < 120 ; k += 3)
{ sample = (((uint32_t) ucptr [k]) << 25) | (ucptr [k + 1] << 18) | (ucptr [k + 2] << 11) ; { sample = (((uint32_t) ucptr [k]) << 25) + (ucptr [k + 1] << 18) + (ucptr [k + 2] << 11) ;
psds->read_samples [k / 3] = (int) (sample - 0x80000000) ; psds->read_samples [k / 3] = (int) (sample - 0x80000000) ;
} ; } ;
@ -542,7 +542,7 @@ sds_4byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
ucptr = psds->read_data + 5 ; ucptr = psds->read_data + 5 ;
for (k = 0 ; k < 120 ; k += 4) for (k = 0 ; k < 120 ; k += 4)
{ sample = (((uint32_t) ucptr [k]) << 25) | (ucptr [k + 1] << 18) | (ucptr [k + 2] << 11) | (ucptr [k + 3] << 4) ; { sample = (((uint32_t) ucptr [k]) << 25) + (ucptr [k + 1] << 18) + (ucptr [k + 2] << 11) + (ucptr [k + 3] << 4) ;
psds->read_samples [k / 4] = (int) (sample - 0x80000000) ; psds->read_samples [k / 4] = (int) (sample - 0x80000000) ;
} ; } ;

View file

@ -41,10 +41,6 @@
#define HAVE_ALSA_ASOUNDLIB_H 0 #define HAVE_ALSA_ASOUNDLIB_H 0
#endif #endif
#ifndef HAVE_SNDIO_H
#define HAVE_SNDIO_H 0
#endif
#ifndef HAVE_BYTESWAP_H #ifndef HAVE_BYTESWAP_H
#define HAVE_BYTESWAP_H 0 #define HAVE_BYTESWAP_H 0
#endif #endif

View file

@ -472,7 +472,7 @@ SNDFILE*
sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data)
{ SF_PRIVATE *psf ; { SF_PRIVATE *psf ;
/* Make sure we have a valid set of virtual pointers. */ /* Make sure we have a valid set ot virtual pointers. */
if (sfvirtual->get_filelen == NULL) if (sfvirtual->get_filelen == NULL)
{ sf_errno = SFE_BAD_VIRTUAL_IO ; { sf_errno = SFE_BAD_VIRTUAL_IO ;
snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_get_filelen in SF_VIRTUAL_IO struct.\n") ; snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_get_filelen in SF_VIRTUAL_IO struct.\n") ;
@ -658,7 +658,7 @@ sf_format_check (const SF_INFO *info)
/* This is the place where each file format can check if the supplied /* This is the place where each file format can check if the supplied
** SF_INFO struct is valid. ** SF_INFO struct is valid.
** Return 0 on failure, 1 on success. ** Return 0 on failure, 1 ons success.
*/ */
if (info->channels < 1 || info->channels > SF_MAX_CHANNELS) if (info->channels < 1 || info->channels > SF_MAX_CHANNELS)
@ -1112,7 +1112,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
format = SF_CODEC (psf->sf.format) ; format = SF_CODEC (psf->sf.format) ;
/* Only files containing the following data types support the PEAK chunk. */ /* Only files containg the following data types support the PEAK chunk. */
if (format != SF_FORMAT_FLOAT && format != SF_FORMAT_DOUBLE) if (format != SF_FORMAT_FLOAT && format != SF_FORMAT_DOUBLE)
return SF_FALSE ; return SF_FALSE ;
@ -1522,7 +1522,7 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence)
** used with SEEK_SET. ** used with SEEK_SET.
*/ */
switch (whence) switch (whence)
{ /* The SEEK_SET behaviour is independent of mode. */ { /* The SEEK_SET behaviour is independant of mode. */
case SEEK_SET : case SEEK_SET :
case SEEK_SET | SFM_READ : case SEEK_SET | SFM_READ :
case SEEK_SET | SFM_WRITE : case SEEK_SET | SFM_WRITE :

View file

@ -845,7 +845,7 @@ Detailed description of new data blocks (VOC files version 1.20 and above):
(Source is fax from Barry Boone at Creative Labs, 405/742-6622) (Source is fax from Barry Boone at Creative Labs, 405/742-6622)
BLOCK 8 - digitized sound attribute extension, must precede block 1. BLOCK 8 - digitized sound attribute extension, must preceed block 1.
Used to define stereo, 8 bit audio Used to define stereo, 8 bit audio
BYTE bBlockID; // = 8 BYTE bBlockID; // = 8
BYTE nBlockLen[3]; // 3 byte length BYTE nBlockLen[3]; // 3 byte length

View file

@ -153,7 +153,7 @@ w64_open (SF_PRIVATE *psf)
/* /*
** At this point we don't know the file length so set it stupidly high, but not ** At this point we don't know the file length so set it stupidly high, but not
** so high that it triggers undefined behaviour when something is added to it. ** so high that it triggers undefined behaviour whan something is added to it.
*/ */
psf->filelength = SF_COUNT_MAX - 10000 ; psf->filelength = SF_COUNT_MAX - 10000 ;
psf->datalength = psf->filelength ; psf->datalength = psf->filelength ;

View file

@ -208,7 +208,7 @@ wav_open (SF_PRIVATE *psf)
} ; } ;
#if (ENABLE_EXPERIMENTAL_CODE == 0) #if (ENABLE_EXPERIMENTAL_CODE == 0)
/* For now, don't support writing MPEGLAYER3 WAVs, as we can't guarantee that /* For now, don't support writing MPEGLAYER3 WAVs, as we can't guarentee that
** such a file written by libsndfile would have the same length when opened again. ** such a file written by libsndfile would have the same length when opened again.
*/ */
if (subformat == SF_FORMAT_MPEG_LAYER_III) if (subformat == SF_FORMAT_MPEG_LAYER_III)
@ -1537,7 +1537,7 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, uint32_t chunklen)
** **
** 0x01 On: One Shot Off: Loop ** 0x01 On: One Shot Off: Loop
** 0x02 On: Root note is Set Off: No root ** 0x02 On: Root note is Set Off: No root
** 0x04 On: Stretch is On, Off: Stretch is OFF ** 0x04 On: Stretch is On, Off: Strech is OFF
** 0x08 On: Disk Based Off: Ram based ** 0x08 On: Disk Based Off: Ram based
** 0x10 On: ?????????? Off: ????????? (Acidizer puts that ON) ** 0x10 On: ?????????? Off: ????????? (Acidizer puts that ON)
** **

View file

@ -88,7 +88,7 @@ static const struct chanmap_s
{ int id ; { int id ;
const char * name ; const char * name ;
} channel_mask_bits [] = } channel_mask_bits [] =
{ /* WAVEFORMATEXTENSIBLE doesn't distinguish FRONT_LEFT from LEFT */ { /* WAVEFORMATEXTENSIBLE doesn't distuingish FRONT_LEFT from LEFT */
{ SF_CHANNEL_MAP_LEFT, "L" }, { SF_CHANNEL_MAP_LEFT, "L" },
{ SF_CHANNEL_MAP_RIGHT, "R" }, { SF_CHANNEL_MAP_RIGHT, "R" },
{ SF_CHANNEL_MAP_CENTER, "C" }, { SF_CHANNEL_MAP_CENTER, "C" },
@ -161,7 +161,7 @@ wavlike_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize)
{ psf_log_printf (psf, " Bit Width : 24\n") ; { psf_log_printf (psf, " Bit Width : 24\n") ;
psf_log_printf (psf, "\n" psf_log_printf (psf, "\n"
" Ambiguous information in 'fmt ' chunk. Possible file types:\n" " Ambiguous information in 'fmt ' chunk. Possibile file types:\n"
" 0) Invalid IEEE float file generated by Syntrillium's Cooledit!\n" " 0) Invalid IEEE float file generated by Syntrillium's Cooledit!\n"
" 1) File generated by ALSA's arecord containing 24 bit samples in 32 bit containers.\n" " 1) File generated by ALSA's arecord containing 24 bit samples in 32 bit containers.\n"
" 2) 24 bit file with incorrect Block Align value.\n" " 2) 24 bit file with incorrect Block Align value.\n"

View file

@ -151,7 +151,7 @@ main (void)
/*================================================================================= /*=================================================================================
** The following routines came from the sox-12.15 (Sound eXchange) distribution. ** The following routines came from the sox-12.15 (Sound eXcahcnge) distribution.
** **
** This code is not compiled into libsndfile. It is only used to test the ** This code is not compiled into libsndfile. It is only used to test the
** libsndfile lookup tables for correctness. ** libsndfile lookup tables for correctness.

View file

@ -43,7 +43,7 @@
#endif #endif
/* /*
** Neat solution to the Win32/OS2 binary file flag requirement. ** Neat solution to the Win32/OS2 binary file flage requirement.
** If O_BINARY isn't already defined by the inclusion of the system ** If O_BINARY isn't already defined by the inclusion of the system
** headers, set it to zero. ** headers, set it to zero.
*/ */

View file

@ -714,7 +714,7 @@ instrumet_rw_test (const char *filename)
{ inst.basenote = 22 ; { inst.basenote = 22 ;
if (sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE) if (sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
printf ("Success: [%s] updated\n", filename) ; printf ("Sucess: [%s] updated\n", filename) ;
else else
printf ("Error: SFC_SET_INSTRUMENT on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; printf ("Error: SFC_SET_INSTRUMENT on [%s] [%s]\n", filename, sf_strerror (sndfile)) ;
} }
@ -913,7 +913,7 @@ cue_rw_test (const char *filename)
{ cues.cue_points [1].sample_offset = 3 ; { cues.cue_points [1].sample_offset = 3 ;
if (sf_command (sndfile, SFC_SET_CUE, &cues, sizeof (cues)) == SF_TRUE) if (sf_command (sndfile, SFC_SET_CUE, &cues, sizeof (cues)) == SF_TRUE)
printf ("Success: [%s] updated\n", filename) ; printf ("Sucess: [%s] updated\n", filename) ;
else else
printf ("Error: SFC_SET_CUE on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; printf ("Error: SFC_SET_CUE on [%s] [%s]\n", filename, sf_strerror (sndfile)) ;
} }

View file

@ -175,7 +175,7 @@ compression_size_test (int format, const char * filename)
int int
main (int argc, char *argv []) main (int argc, char *argv [])
{ int all_tests = 0 ; { int all_tests = 0, tests = 0 ;
if (argc != 2) if (argc != 2)
{ printf ( { printf (
@ -197,6 +197,7 @@ main (int argc, char *argv [])
{ if (HAVE_EXTERNAL_XIPH_LIBS) { if (HAVE_EXTERNAL_XIPH_LIBS)
{ vorbis_test () ; { vorbis_test () ;
compression_size_test (SF_FORMAT_OGG | SF_FORMAT_VORBIS, "vorbis.oga") ; compression_size_test (SF_FORMAT_OGG | SF_FORMAT_VORBIS, "vorbis.oga") ;
tests ++ ;
} }
else else
puts (" No Ogg Vorbis tests because support was not compiled in.") ; puts (" No Ogg Vorbis tests because support was not compiled in.") ;
@ -205,6 +206,7 @@ main (int argc, char *argv [])
if (all_tests || strcmp (argv [1], "flac") == 0) if (all_tests || strcmp (argv [1], "flac") == 0)
{ if (HAVE_EXTERNAL_XIPH_LIBS) { if (HAVE_EXTERNAL_XIPH_LIBS)
{ compression_size_test (SF_FORMAT_FLAC | SF_FORMAT_PCM_16, "pcm16.flac") ; { compression_size_test (SF_FORMAT_FLAC | SF_FORMAT_PCM_16, "pcm16.flac") ;
tests ++ ;
} }
else else
puts (" No FLAC tests because support was not compiled in.") ; puts (" No FLAC tests because support was not compiled in.") ;
@ -213,6 +215,7 @@ main (int argc, char *argv [])
if (all_tests || strcmp (argv [1], "opus") == 0) if (all_tests || strcmp (argv [1], "opus") == 0)
{ if (HAVE_EXTERNAL_XIPH_LIBS) { if (HAVE_EXTERNAL_XIPH_LIBS)
{ compression_size_test (SF_FORMAT_OGG | SF_FORMAT_OPUS, "opus.opus") ; { compression_size_test (SF_FORMAT_OGG | SF_FORMAT_OPUS, "opus.opus") ;
tests ++ ;
} }
else else
puts (" No Opus tests because support was not compiled in.") ; puts (" No Opus tests because support was not compiled in.") ;
@ -221,6 +224,7 @@ main (int argc, char *argv [])
if (all_tests || strcmp (argv [1], "mpeg") == 0) if (all_tests || strcmp (argv [1], "mpeg") == 0)
{ if (HAVE_MPEG) { if (HAVE_MPEG)
{ compression_size_test (SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III, "mpeg.mp3") ; { compression_size_test (SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III, "mpeg.mp3") ;
tests ++ ;
} }
else else
puts (" No MPEG tests because support was not compiled in.") ; puts (" No MPEG tests because support was not compiled in.") ;

View file

@ -293,7 +293,7 @@ filesystem_full_test (int format)
sfinfo.frames = 0 ; sfinfo.frames = 0 ;
if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL) if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL)
{ printf ("\n\nLine %d : Error, file should not have opened.\n", __LINE__ - 1) ; { printf ("\n\nLine %d : Error, file should not have openned.\n", __LINE__ - 1) ;
exit (1) ; exit (1) ;
} ; } ;

View file

@ -79,6 +79,7 @@ static int verbose = SF_FALSE ;
int int
main (int argc, char **argv) main (int argc, char **argv)
{ int do_all = 0 ; { int do_all = 0 ;
int test_count = 0 ;
if (argc == 3 && strcmp (argv [2], "-v") == 0) if (argc == 3 && strcmp (argv [2], "-v") == 0)
{ verbose = SF_TRUE ; { verbose = SF_TRUE ;
@ -106,14 +107,17 @@ main (int argc, char **argv)
if (do_all || ! strcmp (argv [1], "wav")) if (do_all || ! strcmp (argv [1], "wav"))
{ multi_file_test ("multi_wav.dat", wav_formats, ARRAY_LEN (wav_formats)) ; { multi_file_test ("multi_wav.dat", wav_formats, ARRAY_LEN (wav_formats)) ;
test_count++ ;
} ; } ;
if (do_all || ! strcmp (argv [1], "aiff")) if (do_all || ! strcmp (argv [1], "aiff"))
{ multi_file_test ("multi_aiff.dat", aiff_formats, ARRAY_LEN (aiff_formats)) ; { multi_file_test ("multi_aiff.dat", aiff_formats, ARRAY_LEN (aiff_formats)) ;
test_count++ ;
} ; } ;
if (do_all || ! strcmp (argv [1], "au")) if (do_all || ! strcmp (argv [1], "au"))
{ multi_file_test ("multi_au.dat", au_formats, ARRAY_LEN (au_formats)) ; { multi_file_test ("multi_au.dat", au_formats, ARRAY_LEN (au_formats)) ;
test_count++ ;
} ; } ;
return 0 ; return 0 ;
@ -231,3 +235,4 @@ write_file_at_end (int fd, int filetype, int channels, int file_num)
sf_close (sndfile) ; sf_close (sndfile) ;
} /* write_file_at_end */ } /* write_file_at_end */

View file

@ -339,7 +339,7 @@ read_write_peak_test (const char *filename, int filetype)
sf_close (file) ; sf_close (file) ;
/* Open the file RDWR, write sample valid 1.25. */ /* Open the fiel RDWR, write sample valied 1.25. */
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++) for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)

View file

@ -58,7 +58,7 @@ main (int argc, char *argv [])
} ; } ;
printf ("Total : %d\n", total) ; printf ("Total : %d\n", total) ;
printf ("Maximum value : %d\n", max) ; printf ("Maximun value : %d\n", max) ;
sf_close (file) ; sf_close (file) ;

View file

@ -152,7 +152,7 @@ main (void)
/*================================================================================= /*=================================================================================
** The following routines came from the sox-12.15 (Sound eXchange) distribution. ** The following routines came from the sox-12.15 (Sound eXcahcnge) distribution.
** **
** This code is not compiled into libsndfile. It is only used to test the ** This code is not compiled into libsndfile. It is only used to test the
** libsndfile lookup tables for correctness. ** libsndfile lookup tables for correctness.

View file

@ -208,7 +208,7 @@ sf_count_t file_length_fd (int fd) ;
#define LOG_BUFFER_SIZE 4096 #define LOG_BUFFER_SIZE 4096
/* /*
** Neat solution to the Win32/OS2 binary file flag requirement. ** Neat solution to the Win32/OS2 binary file flage requirement.
** If O_BINARY isn't already defined by the inclusion of the system ** If O_BINARY isn't already defined by the inclusion of the system
** headers, set it to zero. ** headers, set it to zero.
*/ */
@ -426,8 +426,8 @@ check_log_buffer_or_die (SNDFILE *file, int line_num)
} ; } ;
/* Look for "Should" */ /* Look for "Should" */
if (strstr (buffer, "unknown marker")) if (strstr (buffer, "nknown marker"))
{ printf ("\n\nLine %d : Log buffer contains `unknown marker'. Dumping.\n", line_num) ; { printf ("\n\nLine %d : Log buffer contains `nknown marker'. Dumping.\n", line_num) ;
puts (buffer) ; puts (buffer) ;
exit (1) ; exit (1) ;
} ; } ;

View file

@ -244,7 +244,7 @@ show_stat_fstat_error (void)
assert (write (fd, data, sizeof (data)) > 0) ; assert (write (fd, data, sizeof (data)) > 0) ;
printf ("1) Now call stat and fstat on the file and retrieve the file lengths.\n") ; printf ("1) Now call stat and fstat on the file and retreive the file lengths.\n") ;
if (stat (filename, &buf) != 0) if (stat (filename, &buf) != 0)
{ printf ("\n\nLine %d: stat() failed : %s\n\n", __LINE__, strerror (errno)) ; { printf ("\n\nLine %d: stat() failed : %s\n\n", __LINE__, strerror (errno)) ;

View file

@ -856,7 +856,7 @@ mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int lo
create_short_file (filename) ; create_short_file (filename) ;
/* Opening a already existing short file (ie invalid header) RDWR is disallowed. /* Opening a already existing short file (ie invalid header) RDWR is disallowed.
** If this returns a valid pointer sf_open() screwed up. ** If this returns a valif pointer sf_open() screwed up.
*/ */
if ((file = sf_open (filename, SFM_RDWR, &sfinfo))) if ((file = sf_open (filename, SFM_RDWR, &sfinfo)))
{ printf ("\n\nLine %d: sf_open should (SFM_RDWR) have failed but didn't.\n", __LINE__) ; { printf ("\n\nLine %d: sf_open should (SFM_RDWR) have failed but didn't.\n", __LINE__) ;

View file

@ -7,6 +7,9 @@ if(TARGET vorbis)
if(NOT TARGET VORBIS::VORBIS) if(NOT TARGET VORBIS::VORBIS)
add_library(VORBIS::VORBIS ALIAS vorbis) add_library(VORBIS::VORBIS ALIAS vorbis)
endif() endif()
if(NOT TARGET Vorbis::vorbisenc)
add_library(Vorbis::vorbisenc ALIAS vorbisenc)
endif()
else() else()
set(VORBIS_FOUND FALSE) set(VORBIS_FOUND FALSE)
message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).")