mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Update minimum requirements and libs
This updates the minimum required cmake version and the libs that have updates for this. Ogg updated to master as of 20052025 Libsndfile updated to master as of 20052025 Opus minimum cmake version changed vorbis minimum cmake version changed
This commit is contained in:
parent
8756e35853
commit
700bf32a2a
130 changed files with 4380 additions and 48121 deletions
|
|
@ -5,6 +5,12 @@ 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/),
|
||||
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
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required (VERSION 3.1..3.18)
|
||||
cmake_minimum_required (VERSION 3.5...4.0)
|
||||
|
||||
# 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.
|
||||
|
|
@ -8,10 +8,12 @@ if (POLICY CMP0091)
|
|||
return ()
|
||||
endif ()
|
||||
|
||||
if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
cmake_policy (SET CMP0091 NEW)
|
||||
else ()
|
||||
cmake_policy (SET CMP0091 OLD)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.18)
|
||||
if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
cmake_policy (SET CMP0091 NEW)
|
||||
else ()
|
||||
cmake_policy (SET CMP0091 OLD)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
|
@ -95,7 +97,7 @@ endif ()
|
|||
include(SndFileChecks)
|
||||
|
||||
if (ENABLE_EXTERNAL_LIBS AND NOT (Vorbis_FOUND OR FLAC_FOUND OR OPUS_FOUND))
|
||||
#set (ENABLE_EXTERNAL_LIBS OFF)
|
||||
set (ENABLE_EXTERNAL_LIBS OFF)
|
||||
endif()
|
||||
if(ENABLE_MPEG AND (NOT HAVE_MPEG_LIBS))
|
||||
set (ENABLE_MPEG OFF)
|
||||
|
|
@ -104,11 +106,6 @@ if (BUILD_REGTEST AND (NOT SQLITE3_FOUND))
|
|||
set (BUILD_REGTEST OFF)
|
||||
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 (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS" OFF)
|
||||
|
||||
|
|
@ -140,7 +137,6 @@ add_feature_info (ENABLE_EXPERIMENTAL ENABLE_EXPERIMENTAL "enable experimental c
|
|||
add_feature_info (BUILD_TESTING BUILD_TESTING "build tests")
|
||||
add_feature_info (BUILD_REGTEST BUILD_REGTEST "build regtest")
|
||||
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_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")
|
||||
|
|
@ -195,7 +191,7 @@ set_package_properties(Opus PROPERTIES
|
|||
set_package_properties(Speex PROPERTIES TYPE OPTIONAL
|
||||
URL "www.speex.org/"
|
||||
DESCRIPTION "an audio codec tuned for speech"
|
||||
PURPOSE "Enables experemental Speex support"
|
||||
PURPOSE "Enables experimental Speex support"
|
||||
)
|
||||
set_package_properties (SQLite3 PROPERTIES
|
||||
TYPE OPTIONAL
|
||||
|
|
@ -487,7 +483,7 @@ if (BUILD_SHARED_LIBS)
|
|||
if (DEFINED SYMBOL_OS)
|
||||
add_custom_command (
|
||||
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}..."
|
||||
)
|
||||
|
||||
|
|
@ -570,8 +566,9 @@ if (BUILD_PROGRAMS)
|
|||
elseif ((NOT BEOS) AND ALSA_FOUND)
|
||||
target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS})
|
||||
target_link_libraries (sndfile-play PRIVATE ${ALSA_LIBRARIES})
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
target_link_libraries (sndfile-play PRIVATE Sndio::Sndio)
|
||||
elseif ((NOT BEOS) AND SNDIO_FOUND)
|
||||
target_include_directories (sndfile-play PRIVATE ${SNDIO_INCLUDE_DIRS})
|
||||
target_link_libraries (sndfile-play PRIVATE ${SNDIO_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
# sndfile-convert
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ EXTRA_DIST = sndfile.pc.in Scripts/android-configure.sh \
|
|||
NEWS.OLD CHANGELOG.md Scripts/linux-to-win-cross-configure.sh \
|
||||
CMakeLists.txt $(cmake_files) Win32 SECURITY.md
|
||||
|
||||
cmake_files = cmake/ClipMode.cmake cmake/FindFLAC.cmake \
|
||||
cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \
|
||||
cmake_files = cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \
|
||||
cmake/FindOgg.cmake cmake/FindVorbis.cmake cmake/FindSndio.cmake \
|
||||
cmake/FindSpeex.cmake cmake/sqlite/FindSQLite3.cmake \
|
||||
cmake/SndFileChecks.cmake cmake/TestInline.cmake \
|
||||
|
|
@ -25,7 +24,7 @@ cmake_files = cmake/ClipMode.cmake cmake/FindFLAC.cmake \
|
|||
cmake/FindOpus.cmake cmake/SndFileConfig.cmake.in \
|
||||
cmake/CheckCPUArch.cmake cmake/CheckCPUArch.c.in \
|
||||
cmake/Findmp3lame.cmake cmake/Findmpg123.cmake \
|
||||
cmake/SetupABIVersions.cmake
|
||||
cmake/FindFLAC.cmake cmake/SetupABIVersions.cmake
|
||||
|
||||
pkgconfig_DATA = sndfile.pc
|
||||
|
||||
|
|
@ -403,6 +402,7 @@ tests_scale_clip_test_LDADD = src/libsndfile.la
|
|||
# Yes, this sucks, but GNU make patterns aren't portable,
|
||||
# see also https://github.com/libsndfile/libsndfile/issues/369
|
||||
|
||||
if HAVE_AUTOGEN
|
||||
SUFFIXES = .tpl .def
|
||||
|
||||
.tpl.def:
|
||||
|
|
@ -424,6 +424,7 @@ tests/utils.h : tests/utils.c
|
|||
rm -f tests/utils.c && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) tests/utils.c; \
|
||||
fi
|
||||
endif
|
||||
|
||||
########
|
||||
# man/ #
|
||||
|
|
@ -455,7 +456,7 @@ if USE_OSSFUZZ_STATIC
|
|||
FUZZ_LDADD = $(LIB_FUZZING_ENGINE)
|
||||
FUZZ_FLAG =
|
||||
else
|
||||
FUZZ_LDADD = libstandaloneengine.la
|
||||
FUZZ_LDADD = ossfuzz/libstandaloneengine.la
|
||||
FUZZ_FLAG =
|
||||
endif
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ You can pass additional options with `/D<parameter>=<value>` when you run
|
|||
Useful libsndfile options:
|
||||
|
||||
* `BUILD_SHARED_LIBS` - build shared library (DLL under Windows) when `ON`,
|
||||
build static library othervise. This option is `OFF` by default.
|
||||
build static library otherwise. This option is `OFF` by default.
|
||||
* `BUILD_PROGRAMS` - build libsndfile's utilities from `programs/` directory,
|
||||
`ON` by default.
|
||||
* `BUILD_EXAMPLES` - build examples, `ON` by default.
|
||||
|
|
@ -137,8 +137,6 @@ 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.
|
||||
* `ENABLE_MPEG` - MP3 support. This option is available and set to `ON` if all
|
||||
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
|
||||
default.
|
||||
* `ENABLE_EXPERIMENTAL` - enable experimental code. Don't use it if you are
|
||||
|
|
@ -165,7 +163,7 @@ You can pass additional options with `/D<parameter>=<value>` when you run
|
|||
is native for MinGW ecosystem, Autotools constructs it using MinGW platform
|
||||
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
|
||||
platform, because Windows has no library naming rules. It is preffered
|
||||
platform, because Windows has no library naming rules. It is preferred
|
||||
because you can search library using package manager or CMake's
|
||||
`find_library` command on any platform using the same `sndfile` name.
|
||||
|
||||
|
|
@ -183,8 +181,6 @@ Deprecated options:
|
|||
|
||||
* `DISABLE_EXTERNAL_LIBS` - disable Ogg, Vorbis and FLAC support. Replaced by
|
||||
`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
|
||||
|
||||
### Linking from CMake projects
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ class Preprocessor:
|
|||
"""
|
||||
def __init__ (self):
|
||||
self.comment_nest = 0
|
||||
self.leading_space_re = re.compile ('^(\t+| )')
|
||||
self.trailing_space_re = re.compile ('(\t+| )$')
|
||||
self.define_hack_re = re.compile ("(#\s*define\s+[a-zA-Z0-9_]+)\(")
|
||||
self.leading_space_re = re.compile (r'^(\t+| )')
|
||||
self.trailing_space_re = re.compile (r'(\t+| )$')
|
||||
self.define_hack_re = re.compile (r"(#\s*define\s+[a-zA-Z0-9_]+)\(")
|
||||
|
||||
def comment_nesting (self):
|
||||
"""
|
||||
Return the currect comment nesting. At the start and end of the file,
|
||||
Return the current comment nesting. At the start and end of the file,
|
||||
this value should be zero. Inside C comments it should be 1 or
|
||||
(possibly) more.
|
||||
"""
|
||||
|
|
@ -55,7 +55,7 @@ class Preprocessor:
|
|||
|
||||
# Strip C++ style comments.
|
||||
if self.comment_nest == 0:
|
||||
line = re.sub ("( |\t*)//.*", '', line)
|
||||
line = re.sub (r"( |\t*)//.*", '', line)
|
||||
|
||||
# Strip C style comments.
|
||||
open_comment = line.find ('/*')
|
||||
|
|
@ -108,51 +108,51 @@ class CStyleChecker:
|
|||
self.error_count = 0
|
||||
self.line_num = 1
|
||||
self.orig_line = ''
|
||||
self.trailing_newline_re = re.compile ('[\r\n]+$')
|
||||
self.indent_re = re.compile ("^\s*")
|
||||
self.trailing_newline_re = re.compile (r'[\r\n]+$')
|
||||
self.indent_re = re.compile (r"^\s*")
|
||||
self.last_line_indent = ""
|
||||
self.last_line_indent_curly = False
|
||||
self.re_checks = \
|
||||
[ ( re.compile (" "), "multiple space instead of tab" )
|
||||
, ( re.compile ("\t "), "space after tab" )
|
||||
, ( re.compile ("[^ ];"), "missing space before semi-colon" )
|
||||
, ( re.compile ("{[^\s}]"), "missing space after open brace" )
|
||||
, ( re.compile ("[^{\s]}"), "missing space before close brace" )
|
||||
, ( re.compile ("[ \t]+$"), "contains trailing whitespace" )
|
||||
[ ( re.compile (r" "), "multiple space instead of tab" )
|
||||
, ( re.compile (r"\t "), "space after tab" )
|
||||
, ( re.compile (r"[^ ];"), "missing space before semi-colon" )
|
||||
, ( re.compile (r"{[^\s}]"), "missing space after open brace" )
|
||||
, ( re.compile (r"[^{\s]}"), "missing space before close brace" )
|
||||
, ( re.compile (r"[ \t]+$"), "contains trailing whitespace" )
|
||||
|
||||
, ( re.compile (",[^\s\n]"), "missing space after comma" )
|
||||
, ( re.compile (";[^\s]"), "missing space after semi-colon" )
|
||||
, ( re.compile ("=[^\s\"'=]"), "missing space after assignment" )
|
||||
, ( re.compile (r",[^\s\n]"), "missing space after comma" )
|
||||
, ( re.compile (r";[^\s]"), "missing space after semi-colon" )
|
||||
, ( re.compile (r"=[^\s\"'=]"), "missing space after assignment" )
|
||||
|
||||
# Open and close parenthesis.
|
||||
, ( re.compile ("[^\s\(\[\*&']\("), "missing space before open parenthesis" )
|
||||
, ( re.compile ("\)(-[^>]|[^,'\s\n\)\]-])"), "missing space after close parenthesis" )
|
||||
, ( re.compile ("\s(do|for|if|when)\s.*{$"), "trailing open parenthesis at end of line" )
|
||||
, ( re.compile ("\( [^;]"), "space after open parenthesis" )
|
||||
, ( re.compile ("[^;] \)"), "space before close parenthesis" )
|
||||
, ( re.compile (r"[^\s\(\[\*&']\("), "missing space before open parenthesis" )
|
||||
, ( re.compile (r"\)(-[^>]|[^,'\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 (r"\( [^;]"), "space after open parenthesis" )
|
||||
, ( re.compile (r"[^;] \)"), "space before close parenthesis" )
|
||||
|
||||
# Open and close square brace.
|
||||
, ( re.compile ("[^\s\(\]]\["), "missing space before open square brace" )
|
||||
, ( re.compile ("\][^,\)\]\[\s\.-]"), "missing space after close square brace" )
|
||||
, ( re.compile ("\[ "), "space after open square brace" )
|
||||
, ( re.compile (" \]"), "space before close square brace" )
|
||||
, ( re.compile (r"[^\s\(\]]\["), "missing space before open square brace" )
|
||||
, ( re.compile (r"\][^,\)\]\[\s\.-]"), "missing space after close square brace" )
|
||||
, ( re.compile (r"\[ "), "space after open square brace" )
|
||||
, ( re.compile (r" \]"), "space before close square brace" )
|
||||
|
||||
# Space around operators.
|
||||
, ( re.compile ("[^\s][\*/%+-][=][^\s]"), "missing space around opassign" )
|
||||
, ( re.compile ("[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" )
|
||||
, ( re.compile (r"[^\s][\*/%+-][=][^\s]"), "missing space around opassign" )
|
||||
, ( re.compile (r"[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" )
|
||||
|
||||
# Parens around single argument to return.
|
||||
, ( re.compile ("\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" )
|
||||
, ( re.compile (r"\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" )
|
||||
|
||||
# Parens around single case argument.
|
||||
, ( re.compile ("\s+case\s+\([a-zA-Z0-9_]+\)\s+:"), "parens around single case argument" )
|
||||
, ( re.compile (r"\s+case\s+\([a-zA-Z0-9_]+\)\s+:"), "parens around single case argument" )
|
||||
|
||||
# Open curly at end of line.
|
||||
, ( re.compile ("\)\s*{\s*$"), "open curly brace at end of line" )
|
||||
, ( re.compile (r"\)\s*{\s*$"), "open curly brace at end of line" )
|
||||
|
||||
# Pre and post increment/decrment.
|
||||
, ( re.compile ("[^\(\[][+-]{2}[a-zA-Z0-9_]"), "space after pre increment/decrement" )
|
||||
, ( re.compile ("[a-zA-Z0-9_][+-]{2}[^\)\,]]"), "space before post increment/decrement" )
|
||||
# Pre and post increment/decrement.
|
||||
, ( re.compile (r"[^\(\[][+-]{2}[a-zA-Z0-9_]"), "space after pre increment/decrement" )
|
||||
, ( re.compile (r"[a-zA-Z0-9_][+-]{2}[^\)\,]]"), "space before post increment/decrement" )
|
||||
]
|
||||
|
||||
def get_error_count (self):
|
||||
|
|
@ -207,7 +207,7 @@ class CStyleChecker:
|
|||
"""
|
||||
|
||||
indent = len (self.indent_re.search (line).group ())
|
||||
if re.search ("^\s+}", line):
|
||||
if re.search (r"^\s+}", line):
|
||||
if not self.last_line_indent_curly and indent != self.last_line_indent:
|
||||
None # self.error ("bad indent on close curly brace")
|
||||
self.last_line_indent_curly = True
|
||||
|
|
@ -219,8 +219,8 @@ class CStyleChecker:
|
|||
if check_re.search (line):
|
||||
self.error (msg)
|
||||
|
||||
if re.search ("[a-zA-Z0-9][<>!=^/&\|]{1,2}[a-zA-Z0-9]", line):
|
||||
if not re.search (".*#include.*[a-zA-Z0-9]/[a-zA-Z]", line):
|
||||
if re.search (r"[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):
|
||||
self.error ("missing space around operator")
|
||||
|
||||
self.last_line_indent = indent
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ if test -n "$cfiles" ; then
|
|||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check the copyright notice of all files to be commited.
|
||||
# Check the copyright notice of all files to be committed.
|
||||
|
||||
user=`git config --global user.email`
|
||||
year=`date +"%Y"`
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
if (NOT TEMPLATE_MATCH)
|
||||
message(FATAL_ERROR "${DEFINITION_FILENAME} doest not contain an AutoGen definition.")
|
||||
message(FATAL_ERROR "${DEFINITION_FILENAME} does not contain an AutoGen definition.")
|
||||
endif()
|
||||
|
||||
get_filename_component(DEFINITION_DIR "${DEFINITION_FILENAME}" PATH)
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
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)
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
# FLAC_INCLUDE_DIRS - where to find FLAC headers.
|
||||
# FLAC_LIBRARIES - List of libraries when using libFLAC.
|
||||
# FLAC_FOUND - True if libFLAC found.
|
||||
# FLAC_DEFINITIONS - FLAC compile definitons
|
||||
# FLAC_DEFINITIONS - FLAC compile definitions
|
||||
|
||||
if (FLAC_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ if (MP3LAME_FOUND)
|
|||
)
|
||||
if (MP3LAME_HIP_LIBRARY AND (NOT TARGET mp3lame::mpghip))
|
||||
add_library (mp3lame::mpghip STATIC IMPORTED)
|
||||
set_property (mp3lame::mpghip PROPERTY IMPORTED_LOCATION "${MP3LAME_HIP_LIBRARY}")
|
||||
set_property (TARGET mp3lame::mpghip PROPERTY IMPORTED_LOCATION "${MP3LAME_HIP_LIBRARY}")
|
||||
set_property (TARGET mp3lame::mp3lame PROPERTY INTERFACE_LINK_LIBRARIES "mp3lame::mpghip")
|
||||
endif ()
|
||||
endif ()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ include (CheckTypeSize)
|
|||
include (TestBigEndian)
|
||||
|
||||
include (TestInline)
|
||||
include (ClipMode)
|
||||
include (TestLargeFiles)
|
||||
include (CheckCPUArch)
|
||||
|
||||
|
|
@ -16,10 +15,9 @@ if (LARGE_FILES_DEFINITIONS)
|
|||
add_definitions(${LARGE_FILES_DEFINITIONS})
|
||||
endif ()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
find_package (Sndio)
|
||||
elseif (NOT WIN32)
|
||||
if (NOT WIN32)
|
||||
find_package (ALSA)
|
||||
find_package (Sndio)
|
||||
endif ()
|
||||
|
||||
if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15))
|
||||
|
|
@ -104,7 +102,7 @@ check_type_size (wchar_t SIZEOF_WCHAR_T)
|
|||
# Never checked
|
||||
# check_type_size (size_t SIZEOF_SIZE_T)
|
||||
|
||||
# Used in configre.ac
|
||||
# Used in configure.ac
|
||||
# check_type_size (double SIZEOF_DOUBLE)
|
||||
# check_type_size (float SIZEOF_FLOAT)
|
||||
# check_type_size (int SIZEOF_INT)
|
||||
|
|
@ -196,7 +194,6 @@ if (CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
|||
endif ()
|
||||
|
||||
test_inline ()
|
||||
clip_mode ()
|
||||
|
||||
if (MSVC)
|
||||
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
|
|
@ -252,5 +249,5 @@ if (DEFINED ENABLE_STATIC_RUNTIME)
|
|||
endif ()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
find_package (PythonInterp REQUIRED)
|
||||
find_package (Python REQUIRED)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -141,9 +141,6 @@ AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE], [${EXPERIMENTAL_CODE}], [Set to 1
|
|||
AC_ARG_ENABLE([werror],
|
||||
[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],
|
||||
[AS_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs])])
|
||||
|
||||
|
|
@ -153,6 +150,9 @@ AC_ARG_ENABLE([sqlite],
|
|||
AC_ARG_ENABLE([alsa],
|
||||
[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],
|
||||
[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])
|
||||
|
||||
dnl ====================================================================================
|
||||
dnl Check for requirements for building plugins for other languages/enviroments.
|
||||
dnl Check for requirements for building plugins for other languages/environments.
|
||||
|
||||
dnl Octave maths environment http://www.octave.org/
|
||||
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.])
|
||||
|
||||
dnl ====================================================================================
|
||||
dnl Check for MPEG libraris liblame
|
||||
dnl Check for MPEG libraries liblame
|
||||
|
||||
ac_cv_lame="no"
|
||||
ac_cv_mpg123="no"
|
||||
|
|
@ -402,22 +402,6 @@ AS_IF([test "x$enable_sqlite" != "xno"], [
|
|||
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"])
|
||||
|
||||
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 Host OS specific stuff.
|
||||
|
||||
|
|
@ -490,17 +474,30 @@ AS_IF([test "x$enable_alsa" != "xno"], [
|
|||
])
|
||||
|
||||
dnl ====================================================================================
|
||||
dnl Check for OpenBSD's sndio.
|
||||
dnl Check for Sndio.
|
||||
|
||||
SNDIO_LIBS=""
|
||||
HAVE_SNDIO_H=0
|
||||
AS_CASE([$host_os],
|
||||
[openbsd*], [
|
||||
AC_CHECK_HEADERS(sndio.h)
|
||||
AS_IF([test "x$ac_cv_header_sndio_h" = "xyes"], [
|
||||
SNDIO_LIBS="-lsndio"
|
||||
HAVE_SNDIO_H=1
|
||||
AS_IF([test "x$alsa_works" != "xyes"], [
|
||||
AS_IF([test "x$enable_sndio" != "xno"], [
|
||||
PKG_CHECK_MODULES([SNDIO], [sndio], [
|
||||
HAVE_SNDIO_H=1
|
||||
ac_cv_sndio="yes"
|
||||
], [
|
||||
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.])
|
||||
|
|
@ -532,10 +529,7 @@ AS_IF([test "x$ac_cv_sizeof_double" != "x8"], [
|
|||
AC_MSG_WARN([[******************************************************************]])
|
||||
])
|
||||
|
||||
AS_IF([test "x$ac_cv_prog_HAVE_AUTOGEN" = "xno"], [
|
||||
AC_MSG_WARN([[Touching files in directory tests/.]])
|
||||
touch tests/*.c tests/*.h
|
||||
])
|
||||
AM_CONDITIONAL([HAVE_AUTOGEN], [test "x$ac_cv_prog_HAVE_AUTOGEN" = "xyes"])
|
||||
|
||||
dnl ====================================================================================
|
||||
dnl Settings for the HTML documentation.
|
||||
|
|
@ -578,17 +572,9 @@ AS_IF([test "x$enable_werror" = "xyes"], [
|
|||
AC_LANG_POP([C++])
|
||||
])
|
||||
|
||||
common_flags="-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wundef -Wuninitialized -Winit-self"
|
||||
common_flags="-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wno-format-truncation"
|
||||
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}"
|
||||
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])
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ documented) [here](command.md).**
|
|||
## Synopsis
|
||||
|
||||
```c
|
||||
#include <stdio.h>;
|
||||
#include <sndfile.h>;
|
||||
#include <stdio.h>
|
||||
#include <sndfile.h>
|
||||
```
|
||||
|
||||
| Name | Description |
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ main (void)
|
|||
static double data [BUFFER_LEN] ;
|
||||
|
||||
/* A SNDFILE is very much like a FILE in the Standard C library. The
|
||||
** sf_open function return an SNDFILE* pointer when they sucessfully
|
||||
** sf_open function return an SNDFILE* pointer when they successfully
|
||||
** open the specified file.
|
||||
*/
|
||||
SNDFILE *infile, *outfile ;
|
||||
|
|
@ -131,8 +131,8 @@ process_data (double *data, int count, int channels)
|
|||
|
||||
/* Process the data here.
|
||||
** If the soundfile contains more then 1 channel you need to take care of
|
||||
** the data interleaving youself.
|
||||
** Current we just apply a channel dependant gain.
|
||||
** the data interleaving yourself.
|
||||
** Current we just apply a channel dependent gain.
|
||||
*/
|
||||
|
||||
for (chan = 0 ; chan < channels ; chan ++)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ create_file (const char * fname, int format)
|
|||
/*
|
||||
** The SndfileHandle object will automatically close the file and
|
||||
** release all allocated memory when the object goes out of scope.
|
||||
** This is the Resource Acquisition Is Initailization idom.
|
||||
** This is the Resource Acquisition Is Initialization idom.
|
||||
** See : http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
|
||||
*/
|
||||
} /* create_file */
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ class SndfileHandle
|
|||
operator bool () const { return (p != SF_NULL) ; }
|
||||
|
||||
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 ; }
|
||||
int format (void) const { return p ? p->sfinfo.format : 0 ; }
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
#
|
||||
# Check whether -D_FORTIFY_SOURCE=2 can be added to CPPFLAGS without macro
|
||||
# redefinition warnings, other cpp warnings or linker. Some distributions
|
||||
# (such as Gentoo Linux) enable _FORTIFY_SOURCE globally in their
|
||||
# compilers, leading to unnecessary warnings in the form of
|
||||
# (such as Ubuntu or Gentoo Linux) enable _FORTIFY_SOURCE globally in
|
||||
# their compilers, leading to unnecessary warnings in the form of
|
||||
#
|
||||
# <command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
|
||||
# <built-in>: note: this is the location of the previous definition
|
||||
|
|
@ -29,19 +29,57 @@
|
|||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2017 David Seifert <soap@gentoo.org>
|
||||
# Copyright (c) 2019 Reini Urban <rurban@cpan.org>
|
||||
# Copyright (c) 2019, 2023 Reini Urban <rurban@cpan.org>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 4
|
||||
#serial 10
|
||||
|
||||
AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
|
||||
ac_save_cflags=$CFLAGS
|
||||
ac_cwerror_flag=yes
|
||||
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_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([],
|
||||
|
|
@ -49,7 +87,7 @@ AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
|
|||
#ifndef _FORTIFY_SOURCE
|
||||
return 0;
|
||||
#else
|
||||
this_is_an_error;
|
||||
_FORTIFY_SOURCE_already_defined;
|
||||
#endif
|
||||
]]
|
||||
)],
|
||||
|
|
@ -57,7 +95,7 @@ AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
|
|||
AC_LANG_SOURCE([[
|
||||
#define _FORTIFY_SOURCE 2
|
||||
#include <string.h>
|
||||
int main() {
|
||||
int main(void) {
|
||||
char *s = " ";
|
||||
strcpy(s, "x");
|
||||
return strlen(s)-1;
|
||||
|
|
@ -77,4 +115,5 @@ AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[
|
|||
AC_MSG_RESULT([no])
|
||||
CFLAGS=$ac_save_cflags
|
||||
])
|
||||
fi
|
||||
])
|
||||
|
|
|
|||
|
|
@ -30,33 +30,12 @@
|
|||
#
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# 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
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# 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.
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 6
|
||||
#serial 7
|
||||
|
||||
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
|
||||
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
|
||||
|
|
|
|||
|
|
@ -23,33 +23,12 @@
|
|||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# 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
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# 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.
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 7
|
||||
#serial 8
|
||||
|
||||
AC_DEFUN([AX_APPEND_FLAG],
|
||||
[dnl
|
||||
|
|
|
|||
|
|
@ -28,33 +28,12 @@
|
|||
#
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# 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
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# 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.
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 6
|
||||
#serial 7
|
||||
|
||||
AC_DEFUN([AX_APPEND_LINK_FLAGS],
|
||||
[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
|
||||
|
|
|
|||
|
|
@ -29,40 +29,29 @@
|
|||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# 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
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# 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.
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 5
|
||||
#serial 11
|
||||
|
||||
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
|
||||
[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
|
||||
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||
AC_CACHE_CHECK([whether the _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||
if test x"m4_case(_AC_LANG,
|
||||
[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()])],
|
||||
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||
[AS_VAR_SET(CACHEVAR,[no])])
|
||||
|
|
|
|||
|
|
@ -29,33 +29,12 @@
|
|||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# 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
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# 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.
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 5
|
||||
#serial 6
|
||||
|
||||
AC_DEFUN([AX_CHECK_LINK_FLAG],
|
||||
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
|
||||
|
|
|
|||
|
|
@ -8,15 +8,30 @@
|
|||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun,
|
||||
# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft,
|
||||
# watcom, etc. The vendor is returned in the cache variable
|
||||
# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
|
||||
# Determine the vendor of the C, C++ or Fortran compiler. The vendor is
|
||||
# returned in the cache variable $ax_cv_c_compiler_vendor for C,
|
||||
# $ax_cv_cxx_compiler_vendor for C++ or $ax_cv_fc_compiler_vendor for
|
||||
# (modern) Fortran. The value is one of "intel", "ibm", "pathscale",
|
||||
# "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
|
||||
#
|
||||
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
# 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
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
|
|
@ -44,44 +59,61 @@
|
|||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 16
|
||||
#serial 32
|
||||
|
||||
AC_DEFUN([AX_COMPILER_VENDOR],
|
||||
[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
|
||||
dnl Please add if possible support to ax_compiler_version.m4
|
||||
[# note: don't check for gcc first since some other compilers define __GNUC__
|
||||
vendors="intel: __ICC,__ECC,__INTEL_COMPILER
|
||||
ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__
|
||||
pathscale: __PATHCC__,__PATHSCALE__
|
||||
clang: __clang__
|
||||
cray: _CRAYC
|
||||
fujitsu: __FUJITSU
|
||||
gnu: __GNUC__
|
||||
sun: __SUNPRO_C,__SUNPRO_CC
|
||||
hp: __HP_cc,__HP_aCC
|
||||
dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
|
||||
borland: __BORLANDC__,__CODEGEARC__,__TURBOC__
|
||||
comeau: __COMO__
|
||||
kai: __KCC
|
||||
lcc: __LCC__
|
||||
sgi: __sgi,sgi
|
||||
microsoft: _MSC_VER
|
||||
metrowerks: __MWERKS__
|
||||
watcom: __WATCOMC__
|
||||
portland: __PGI
|
||||
tcc: __TINYC__
|
||||
unknown: UNKNOWN"
|
||||
for ventest in $vendors; do
|
||||
case $ventest in
|
||||
*:) 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`
|
||||
])
|
||||
])
|
||||
AC_DEFUN([AX_COMPILER_VENDOR], [dnl
|
||||
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [dnl
|
||||
dnl If you modify this list of vendors, please add similar support
|
||||
dnl to ax_compiler_version.m4 if at all possible.
|
||||
dnl
|
||||
dnl Note: Do NOT check for GCC first since some other compilers
|
||||
dnl define __GNUC__ to remain compatible with it. Compilers that
|
||||
dnl are very slow to start (such as Intel) are listed first.
|
||||
|
||||
vendors="
|
||||
intel: __ICC,__ECC,__INTEL_COMPILER
|
||||
ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__,__ibmxl__
|
||||
pathscale: __PATHCC__,__PATHSCALE__
|
||||
clang: __clang__
|
||||
cray: _CRAYC
|
||||
fujitsu: __FUJITSU
|
||||
sdcc: SDCC,__SDCC
|
||||
sx: _SX
|
||||
nvhpc: __NVCOMPILER
|
||||
portland: __PGI
|
||||
gnu: __GNUC__
|
||||
sun: __SUNPRO_C,__SUNPRO_CC,__SUNPRO_F90,__SUNPRO_F95
|
||||
hp: __HP_cc,__HP_aCC
|
||||
dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
|
||||
borland: __BORLANDC__,__CODEGEARC__,__TURBOC__
|
||||
comeau: __COMO__
|
||||
kai: __KCC
|
||||
lcc: __LCC__
|
||||
sgi: __sgi,sgi
|
||||
microsoft: _MSC_VER
|
||||
metrowerks: __MWERKS__
|
||||
watcom: __WATCOMC__
|
||||
tcc: __TINYC__
|
||||
unknown: UNKNOWN
|
||||
"
|
||||
for ventest in $vendors; do
|
||||
case $ventest in
|
||||
*:)
|
||||
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
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 9
|
||||
#serial 14
|
||||
|
||||
# for intel
|
||||
AC_DEFUN([_AX_COMPILER_VERSION_INTEL],
|
||||
|
|
@ -442,6 +442,20 @@ 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"
|
||||
])
|
||||
|
||||
# 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
|
||||
AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[
|
||||
AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
|
||||
|
|
@ -460,6 +474,42 @@ AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[
|
|||
AC_DEFUN([_AX_COMPILER_VERSION_TCC],[
|
||||
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
|
||||
AC_DEFUN([AX_COMPILER_VERSION],[dnl
|
||||
AC_REQUIRE([AX_COMPILER_VENDOR])
|
||||
|
|
@ -485,8 +535,10 @@ AC_DEFUN([AX_COMPILER_VERSION],[dnl
|
|||
[microsoft],[_AX_COMPILER_VERSION_MICROSOFT],
|
||||
[metrowerks],[_AX_COMPILER_VERSION_METROWERKS],
|
||||
[watcom],[_AX_COMPILER_VERSION_WATCOM],
|
||||
[nvhpc],[_AX_COMPILER_VERSION_NVHPC],
|
||||
[portland],[_AX_COMPILER_VERSION_PORTLAND],
|
||||
[tcc],[_AX_COMPILER_VERSION_TCC],
|
||||
[sdcc],[_AX_COMPILER_VERSION_SDCC],
|
||||
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""])
|
||||
])
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1,124 +0,0 @@
|
|||
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
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
dnl @synopsis MN_C99_FLEXIBLE_ARRAY
|
||||
dnl
|
||||
dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
|
||||
dnl Does the compiler support the 1999 ISO C Standard "struct hack".
|
||||
dnl @version 1.1 Mar 15 2004
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ output APIs. The following table summarizes which audio API is used where:
|
|||
.Pp
|
||||
.Bl -tag -width MacOSX10XXX -compact
|
||||
.It Linux
|
||||
ALSA or OSS
|
||||
ALSA, OSS or sndio
|
||||
.It OpenBSD
|
||||
sndio
|
||||
.It FreeBSD
|
||||
/dev/dsp (OSS)
|
||||
/dev/dsp (OSS) or sndio
|
||||
.It NetBSD
|
||||
/dev/audio
|
||||
.It Solaris
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef SNDFILE_FUZZ_HEADER_H
|
||||
#define SNDFILE_FUZZ_HEADER_H
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sf_count_t offset ;
|
||||
|
|
@ -32,6 +34,9 @@ static sf_count_t vfseek (sf_count_t offset, int whence, void *user_data)
|
|||
break ;
|
||||
|
||||
default :
|
||||
// SEEK_DATA and SEEK_HOLE are not supported by this function.
|
||||
errno = EINVAL ;
|
||||
return -1 ;
|
||||
break ;
|
||||
}
|
||||
|
||||
|
|
@ -88,8 +93,7 @@ int sf_init_file(const uint8_t *data,
|
|||
SNDFILE **sndfile,
|
||||
VIO_DATA *vio_data,
|
||||
SF_VIRTUAL_IO *vio, SF_INFO *sndfile_info)
|
||||
{ float* read_buffer = NULL ;
|
||||
|
||||
{
|
||||
// Initialize the virtual IO structure.
|
||||
vio->get_filelen = vfget_filelen ;
|
||||
vio->seek = vfseek ;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ usage_exit (const char *progname)
|
|||
printf ("\nUsage : %s <infile1> <infile2> ... <outfile>\n\n", progname) ;
|
||||
puts (
|
||||
" Create a new output file <outfile> containing the concatenated\n"
|
||||
" audio data from froms <infile1> <infile2> ....\n"
|
||||
" audio data from <infile1> <infile2> ....\n"
|
||||
"\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"
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ main (int argc, char * argv [])
|
|||
if ((sfinfo.format & SF_FORMAT_SUBMASK) == SF_FORMAT_GSM610 && sfinfo.samplerate != 8000)
|
||||
{ printf (
|
||||
"WARNING: GSM 6.10 data format only supports 8kHz sample rate. The converted\n"
|
||||
"ouput file will contain the input data converted to the GSM 6.10 data format\n"
|
||||
"output file will contain the input data converted to the GSM 6.10 data format\n"
|
||||
"but not re-sampled.\n"
|
||||
) ;
|
||||
} ;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ main (int argc, char *argv [])
|
|||
info.has_bext_fields = has_bext_fields_set (&info) ;
|
||||
|
||||
if (filenames [0] == NULL)
|
||||
{ printf ("Error : No input file specificed.\n\n") ;
|
||||
{ printf ("Error : No input file specified.\n\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,27 +52,26 @@
|
|||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
#include <alsa/asoundlib.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
|
||||
#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__)
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/audioio.h>
|
||||
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#endif
|
||||
|
||||
#define SIGNED_SIZEOF(x) ((int) sizeof (x))
|
||||
|
|
@ -349,13 +348,71 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
|
|||
return total ;
|
||||
} /* 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.
|
||||
*/
|
||||
|
||||
#if !defined (__ANDROID__) && (defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__))
|
||||
#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__)
|
||||
|
||||
static int opensoundsys_open_device (int channels, int srate) ;
|
||||
|
||||
|
|
@ -466,8 +523,6 @@ opensoundsys_open_device (int channels, int srate)
|
|||
return fd ;
|
||||
} /* opensoundsys_open_device */
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Mac OS X functions for playing a sound.
|
||||
*/
|
||||
|
|
@ -482,7 +537,7 @@ opensoundsys_open_device (int channels, int srate)
|
|||
** point to data instead of short*. It plain sucks!
|
||||
*/
|
||||
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
|
||||
#define WIN32_BUFFER_LEN (1 << 15)
|
||||
|
||||
|
|
@ -508,7 +563,7 @@ static void
|
|||
win32_play_data (Win32_Audio_Data *audio_data)
|
||||
{ int thisread, readcount ;
|
||||
|
||||
/* fill a buffer if there is more data and we can read it sucessfully */
|
||||
/* fill a buffer if there is more data and we can read it successfully */
|
||||
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 ;
|
||||
|
|
@ -663,73 +718,11 @@ win32_play (int argc, char *argv [])
|
|||
|
||||
} /* 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.
|
||||
*/
|
||||
|
||||
#if (defined (sun) && defined (unix)) || defined(__NetBSD__)
|
||||
#elif (defined (sun) && defined (unix)) || defined(__NetBSD__)
|
||||
|
||||
static void
|
||||
solaris_play (int argc, char *argv [])
|
||||
|
|
@ -759,7 +752,7 @@ solaris_play (int argc, char *argv [])
|
|||
return ;
|
||||
} ;
|
||||
|
||||
/* Retrive standard values. */
|
||||
/* Retrieve standard values. */
|
||||
AUDIO_INITINFO (&audio_info) ;
|
||||
|
||||
audio_info.play.sample_rate = sfinfo.samplerate ;
|
||||
|
|
@ -830,31 +823,35 @@ main (int argc, char *argv [])
|
|||
return 1 ;
|
||||
} ;
|
||||
|
||||
#if defined (__ANDROID__)
|
||||
puts ("*** Playing sound not yet supported on Android.") ;
|
||||
puts ("*** Please feel free to submit a patch.") ;
|
||||
return 1 ;
|
||||
#elif defined (__linux__)
|
||||
#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) ;
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
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 (sun) && defined (unix)) || defined(__NetBSD__)
|
||||
solaris_play (argc, argv) ;
|
||||
|
||||
#elif defined (__ANDROID__)
|
||||
puts ("*** Playing sound not yet supported on Android.") ;
|
||||
puts ("*** Please feel free to submit a patch.") ;
|
||||
return EXIT_FAILURE ;
|
||||
|
||||
#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__)
|
||||
opensoundsys_play (argc, argv) ;
|
||||
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
win32_play (argc, argv) ;
|
||||
|
||||
#elif (defined (sun) && defined (unix)) || defined(__NetBSD__)
|
||||
solaris_play (argc, argv) ;
|
||||
|
||||
#else
|
||||
puts ("*** Playing sound not supported on this platform.") ;
|
||||
puts ("*** Please feel free to submit a patch.") ;
|
||||
return 1 ;
|
||||
return EXIT_FAILURE ;
|
||||
#endif
|
||||
|
||||
return 0 ;
|
||||
return EXIT_SUCCESS ;
|
||||
} /* main */
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ with the libsndfile source code distribution.
|
|||
|
||||
Organization of Files
|
||||
---------------------
|
||||
The regession test program keeps its database file in the directory it
|
||||
The regression test program keeps its database file in the directory it
|
||||
is run from. In addition, the database only contains information about
|
||||
the files, not the files themselves.
|
||||
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ int dummy (void) ;
|
|||
int
|
||||
dummy (void)
|
||||
{ /*
|
||||
** Empty dummy fnction so tha compiler doesn't winge about an
|
||||
** Empty dummy function so the compiler doesn't whine about an
|
||||
** empty file.
|
||||
*/
|
||||
return 0 ;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
Copyright: (c) 2001-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
Copyright: (c) 2001-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "aglib.h"
|
||||
#include "ALACBitUtilities.h"
|
||||
#include "EndianPortable.h"
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@
|
|||
File: ALACDecoder.cpp
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alac_codec.h"
|
||||
|
|
@ -38,11 +41,6 @@
|
|||
#include "ALACBitUtilities.h"
|
||||
#include "EndianPortable.h"
|
||||
|
||||
typedef enum
|
||||
{ false = 0,
|
||||
true = 1
|
||||
} bool ;
|
||||
|
||||
// constants/data
|
||||
const uint32_t kMaxBitDepth = 32 ; // max allowed bit depth is 32
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,11 @@
|
|||
#define DebugMsg printf
|
||||
|
||||
// headers
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sfendian.h"
|
||||
|
|
@ -44,12 +47,6 @@
|
|||
#include "ALACAudioTypes.h"
|
||||
#include "EndianPortable.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
false = 0,
|
||||
true = 1
|
||||
} bool ;
|
||||
|
||||
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) ;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
Copyright: (c) 2004-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "matrixlib.h"
|
||||
#include "ALACAudioTypes.h"
|
||||
#include "shift.h"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
Copyright: (c) 2004-2011 Apple, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "matrixlib.h"
|
||||
#include "ALACAudioTypes.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ g723_test (double margin)
|
|||
} ;
|
||||
} ;
|
||||
|
||||
printf ("\n\nMax error of %d at postion %d.\n", max_err, position) ;
|
||||
printf ("\n\nMax error of %d at position %d.\n", max_err, position) ;
|
||||
|
||||
for (k = 0 ; k < BUFFER_SIZE ; k++)
|
||||
{ if (error_function (data [k], orig [k], margin))
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
#define MAC6_MARKER (MAKE_MARKER ('M', 'A', 'C', '6'))
|
||||
#define ADP4_MARKER (MAKE_MARKER ('A', 'D', 'P', '4'))
|
||||
|
||||
/* Predfined chunk sizes. */
|
||||
/* Predefined chunk sizes. */
|
||||
#define SIZEOF_AIFF_COMM 18
|
||||
#define SIZEOF_AIFC_COMM_MIN 22
|
||||
#define SIZEOF_AIFC_COMM 24
|
||||
|
|
@ -1702,7 +1702,7 @@ static int
|
|||
aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize)
|
||||
{ const char * type_str ;
|
||||
basc_CHUNK bc ;
|
||||
int count ;
|
||||
sf_count_t count ;
|
||||
|
||||
count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ;
|
||||
count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ;
|
||||
|
|
|
|||
|
|
@ -885,7 +885,7 @@ alac_pakt_encode (const SF_PRIVATE *psf, uint32_t * pakt_size_out)
|
|||
plac = psf->codec_data ;
|
||||
info = plac->pakt_info ;
|
||||
|
||||
allocated = 100 + 2 * info->count ;
|
||||
allocated = 100 + 4 * info->count ;
|
||||
if ((data = calloc (1, allocated)) == NULL)
|
||||
return NULL ;
|
||||
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ static int
|
|||
au_read_header (SF_PRIVATE *psf)
|
||||
{ AU_FMT au_fmt ;
|
||||
int marker, dword ;
|
||||
sf_count_t data_end ;
|
||||
|
||||
memset (&au_fmt, 0, sizeof (au_fmt)) ;
|
||||
psf_binheader_readf (psf, "pm", 0, &marker) ;
|
||||
|
|
@ -317,14 +318,15 @@ au_read_header (SF_PRIVATE *psf)
|
|||
return SFE_AU_EMBED_BAD_LEN ;
|
||||
} ;
|
||||
|
||||
data_end = (sf_count_t) au_fmt.dataoffset + (sf_count_t) au_fmt.datasize ;
|
||||
if (psf->fileoffset > 0)
|
||||
{ psf->filelength = au_fmt.dataoffset + au_fmt.datasize ;
|
||||
{ psf->filelength = data_end ;
|
||||
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
|
||||
}
|
||||
else if (au_fmt.datasize == -1 || au_fmt.dataoffset + au_fmt.datasize == psf->filelength)
|
||||
else if (au_fmt.datasize == -1 || data_end == psf->filelength)
|
||||
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
|
||||
else if (au_fmt.dataoffset + au_fmt.datasize < psf->filelength)
|
||||
{ psf->filelength = au_fmt.dataoffset + au_fmt.datasize ;
|
||||
else if (data_end < psf->filelength)
|
||||
{ psf->filelength = data_end ;
|
||||
psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ avr_read_header (SF_PRIVATE *psf)
|
|||
psf->endian = SF_ENDIAN_BIG ;
|
||||
|
||||
psf->dataoffset = AVR_HDR_SIZE ;
|
||||
psf->datalength = hdr.frames * (hdr.rez / 8) ;
|
||||
psf->datalength = (sf_count_t) hdr.frames * (hdr.rez / 8) ;
|
||||
|
||||
if (psf->fileoffset > 0)
|
||||
psf->filelength = AVR_HDR_SIZE + psf->datalength ;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2006-2017 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
|
|
@ -36,79 +36,91 @@
|
|||
# correct.
|
||||
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
import re, string, sys
|
||||
_whitespace_re = re.compile(r"\s+", re.MULTILINE)
|
||||
|
||||
_whitespace_re = re.compile ("\s+", re.MULTILINE)
|
||||
|
||||
def find_binheader_writefs (data):
|
||||
lst = re.findall ('psf_binheader_writef\s*\(\s*[a-zA-Z_]+\s*,\s*\"[^;]+;', data, re.MULTILINE)
|
||||
return [_whitespace_re.sub (" ", x) for x in lst]
|
||||
def find_binheader_writefs(data):
|
||||
lst = re.findall(
|
||||
r'psf_binheader_writef\s*\(\s*[a-zA-Z_]+\s*,\s*"[^;]+;', data, re.MULTILINE
|
||||
)
|
||||
return [_whitespace_re.sub(" ", x) for x in lst]
|
||||
|
||||
def find_format_string (s):
|
||||
fmt = re.search ('"([^"]+)"', s)
|
||||
|
||||
def find_format_string(s):
|
||||
fmt = re.search('"([^"]+)"', s)
|
||||
if not fmt:
|
||||
print ("Bad format in :\n\n\t%s\n\n" % s)
|
||||
sys.exit (1)
|
||||
fmt = fmt.groups ()
|
||||
if len (fmt) != 1:
|
||||
print ("Bad format in :\n\n\t%s\n\n" % s)
|
||||
sys.exit (1)
|
||||
return _whitespace_re.sub ("", fmt [0])
|
||||
print(f"Bad format in :\n\n\t{s}\n\n")
|
||||
sys.exit(1)
|
||||
fmt = fmt.groups()
|
||||
if len(fmt) != 1:
|
||||
print(f"Bad format in :\n\n\t{s}\n\n")
|
||||
sys.exit(1)
|
||||
return _whitespace_re.sub("", fmt[0])
|
||||
|
||||
def get_param_list (data):
|
||||
dlist = re.search ("\((.+)\)\s*;", data)
|
||||
dlist = dlist.groups ()[0]
|
||||
|
||||
def get_param_list(data):
|
||||
dlist = re.search(r"\((.+)\)\s*;", data)
|
||||
dlist = dlist.groups()[0]
|
||||
dlist = dlist.split(",")
|
||||
dlist = [x.strip() for x in dlist]
|
||||
return dlist [2:]
|
||||
return dlist[2:]
|
||||
|
||||
def handle_file (fname):
|
||||
|
||||
def handle_file(fname):
|
||||
errors = 0
|
||||
data = open (fname, "r").read ()
|
||||
data = open(fname, "r").read()
|
||||
|
||||
# return errors
|
||||
|
||||
writefs = find_binheader_writefs (data)
|
||||
writefs = find_binheader_writefs(data)
|
||||
for item in writefs:
|
||||
fmt = find_format_string (item)
|
||||
params = get_param_list (item)
|
||||
fmt = find_format_string(item)
|
||||
params = get_param_list(item)
|
||||
param_index = 0
|
||||
|
||||
# print item
|
||||
|
||||
for ch in fmt:
|
||||
if ch in 'Eet ':
|
||||
if ch in "Eet ":
|
||||
continue
|
||||
|
||||
if ch == 'b':
|
||||
if params [param_index][:4] == "BHWv" and params [param_index + 1][:4] == "BHWz":
|
||||
if ch == "b":
|
||||
if (
|
||||
params[param_index][:4] == "BHWv"
|
||||
and params[param_index + 1][:4] == "BHWz"
|
||||
):
|
||||
param_index += 2
|
||||
continue
|
||||
|
||||
if "BHW" + ch == params [param_index][:4]:
|
||||
if "BHW" + ch == params[param_index][:4]:
|
||||
param_index += 1
|
||||
continue
|
||||
|
||||
if errors == 0: sys.stdout.write ("\n")
|
||||
print ("\n%s: error for format specifier '%c' (index %d) in:\n %s\n" % (fname, ch, param_index, item))
|
||||
if errors == 0:
|
||||
sys.stdout.write("\n")
|
||||
print(
|
||||
f"\n{fname}: error for format specifier '{ch}' (index {param_index}) in:\n {item}\n"
|
||||
)
|
||||
errors += 1
|
||||
# Break out of 'for ch in fmt' loop
|
||||
break
|
||||
|
||||
return errors
|
||||
|
||||
#===============================================================================
|
||||
|
||||
if len (sys.argv) > 1:
|
||||
sys.stdout.write ("\n binheader_writef_check : ")
|
||||
sys.stdout.flush ()
|
||||
# ===============================================================================
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
sys.stdout.write("\n binheader_writef_check : ")
|
||||
sys.stdout.flush()
|
||||
errors = 0
|
||||
for fname in sys.argv [1:]:
|
||||
errors += handle_file (fname)
|
||||
for fname in sys.argv[1:]:
|
||||
errors += handle_file(fname)
|
||||
if errors > 0:
|
||||
print ("\nErrors : %d\n" % errors)
|
||||
sys.exit (1)
|
||||
|
||||
print ("ok\n")
|
||||
print(f"\nErrors : {errors}\n")
|
||||
sys.exit(1)
|
||||
|
||||
print("ok\n")
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
|
|
@ -990,6 +991,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
double *doubleptr ;
|
||||
char c ;
|
||||
int byte_count = 0, count = 0 ;
|
||||
int read_bytes = 0 ;
|
||||
|
||||
if (! format)
|
||||
return psf_ftell (psf) ;
|
||||
|
|
@ -998,6 +1000,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
|
||||
while ((c = *format++))
|
||||
{
|
||||
read_bytes = 0 ;
|
||||
if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
|
||||
break ;
|
||||
|
||||
|
|
@ -1014,7 +1017,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
read_bytes = header_read (psf, ucptr, sizeof (int)) ;
|
||||
*intptr = GET_MARKER (ucptr) ;
|
||||
break ;
|
||||
|
||||
|
|
@ -1022,7 +1025,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;
|
||||
read_bytes = header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ;
|
||||
{ int k ;
|
||||
intdata = 0 ;
|
||||
for (k = 0 ; k < 16 ; k++)
|
||||
|
|
@ -1034,14 +1037,14 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case '1' :
|
||||
charptr = va_arg (argptr, char*) ;
|
||||
*charptr = 0 ;
|
||||
byte_count += header_read (psf, charptr, sizeof (char)) ;
|
||||
read_bytes = header_read (psf, charptr, sizeof (char)) ;
|
||||
break ;
|
||||
|
||||
case '2' : /* 2 byte value with the current endian-ness */
|
||||
shortptr = va_arg (argptr, unsigned short*) ;
|
||||
*shortptr = 0 ;
|
||||
ucptr = (unsigned char*) shortptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (short)) ;
|
||||
read_bytes = header_read (psf, ucptr, sizeof (short)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*shortptr = GET_BE_SHORT (ucptr) ;
|
||||
else
|
||||
|
|
@ -1051,7 +1054,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case '3' : /* 3 byte value with the current endian-ness */
|
||||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
byte_count += header_read (psf, sixteen_bytes, 3) ;
|
||||
read_bytes = header_read (psf, sixteen_bytes, 3) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*intptr = GET_BE_3BYTE (sixteen_bytes) ;
|
||||
else
|
||||
|
|
@ -1062,7 +1065,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
intptr = va_arg (argptr, unsigned int*) ;
|
||||
*intptr = 0 ;
|
||||
ucptr = (unsigned char*) intptr ;
|
||||
byte_count += header_read (psf, ucptr, sizeof (int)) ;
|
||||
read_bytes = header_read (psf, ucptr, sizeof (int)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*intptr = psf_get_be32 (ucptr, 0) ;
|
||||
else
|
||||
|
|
@ -1072,7 +1075,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case '8' : /* 8 byte value with the current endian-ness */
|
||||
countptr = va_arg (argptr, sf_count_t *) ;
|
||||
*countptr = 0 ;
|
||||
byte_count += header_read (psf, sixteen_bytes, 8) ;
|
||||
read_bytes = header_read (psf, sixteen_bytes, 8) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
countdata = psf_get_be64 (sixteen_bytes, 0) ;
|
||||
else
|
||||
|
|
@ -1083,7 +1086,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case 'f' : /* Float conversion */
|
||||
floatptr = va_arg (argptr, float *) ;
|
||||
*floatptr = 0.0 ;
|
||||
byte_count += header_read (psf, floatptr, sizeof (float)) ;
|
||||
read_bytes = header_read (psf, floatptr, sizeof (float)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*floatptr = float32_be_read ((unsigned char*) floatptr) ;
|
||||
else
|
||||
|
|
@ -1093,7 +1096,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case 'd' : /* double conversion */
|
||||
doubleptr = va_arg (argptr, double *) ;
|
||||
*doubleptr = 0.0 ;
|
||||
byte_count += header_read (psf, doubleptr, sizeof (double)) ;
|
||||
read_bytes = header_read (psf, doubleptr, sizeof (double)) ;
|
||||
if (psf->rwf_endian == SF_ENDIAN_BIG)
|
||||
*doubleptr = double64_be_read ((unsigned char*) doubleptr) ;
|
||||
else
|
||||
|
|
@ -1117,7 +1120,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
charptr = va_arg (argptr, char*) ;
|
||||
count = va_arg (argptr, size_t) ;
|
||||
memset (charptr, 0, count) ;
|
||||
byte_count += header_read (psf, charptr, count) ;
|
||||
read_bytes = header_read (psf, charptr, count) ;
|
||||
break ;
|
||||
|
||||
case 'G' :
|
||||
|
|
@ -1128,7 +1131,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))
|
||||
break ;
|
||||
|
||||
byte_count += header_gets (psf, charptr, count) ;
|
||||
read_bytes = header_gets (psf, charptr, count) ;
|
||||
break ;
|
||||
|
||||
case 'z' :
|
||||
|
|
@ -1152,7 +1155,7 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
case 'j' : /* Seek to position from current position. */
|
||||
count = va_arg (argptr, size_t) ;
|
||||
header_seek (psf, count, SEEK_CUR) ;
|
||||
byte_count += count ;
|
||||
read_bytes = count ;
|
||||
break ;
|
||||
|
||||
case '!' : /* Clear buffer, forcing re-read. */
|
||||
|
|
@ -1164,8 +1167,17 @@ psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
|
|||
psf->error = SFE_INTERNAL ;
|
||||
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) ;
|
||||
|
||||
return byte_count ;
|
||||
|
|
@ -1761,18 +1773,14 @@ psf_f2i_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ dest [i] = 0x7FFFFFFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ dest [i] = 0x80000000 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
dest [i] = psf_lrintf (scaled_value) ;
|
||||
} ;
|
||||
|
|
@ -1782,7 +1790,7 @@ psf_f2i_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
|
||||
void
|
||||
psf_d2i_array (const double *src, int *dest, int count, int normalize)
|
||||
{ double normfact ;
|
||||
{ double normfact ;
|
||||
|
||||
normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ;
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
|
|
@ -1799,18 +1807,14 @@ psf_d2i_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ dest [i] = 0x7FFFFFFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ dest [i] = 0x80000000 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
dest [i] = psf_lrint (scaled_value) ;
|
||||
} ;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
#define SF_MAX_CHANNELS 1024
|
||||
|
||||
/*
|
||||
* Macros for spliting the format file of SF_INFO into container type,
|
||||
* Macros for splitting the format file of SF_INFO into container type,
|
||||
** codec type and endian-ness.
|
||||
*/
|
||||
#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) ;
|
||||
|
||||
/*=======================================================================================
|
||||
** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the
|
||||
** SF_PRIVATE struct - 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
|
||||
** contents.
|
||||
*/
|
||||
|
|
@ -402,7 +402,7 @@ typedef struct sf_private_tag
|
|||
|
||||
int scale_int_float ;
|
||||
|
||||
/* Vairables for handling pipes. */
|
||||
/* Variables for handling pipes. */
|
||||
int is_pipe ; /* True if file is 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 dataend ; /* Offset to file tailer. */
|
||||
|
||||
int blockwidth ; /* Size in bytes of one set of interleaved samples. */
|
||||
sf_count_t blockwidth ; /* Size in bytes of one set of interleaved samples. */
|
||||
int bytewidth ; /* Size in bytes of one sample (one channel). */
|
||||
|
||||
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
|
||||
**
|
||||
** These functions are available on *BSD, but are not avaialble everywhere so we
|
||||
** These functions are available on *BSD, but are not available everywhere so we
|
||||
** implement them here.
|
||||
**
|
||||
** 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)
|
||||
{
|
||||
#ifdef USE_SSE2
|
||||
return _mm_cvtss_si32 (_mm_load_ss (&x)) ;
|
||||
return _mm_cvtss_si32 (_mm_load_ss (&x)) ;
|
||||
#else
|
||||
return lrintf (x) ;
|
||||
#endif
|
||||
|
|
@ -973,7 +973,7 @@ static inline int psf_lrintf (float x)
|
|||
static inline int psf_lrint (double x)
|
||||
{
|
||||
#ifdef USE_SSE2
|
||||
return _mm_cvtsd_si32 (_mm_load_sd (&x)) ;
|
||||
return _mm_cvtsd_si32 (_mm_load_sd (&x)) ;
|
||||
#else
|
||||
return lrint (x) ;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
/* Set to 1 if the compile is GNU 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. */
|
||||
#cmakedefine01 CPU_IS_BIG_ENDIAN
|
||||
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ double64_get_capability (SF_PRIVATE *psf)
|
|||
unsigned char c [8] ;
|
||||
} data ;
|
||||
|
||||
data.d = 1.234567890123456789 ; /* Some abitrary value. */
|
||||
data.d = 1.234567890123456789 ; /* Some arbitrary value. */
|
||||
|
||||
if (! psf->ieee_replace)
|
||||
{ /* 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++)
|
||||
{ float tmp = scale * src [i] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
|
||||
if (tmp > (1.0 * INT_MAX))
|
||||
dest [i] = INT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
|
||||
else if (tmp < (-1.0 * INT_MAX))
|
||||
dest [i] = INT_MIN ;
|
||||
else
|
||||
dest [i] = psf_lrint (tmp) ;
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count)
|
|||
|
||||
if (bit_count < 0)
|
||||
{ get_dwm = SF_TRUE ;
|
||||
/* modify bit_count to ensure we have enought bits for finding dwm. */
|
||||
/* modify bit_count to ensure we have enough bits for finding dwm. */
|
||||
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)
|
||||
{ int byte ;
|
||||
|
||||
/* Shift the bits into the resevoir. */
|
||||
/* Shift the bits into the reservoir. */
|
||||
pdwvw->bits = arith_shift_left (pdwvw->bits, new_bits) | (data & (arith_shift_left (1, new_bits) - 1)) ;
|
||||
pdwvw->bit_count += new_bits ;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#define SENSIBLE_SIZE (0x40000000)
|
||||
|
||||
/*
|
||||
** Neat solution to the Win32/OS2 binary file flage requirement.
|
||||
** Neat solution to the Win32/OS2 binary file flag requirement.
|
||||
** If O_BINARY isn't already defined by the inclusion of the system
|
||||
** headers, set it to zero.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ float32_get_capability (SF_PRIVATE *psf)
|
|||
unsigned char c [4] ;
|
||||
} data ;
|
||||
|
||||
data.f = (float) 1.23456789 ; /* Some abitrary value. */
|
||||
data.f = (float) 1.23456789 ; /* Some arbitrary value. */
|
||||
|
||||
if (! psf->ieee_replace)
|
||||
{ /* 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++)
|
||||
{ float tmp = scale * src [i] ;
|
||||
|
||||
if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX))
|
||||
if (tmp > (1.0 * INT_MAX))
|
||||
dest [i] = INT_MAX ;
|
||||
else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
|
||||
else if (tmp < (-1.0 * INT_MAX))
|
||||
dest [i] = INT_MIN ;
|
||||
else
|
||||
dest [i] = psf_lrintf (tmp) ;
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
|||
** to avoid having to branch when pulling apart the nibbles.
|
||||
*/
|
||||
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)))
|
||||
return SFE_MALLOC_FAILED ;
|
||||
|
|
@ -238,7 +238,7 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
|
|||
case SF_FORMAT_AIFF :
|
||||
psf_log_printf (psf, "still need to check block count\n") ;
|
||||
pima->decode_block = aiff_ima_decode_block ;
|
||||
psf->sf.frames = pima->samplesperblock * pima->blocks / pima->channels ;
|
||||
psf->sf.frames = (sf_count_t) pima->samplesperblock * pima->blocks / pima->channels ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
|
|
@ -262,9 +262,6 @@ aiff_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
|
|||
int chan, k, diff, bytecode, predictor ;
|
||||
short step, stepindx, *sampledata ;
|
||||
|
||||
static int count = 0 ;
|
||||
count ++ ;
|
||||
|
||||
pima->blockcount += pima->channels ;
|
||||
pima->samplecount = 0 ;
|
||||
|
||||
|
|
@ -391,7 +388,7 @@ aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
|
|||
static int
|
||||
wavlike_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
|
||||
{ int chan, k, predictor, blockindx, indx, indxstart, diff ;
|
||||
short step, bytecode, stepindx [2] = { 0 };
|
||||
short step, bytecode, stepindx [2] = { 0 } ;
|
||||
|
||||
pima->blockcount ++ ;
|
||||
pima->samplecount = 0 ;
|
||||
|
|
@ -1005,4 +1002,3 @@ ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
|
|||
|
||||
return total ;
|
||||
} /* ima_write_d */
|
||||
|
||||
|
|
|
|||
|
|
@ -171,35 +171,35 @@ ircam_read_header (SF_PRIVATE *psf)
|
|||
switch (encoding)
|
||||
{ case IRCAM_PCM_16 :
|
||||
psf->bytewidth = 2 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_16 ;
|
||||
break ;
|
||||
|
||||
case IRCAM_PCM_32 :
|
||||
psf->bytewidth = 4 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_32 ;
|
||||
break ;
|
||||
|
||||
case IRCAM_FLOAT :
|
||||
psf->bytewidth = 4 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT ;
|
||||
break ;
|
||||
|
||||
case IRCAM_ALAW :
|
||||
psf->bytewidth = 1 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ALAW ;
|
||||
break ;
|
||||
|
||||
case IRCAM_ULAW :
|
||||
psf->bytewidth = 1 ;
|
||||
psf->blockwidth = psf->sf.channels * psf->bytewidth ;
|
||||
psf->blockwidth = (sf_count_t) psf->sf.channels * psf->bytewidth ;
|
||||
|
||||
psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ULAW ;
|
||||
break ;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ mat4_open (SF_PRIVATE *psf)
|
|||
|
||||
psf->container_close = mat4_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
switch (subformat)
|
||||
{ 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) ;
|
||||
}
|
||||
else if ((psf->filelength - psf->dataoffset) > psf->sf.channels * psf->sf.frames * psf->bytewidth)
|
||||
psf->dataend = psf->dataoffset + rows * cols * psf->bytewidth ;
|
||||
psf->dataend = psf->dataoffset + (sf_count_t) rows * (sf_count_t) cols * psf->bytewidth ;
|
||||
|
||||
psf->datalength = psf->filelength - psf->dataoffset - psf->dataend ;
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ mat5_open (SF_PRIVATE *psf)
|
|||
|
||||
psf->container_close = mat5_close ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
switch (subformat)
|
||||
{ case SF_FORMAT_PCM_U8 :
|
||||
|
|
|
|||
|
|
@ -48,36 +48,36 @@
|
|||
/* Variable names from ITU G.726 spec */
|
||||
struct nms_adpcm_state
|
||||
{ /* Log of the step size multiplier. Operated on by codewords. */
|
||||
int yl ;
|
||||
short yl ;
|
||||
|
||||
/* Quantizer step size multiplier. Generated from yl. */
|
||||
int y ;
|
||||
short y ;
|
||||
|
||||
/* Coefficents of the pole predictor */
|
||||
int a [2] ;
|
||||
/* Coefficients of the pole predictor */
|
||||
short a [2] ;
|
||||
|
||||
/* Coefficents of the zero predictor */
|
||||
int b [6] ;
|
||||
/* Coefficients of the zero predictor */
|
||||
short b [6] ;
|
||||
|
||||
/* Previous quantized deltas (multiplied by 2^14) */
|
||||
int d_q [7] ;
|
||||
short d_q [7] ;
|
||||
|
||||
/* d_q [x] + s_ez [x], used by the pole-predictor for signs only. */
|
||||
int p [3] ;
|
||||
short p [3] ;
|
||||
|
||||
/* Previous reconstructed signal values. */
|
||||
int s_r [2] ;
|
||||
short s_r [2] ;
|
||||
|
||||
/* Zero predictor components of the signal estimate. */
|
||||
int s_ez ;
|
||||
short s_ez ;
|
||||
|
||||
/* Signal estimate, (including s_ez). */
|
||||
int s_e ;
|
||||
short s_e ;
|
||||
|
||||
/* The most recent codeword (enc:generated, dec:inputted) */
|
||||
int Ik ;
|
||||
char Ik ;
|
||||
|
||||
int parity ;
|
||||
char parity ;
|
||||
|
||||
/*
|
||||
** Offset into code tables for the bitrate.
|
||||
|
|
@ -109,7 +109,7 @@ typedef struct
|
|||
} NMS_ADPCM_PRIVATE ;
|
||||
|
||||
/* Pre-computed exponential interval used in the antilog approximation. */
|
||||
static unsigned int table_expn [] =
|
||||
static unsigned short table_expn [] =
|
||||
{ 0x4000, 0x4167, 0x42d5, 0x444c, 0x45cb, 0x4752, 0x48e2, 0x4a7a,
|
||||
0x4c1b, 0x4dc7, 0x4f7a, 0x5138, 0x52ff, 0x54d1, 0x56ac, 0x5892,
|
||||
0x5a82, 0x5c7e, 0x5e84, 0x6096, 0x62b4, 0x64dd, 0x6712, 0x6954,
|
||||
|
|
@ -117,21 +117,21 @@ static unsigned int table_expn [] =
|
|||
} ;
|
||||
|
||||
/* Table mapping codewords to scale factor deltas. */
|
||||
static int table_scale_factor_step [] =
|
||||
static short table_scale_factor_step [] =
|
||||
{ 0x0, 0x0, 0x0, 0x0, 0x4b0, 0x0, 0x0, 0x0, /* 2-bit */
|
||||
-0x3c, 0x0, 0x90, 0x0, 0x2ee, 0x0, 0x898, 0x0, /* 3-bit */
|
||||
-0x30, 0x12, 0x6b, 0xc8, 0x188, 0x2e0, 0x551, 0x1150, /* 4-bit */
|
||||
} ;
|
||||
|
||||
/* Table mapping codewords to quantized delta interval steps. */
|
||||
static unsigned int table_step [] =
|
||||
static unsigned short table_step [] =
|
||||
{ 0x73F, 0, 0, 0, 0x1829, 0, 0, 0, /* 2-bit */
|
||||
0x3EB, 0, 0xC18, 0, 0x1581, 0, 0x226E, 0, /* 3-bit */
|
||||
0x20C, 0x635, 0xA83, 0xF12, 0x1418, 0x19E3, 0x211A, 0x2BBA, /* 4-bit */
|
||||
} ;
|
||||
|
||||
/* Binary search lookup table for quantizing using table_step. */
|
||||
static int table_step_search [] =
|
||||
static short table_step_search [] =
|
||||
{ 0, 0x1F6D, 0, -0x1F6D, 0, 0, 0, 0, /* 2-bit */
|
||||
0x1008, 0x1192, 0, -0x219A, 0x1656, -0x1656, 0, 0, /* 3-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
|
||||
** approximately ret = b^exp where b = e^(ln(1024)/ln(20480)) ~= 1.0003385
|
||||
*/
|
||||
static inline int
|
||||
nms_adpcm_antilog (int exp)
|
||||
{ int ret ;
|
||||
static inline short
|
||||
nms_adpcm_antilog (short exp)
|
||||
{ int_fast32_t r ;
|
||||
|
||||
ret = 0x1000 ;
|
||||
ret += (((exp & 0x3f) * 0x166b) >> 12) ;
|
||||
ret *= table_expn [(exp & 0x7c0) >> 6] ;
|
||||
ret >>= (26 - (exp >> 11)) ;
|
||||
r = 0x1000 ;
|
||||
r += (((int_fast32_t) (exp & 0x3f) * 0x166b) >> 12) ;
|
||||
r *= table_expn [(exp & 0x7c0) >> 6] ;
|
||||
r >>= (26 - (exp >> 11)) ;
|
||||
|
||||
return ret ;
|
||||
return (short) r ;
|
||||
} /* nms_adpcm_antilog */
|
||||
|
||||
static void
|
||||
nms_adpcm_update (struct nms_adpcm_state *s)
|
||||
{ /* Variable names from ITU G.726 spec */
|
||||
int a1ul ;
|
||||
int fa1 ;
|
||||
short a1ul, fa1 ;
|
||||
int_fast32_t se ;
|
||||
int i ;
|
||||
|
||||
/* 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->y = nms_adpcm_antilog (s->yl) ;
|
||||
|
||||
/* Update the zero predictor coefficents. */
|
||||
/* Update the zero predictor coefficients. */
|
||||
for (i = 0 ; i < 6 ; i++)
|
||||
{ s->b [i] = (s->b [i] * 0xff) >> 8 ;
|
||||
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 ;
|
||||
}
|
||||
|
||||
/* Update the pole predictor coefficents. */
|
||||
/* Update the pole predictor coefficients. */
|
||||
fa1 = s->a [0] >> 5 ;
|
||||
if (fa1 < -256)
|
||||
fa1 = -256 ;
|
||||
else if (fa1 > 256)
|
||||
fa1 = 256 ;
|
||||
|
||||
s->a [0] = (0xff * s->a [0]) >> 8 ;
|
||||
s->a [0] = (s->a [0] * 0xff) >> 8 ;
|
||||
if (s->p [0] != 0 && s->p [1] != 0 && ((s->p [0] ^ s->p [1]) < 0))
|
||||
s->a [0] -= 192 ;
|
||||
else
|
||||
|
|
@ -230,7 +230,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
fa1 = -fa1 ;
|
||||
}
|
||||
|
||||
s->a [1] = fa1 + ((0xfe * s->a [1]) >> 8) ;
|
||||
s->a [1] = fa1 + ((s->a [1] * 0xfe) >> 8) ;
|
||||
if (s->p [0] != 0 && s->p [2] != 0 && ((s->p [0] ^ s->p [2]) < 0))
|
||||
s->a [1] -= 128 ;
|
||||
else
|
||||
|
|
@ -250,19 +250,18 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
s->a [0] = a1ul ;
|
||||
} ;
|
||||
|
||||
/* Compute the zero predictor estimate. Rotate past deltas too. */
|
||||
s->s_ez = 0 ;
|
||||
/* Compute the zero predictor estimate and rotate past deltas. */
|
||||
se = 0 ;
|
||||
for (i = 5 ; i >= 0 ; i--)
|
||||
{ s->s_ez += s->d_q [i] * s->b [i] ;
|
||||
{ se += (int_fast32_t) s->d_q [i] * s->b [i] ;
|
||||
s->d_q [i + 1] = s->d_q [i] ;
|
||||
} ;
|
||||
s->s_ez = se >> 14 ;
|
||||
|
||||
/* Compute the signal estimate. */
|
||||
s->s_e = s->a [0] * s->s_r [0] + s->a [1] * s->s_r [1] + s->s_ez ;
|
||||
|
||||
/* Return to scale */
|
||||
s->s_ez >>= 14 ;
|
||||
s->s_e >>= 14 ;
|
||||
/* Complete the signal estimate. */
|
||||
se += (int_fast32_t) s->a [0] * s->s_r [0] ;
|
||||
se += (int_fast32_t) s->a [1] * s->s_r [1] ;
|
||||
s->s_e = se >> 14 ;
|
||||
|
||||
/* Rotate members to prepare for next iteration. */
|
||||
s->s_r [1] = s->s_r [0] ;
|
||||
|
|
@ -274,7 +273,7 @@ nms_adpcm_update (struct nms_adpcm_state *s)
|
|||
static int16_t
|
||||
nms_adpcm_reconstruct_sample (struct nms_adpcm_state *s, uint8_t I)
|
||||
{ /* Variable names from ITU G.726 spec */
|
||||
int dqx ;
|
||||
int_fast32_t dqx ;
|
||||
|
||||
/*
|
||||
** The ordering of the 12-bit right-shift is a precision loss. It agrees
|
||||
|
|
@ -308,17 +307,17 @@ nms_adpcm_codec_init (struct nms_adpcm_state *s, enum nms_enc_type type)
|
|||
/*
|
||||
** 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.
|
||||
*/
|
||||
static uint8_t
|
||||
nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl)
|
||||
{ /* Variable names from ITU G.726 spec */
|
||||
int d ;
|
||||
int_fast32_t d ;
|
||||
uint8_t I ;
|
||||
|
||||
/* Down scale the sample from 16 => ~14 bits. */
|
||||
sl = (sl * 0x1fdf) / 0x7fff ;
|
||||
sl = ((int_fast32_t) sl * 0x1fdf) / 0x7fff ;
|
||||
|
||||
/* Compute estimate, and delta from actual value */
|
||||
nms_adpcm_update (s) ;
|
||||
|
|
@ -407,7 +406,7 @@ nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl)
|
|||
*/
|
||||
static int16_t
|
||||
nms_adpcm_decode_sample (struct nms_adpcm_state *s, uint8_t I)
|
||||
{ int sl ;
|
||||
{ int_fast32_t sl ;
|
||||
|
||||
nms_adpcm_update (s) ;
|
||||
sl = nms_adpcm_reconstruct_sample (s, I) ;
|
||||
|
|
@ -1091,7 +1090,7 @@ nms_adpcm_init (SF_PRIVATE *psf)
|
|||
else
|
||||
pnms->blocks_total = psf->datalength / (pnms->shortsperblock * sizeof (short)) ;
|
||||
|
||||
psf->sf.frames = pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ;
|
||||
psf->sf.frames = (sf_count_t) pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ;
|
||||
psf->codec_close = nms_adpcm_close ;
|
||||
psf->seek = nms_adpcm_seek ;
|
||||
|
||||
|
|
|
|||
|
|
@ -211,12 +211,16 @@ ogg_read_first_page (SF_PRIVATE *psf, OGG_PRIVATE *odata)
|
|||
|
||||
int
|
||||
ogg_write_page (SF_PRIVATE *psf, ogg_page *page)
|
||||
{ int bytes ;
|
||||
{ int n ;
|
||||
|
||||
bytes = psf_fwrite (page->header, 1, page->header_len, psf) ;
|
||||
bytes += psf_fwrite (page->body, 1, page->body_len, psf) ;
|
||||
n = psf_fwrite (page->header, 1, page->header_len, psf) ;
|
||||
if (n == page->header_len)
|
||||
n += psf_fwrite (page->body, 1, page->body_len, psf) ;
|
||||
|
||||
return bytes == page->header_len + page->body_len ;
|
||||
if (n != page->body_len + page->header_len)
|
||||
return -1 ;
|
||||
|
||||
return n ;
|
||||
} /* ogg_write_page */
|
||||
|
||||
sf_count_t
|
||||
|
|
@ -383,7 +387,7 @@ ogg_stream_unpack_page (SF_PRIVATE *psf, OGG_PRIVATE *odata)
|
|||
/*
|
||||
** 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
|
||||
** guarenteed to remain valid in memory until a new page is read into the
|
||||
** guaranteed to remain valid in memory until a new page is read into the
|
||||
** stream.
|
||||
*/
|
||||
for (i = 1 ; ; i++)
|
||||
|
|
@ -819,7 +823,7 @@ ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE* odata)
|
|||
break ;
|
||||
} ;
|
||||
|
||||
psf_log_printf (psf, "This Ogg bitstream contains some uknown data type.\n") ;
|
||||
psf_log_printf (psf, "This Ogg bitstream contains some unknown data type.\n") ;
|
||||
return SFE_UNIMPLEMENTED ;
|
||||
} /* ogg_stream_classify */
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
** Preforms a bisection search. If not found exactly, the best result is
|
||||
** Performs a bisection search. If not found exactly, the best result is
|
||||
** 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
|
||||
** lowest granule positions of the file. begin and end are the file offset
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
** - Samples shall refer to discrete PCM values, regardless of any channel
|
||||
** considerations. This is the same as what libsndfile calls samples.
|
||||
** - Samples/channel shall refer to groups of samples, one for each channel.
|
||||
** This is what Opus calles samples, and what libsndfile calles frames. It
|
||||
** This is what Opus calls samples, and what libsndfile calls frames. It
|
||||
** has the advantage that its name is also the formula to calculate it.
|
||||
**
|
||||
**
|
||||
|
|
@ -827,15 +827,16 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||
|
||||
/* The first page MUST only contain the header, so flush it out now */
|
||||
ogg_stream_packetin (&odata->ostream, &op) ;
|
||||
for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
|
||||
{ if (! (nn = ogg_write_page (psf, &odata->opage)))
|
||||
while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
{ nn = ogg_write_page (psf, &odata->opage) ;
|
||||
if (nn < 0)
|
||||
{ psf_log_printf (psf, "Opus : Failed to write header!\n") ;
|
||||
if (psf->error)
|
||||
return psf->error ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
psf->dataoffset += nn ;
|
||||
}
|
||||
} ;
|
||||
|
||||
/*
|
||||
** Metadata Tags (manditory)
|
||||
|
|
@ -850,15 +851,16 @@ 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)) ;
|
||||
op.packetno = 2 ;
|
||||
ogg_stream_packetin (&odata->ostream, &op) ;
|
||||
for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; )
|
||||
{ if (! (nn = ogg_write_page (psf, &odata->opage)))
|
||||
while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
{ nn = ogg_write_page (psf, &odata->opage) ;
|
||||
if (nn < 0)
|
||||
{ psf_log_printf (psf, "Opus : Failed to write comments!\n") ;
|
||||
if (psf->error)
|
||||
return psf->error ;
|
||||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
psf->dataoffset += nn ;
|
||||
}
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* ogg_opus_write_header */
|
||||
|
|
@ -1132,7 +1134,8 @@ ogg_opus_write_out (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus)
|
|||
if (nbytes > 0)
|
||||
{ oopus->u.encode.last_segments -= ogg_page_segments (&odata->opage) ;
|
||||
oopus->pg_pos = oopus->pkt_pos ;
|
||||
ogg_write_page (psf, &odata->opage) ;
|
||||
if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
return -1 ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
|
|
@ -1448,7 +1451,7 @@ ogg_opus_analyze_file (SF_PRIVATE *psf)
|
|||
oopus->pkt_pos = oopus->pg_pos - gp ;
|
||||
}
|
||||
else if (gp < oopus->pg_pos)
|
||||
{ psf_log_printf (psf, "Opus : First data page is also the last, and granule position has an (ambigious) offset.\n") ;
|
||||
{ psf_log_printf (psf, "Opus : First data page is also the last, and granule position has an (ambiguous) offset.\n") ;
|
||||
return SFE_MALFORMED_FILE ;
|
||||
} ;
|
||||
oopus->u.decode.gp_start = oopus->pkt_pos ;
|
||||
|
|
@ -1511,7 +1514,7 @@ ogg_opus_null_read (SF_PRIVATE *psf, sf_count_t offset)
|
|||
return total ;
|
||||
/*
|
||||
** Ignore pre-skip skipping. The preskip was accounted for in the
|
||||
** arugment to offset, so we need to count it.
|
||||
** argument to offset, so we need to count it.
|
||||
*/
|
||||
oopus->loc = 0 ;
|
||||
} ;
|
||||
|
|
@ -1609,7 +1612,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
|
||||
* current buffer, to avoid backwards seeking if the target is on the page
|
||||
* but before the current locaiton. */
|
||||
* but before the current location. */
|
||||
oopus->loc = 0 ;
|
||||
current_gp = oopus->pkt_pos - (uint64_t) (oopus->len * oopus->sr_factor) ;
|
||||
|
||||
|
|
@ -1644,7 +1647,7 @@ ogg_opus_seek (SF_PRIVATE *psf, int mode, sf_count_t offset)
|
|||
if (ret < 0)
|
||||
{ /*
|
||||
** Page seek failed, what to do? Could be bad data. We can
|
||||
** either fall-back to manual seeking or bail. Manaul seeking
|
||||
** either fall-back to manual seeking or bail. Manual seeking
|
||||
** from the beginning has the advantage of finding where the
|
||||
** file goes bad.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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
|
||||
** integers, (vender string length, tags count.)
|
||||
** integers, (vendor string length, tags count.)
|
||||
*/
|
||||
if (packet->bytes < (ident ? ident->length : 0) + 4 + 4)
|
||||
return SFE_MALFORMED_FILE ;
|
||||
|
|
|
|||
|
|
@ -82,28 +82,6 @@
|
|||
/* How many seconds in the future to not bother bisection searching for. */
|
||||
#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
|
||||
{ int id ;
|
||||
const char *name ;
|
||||
|
|
@ -145,6 +123,45 @@ typedef struct
|
|||
sf_count_t last_page ;
|
||||
} 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
|
||||
vorbis_read_header (SF_PRIVATE *psf)
|
||||
{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
|
|
@ -380,7 +397,6 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||
{ ogg_packet header ;
|
||||
ogg_packet header_comm ;
|
||||
ogg_packet header_code ;
|
||||
int result ;
|
||||
|
||||
vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ;
|
||||
ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */
|
||||
|
|
@ -390,9 +406,9 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||
/* This ensures the actual
|
||||
* audio data will start on a new page, as per spec
|
||||
*/
|
||||
while ((result = ogg_stream_flush (&odata->ostream, &odata->opage)) != 0)
|
||||
{ ogg_write_page (psf, &odata->opage) ;
|
||||
} ;
|
||||
while (ogg_stream_flush (&odata->ostream, &odata->opage))
|
||||
if (ogg_write_page (psf, &odata->opage) < 0)
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
|
|
@ -402,44 +418,25 @@ static int
|
|||
vorbis_close (SF_PRIVATE *psf)
|
||||
{ OGG_PRIVATE* odata = psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = psf->codec_data ;
|
||||
int ret = 0 ;
|
||||
|
||||
if (odata == NULL || vdata == NULL)
|
||||
return 0 ;
|
||||
|
||||
/* Clean up this logical bitstream ; before exit we shuld see if we're
|
||||
/* Clean up this logical bitstream ; before exit we should see if we're
|
||||
** followed by another [chained]. */
|
||||
|
||||
if (psf->file.mode == SFM_WRITE)
|
||||
{
|
||||
if (psf->write_current <= 0)
|
||||
vorbis_write_header (psf, 0) ;
|
||||
ret = vorbis_write_header (psf, 0) ;
|
||||
|
||||
vorbis_analysis_wrote (&vdata->vdsp, 0) ;
|
||||
while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
|
||||
{
|
||||
|
||||
/* 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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret == 0)
|
||||
{ /* A write of zero samples tells Vorbis the stream is done and to
|
||||
flush. */
|
||||
ret = vorbis_write_samples (psf, odata, vdata, 0) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
/* ogg_page and ogg_packet structs always point to storage in
|
||||
libvorbis. They are never freed or manipulated directly */
|
||||
|
|
@ -449,7 +446,7 @@ vorbis_close (SF_PRIVATE *psf)
|
|||
vorbis_comment_clear (&vdata->vcomment) ;
|
||||
vorbis_info_clear (&vdata->vinfo) ;
|
||||
|
||||
return 0 ;
|
||||
return ret ;
|
||||
} /* vorbis_close */
|
||||
|
||||
int
|
||||
|
|
@ -688,33 +685,40 @@ vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens)
|
|||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
static int
|
||||
vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames)
|
||||
{
|
||||
vorbis_analysis_wrote (&vdata->vdsp, in_frames) ;
|
||||
{ int ret ;
|
||||
|
||||
if ((ret = vorbis_analysis_wrote (&vdata->vdsp, in_frames)) != 0)
|
||||
return ret ;
|
||||
|
||||
/*
|
||||
** Vorbis does some data preanalysis, then divvies up blocks for
|
||||
** more involved (potentially parallel) processing. Get a single
|
||||
** block for encoding now.
|
||||
*/
|
||||
while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1)
|
||||
while ((ret = vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock)) == 1)
|
||||
{
|
||||
/* analysis, assume we want to use bitrate management */
|
||||
vorbis_analysis (&vdata->vblock, NULL) ;
|
||||
vorbis_bitrate_addblock (&vdata->vblock) ;
|
||||
if ((ret = vorbis_analysis (&vdata->vblock, NULL)) != 0)
|
||||
return ret ;
|
||||
if ((ret = vorbis_bitrate_addblock (&vdata->vblock)) != 0)
|
||||
return ret ;
|
||||
|
||||
while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket))
|
||||
while ((ret = vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) == 1)
|
||||
{
|
||||
/* weld the packet into the bitstream */
|
||||
ogg_stream_packetin (&odata->ostream, &odata->opacket) ;
|
||||
if ((ret = ogg_stream_packetin (&odata->ostream, &odata->opacket)) != 0)
|
||||
return ret ;
|
||||
|
||||
/* write out pages (if any) */
|
||||
while (!odata->eos)
|
||||
{ int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
if (result == 0)
|
||||
{ ret = ogg_stream_pageout (&odata->ostream, &odata->opage) ;
|
||||
if (ret == 0)
|
||||
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
|
||||
** it here (to show that vorbis does know where the stream ends) */
|
||||
|
|
@ -722,16 +726,22 @@ vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata
|
|||
odata->eos = 1 ;
|
||||
} ;
|
||||
} ;
|
||||
if (ret != 0)
|
||||
return ret ;
|
||||
} ;
|
||||
if (ret != 0)
|
||||
return ret ;
|
||||
|
||||
vdata->gp += in_frames ;
|
||||
|
||||
return 0 ;
|
||||
} /* vorbis_write_data */
|
||||
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
|
||||
{
|
||||
int i, m, j = 0 ;
|
||||
int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -740,14 +750,17 @@ vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) (ptr [j++]) / 32767.0f ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)))
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_s */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
|
||||
{ int i, m, j = 0 ;
|
||||
{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -756,14 +769,17 @@ vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)))
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_i */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
|
||||
{ int i, m, j = 0 ;
|
||||
{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -772,14 +788,17 @@ vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = ptr [j++] ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0)
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_f */
|
||||
|
||||
static sf_count_t
|
||||
vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
|
||||
{ int i, m, j = 0 ;
|
||||
{ int i, m, j = 0, ret ;
|
||||
OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
|
||||
VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
|
||||
int in_frames = lens / psf->sf.channels ;
|
||||
|
|
@ -788,7 +807,10 @@ vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
|
|||
for (m = 0 ; m < psf->sf.channels ; m++)
|
||||
buffer [m][i] = (float) ptr [j++] ;
|
||||
|
||||
vorbis_write_samples (psf, odata, vdata, in_frames) ;
|
||||
if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0)
|
||||
{ vorbis_log_error (psf, ret) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
return lens ;
|
||||
} /* vorbis_write_d */
|
||||
|
|
@ -884,7 +906,7 @@ vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp)
|
|||
return 0 ;
|
||||
|
||||
/* Search for a position a half large-block before our target. As Vorbis is
|
||||
** lapped, every sample position come from two blocks, the "left" half of
|
||||
** lapped, every sample position comes from two blocks, the "left" half of
|
||||
** 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
|
||||
** last finished sample in the stream that can be decoded from a page. A
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ paf24_init (SF_PRIVATE *psf)
|
|||
(PAF24_BLOCK_SIZE + PAF24_SAMPLES_PER_BLOCK * sizeof (int)) ;
|
||||
|
||||
/*
|
||||
** Not exatly sure why this needs to be here but the tests
|
||||
** Not exactly sure why this needs to be here but the tests
|
||||
** fail without it.
|
||||
*/
|
||||
psf->last_op = 0 ;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ pcm_init (SF_PRIVATE *psf)
|
|||
return SFE_INTERNAL ;
|
||||
} ;
|
||||
|
||||
psf->blockwidth = psf->bytewidth * psf->sf.channels ;
|
||||
psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
|
||||
|
||||
if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8)
|
||||
chars = SF_CHARS_SIGNED ;
|
||||
|
|
@ -1782,20 +1782,20 @@ static void
|
|||
f2sc_clip_array (const float *src, signed char *dest, int count, int normalize)
|
||||
{ float normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 127 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = -128 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = psf_lrintf (scaled_value) >> 24 ;
|
||||
dest [i] = psf_lrintf (scaled_value) ;
|
||||
} ;
|
||||
} /* f2sc_clip_array */
|
||||
|
||||
|
|
@ -1841,20 +1841,20 @@ static void
|
|||
f2uc_clip_array (const float *src, unsigned char *dest, int count, int normalize)
|
||||
{ float normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 0xFF ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = 0 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = (psf_lrintf (scaled_value) >> 24) + 128 ;
|
||||
dest [i] = psf_lrintf (scaled_value) + 128 ;
|
||||
} ;
|
||||
} /* f2uc_clip_array */
|
||||
|
||||
|
|
@ -1907,25 +1907,25 @@ f2bes_clip_array (const float *src, short *dest, int count, int normalize)
|
|||
float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [1] = 0xFF ;
|
||||
ucptr [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [1] = 0x00 ;
|
||||
ucptr [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [1] = value >> 16 ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
ucptr [1] = value ;
|
||||
ucptr [0] = value >> 8 ;
|
||||
} ;
|
||||
} /* f2bes_clip_array */
|
||||
|
||||
|
|
@ -1978,25 +1978,25 @@ f2les_clip_array (const float *src, short *dest, int count, int normalize)
|
|||
float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [0] = value >> 16 ;
|
||||
ucptr [1] = value >> 24 ;
|
||||
ucptr [0] = value ;
|
||||
ucptr [1] = value >> 8 ;
|
||||
} ;
|
||||
} /* f2les_clip_array */
|
||||
|
||||
|
|
@ -2047,31 +2047,27 @@ f2let_clip_array (const float *src, tribyte *dest, int count, int normalize)
|
|||
{ float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [0] = 0xFF ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [2] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [0] = 0x00 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [2] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
dest [i].bytes [0] = value >> 8 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [2] = value >> 24 ;
|
||||
dest [i].bytes [0] = value ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [2] = value >> 16 ;
|
||||
} ;
|
||||
} /* f2let_clip_array */
|
||||
|
||||
|
|
@ -2122,31 +2118,27 @@ f2bet_clip_array (const float *src, tribyte *dest, int count, int normalize)
|
|||
{ float normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [0] = 0x7F ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [2] = 0xFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [0] = 0x80 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [2] = 0x00 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
dest [i].bytes [0] = value >> 24 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [2] = value >> 8 ;
|
||||
dest [i].bytes [0] = value >> 16 ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [2] = value ;
|
||||
} ;
|
||||
} /* f2bet_clip_array */
|
||||
|
||||
|
|
@ -2206,7 +2198,6 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= 1.0 * 0x7FFFFFFF)
|
||||
{ ucptr [0] = 0x7F ;
|
||||
ucptr [1] = 0xFF ;
|
||||
|
|
@ -2214,8 +2205,6 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0xFF ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [0] = 0x80 ;
|
||||
ucptr [1] = 0x00 ;
|
||||
|
|
@ -2223,7 +2212,6 @@ f2bei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x00 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
|
|
@ -2289,7 +2277,6 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0xFF ;
|
||||
|
|
@ -2297,8 +2284,6 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x00 ;
|
||||
|
|
@ -2306,7 +2291,6 @@ f2lei_clip_array (const float *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrintf (scaled_value) ;
|
||||
ucptr [0] = value ;
|
||||
|
|
@ -2358,20 +2342,20 @@ static void
|
|||
d2sc_clip_array (const double *src, signed char *dest, int count, int normalize)
|
||||
{ double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 127 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = -128 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = psf_lrintf (scaled_value) >> 24 ;
|
||||
dest [i] = psf_lrintf (scaled_value) ;
|
||||
} ;
|
||||
} /* d2sc_clip_array */
|
||||
|
||||
|
|
@ -2417,20 +2401,20 @@ static void
|
|||
d2uc_clip_array (const double *src, unsigned char *dest, int count, int normalize)
|
||||
{ double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;
|
||||
normfact = normalize ? (8.0 * 0x10) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7F))
|
||||
{ dest [i] = 255 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x10))
|
||||
{ dest [i] = 0 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
dest [i] = (psf_lrint (src [i] * normfact) >> 24) + 128 ;
|
||||
dest [i] = psf_lrint (src [i] * normfact) + 128 ;
|
||||
} ;
|
||||
} /* d2uc_clip_array */
|
||||
|
||||
|
|
@ -2483,25 +2467,25 @@ d2bes_clip_array (const double *src, short *dest, int count, int normalize)
|
|||
double normfact, scaled_value ;
|
||||
int value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [1] = 0xFF ;
|
||||
ucptr [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [1] = 0x00 ;
|
||||
ucptr [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [1] = value >> 16 ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
ucptr [1] = value ;
|
||||
ucptr [0] = value >> 8 ;
|
||||
} ;
|
||||
} /* d2bes_clip_array */
|
||||
|
||||
|
|
@ -2554,25 +2538,25 @@ d2les_clip_array (const double *src, short *dest, int count, int normalize)
|
|||
int value ;
|
||||
double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;
|
||||
normfact = normalize ? (8.0 * 0x1000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x1000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [0] = value >> 16 ;
|
||||
ucptr [1] = value >> 24 ;
|
||||
ucptr [0] = value ;
|
||||
ucptr [1] = value >> 8 ;
|
||||
} ;
|
||||
} /* d2les_clip_array */
|
||||
|
||||
|
|
@ -2623,31 +2607,27 @@ d2let_clip_array (const double *src, tribyte *dest, int count, int normalize)
|
|||
{ int value ;
|
||||
double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [0] = 0xFF ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [2] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [0] = 0x00 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [2] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
dest [i].bytes [0] = value >> 8 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [2] = value >> 24 ;
|
||||
dest [i].bytes [0] = value ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [2] = value >> 16 ;
|
||||
} ;
|
||||
} /* d2let_clip_array */
|
||||
|
||||
|
|
@ -2698,31 +2678,27 @@ d2bet_clip_array (const double *src, tribyte *dest, int count, int normalize)
|
|||
{ int value ;
|
||||
double normfact, scaled_value ;
|
||||
|
||||
normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;
|
||||
normfact = normalize ? (8.0 * 0x100000) : 1.0 ;
|
||||
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{ scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
if (scaled_value >= (1.0 * 0x7FFFFF))
|
||||
{ dest [i].bytes [2] = 0xFF ;
|
||||
dest [i].bytes [1] = 0xFF ;
|
||||
dest [i].bytes [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
if (scaled_value <= (-8.0 * 0x100000))
|
||||
{ dest [i].bytes [2] = 0x00 ;
|
||||
dest [i].bytes [1] = 0x00 ;
|
||||
dest [i].bytes [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
dest [i].bytes [2] = value >> 8 ;
|
||||
dest [i].bytes [1] = value >> 16 ;
|
||||
dest [i].bytes [0] = value >> 24 ;
|
||||
dest [i].bytes [2] = value ;
|
||||
dest [i].bytes [1] = value >> 8 ;
|
||||
dest [i].bytes [0] = value >> 16 ;
|
||||
} ;
|
||||
} /* d2bet_clip_array */
|
||||
|
||||
|
|
@ -2782,7 +2758,6 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ ucptr [3] = 0xFF ;
|
||||
ucptr [2] = 0xFF ;
|
||||
|
|
@ -2790,8 +2765,6 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [0] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [3] = 0x00 ;
|
||||
ucptr [2] = 0x00 ;
|
||||
|
|
@ -2799,7 +2772,6 @@ d2bei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [0] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [0] = value >> 24 ;
|
||||
|
|
@ -2865,7 +2837,6 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
for (int i = 0 ; i < count ; i++)
|
||||
{ ucptr = (unsigned char*) &dest [i] ;
|
||||
scaled_value = src [i] * normfact ;
|
||||
#if CPU_CLIPS_POSITIVE == 0
|
||||
if (scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||
{ ucptr [0] = 0xFF ;
|
||||
ucptr [1] = 0xFF ;
|
||||
|
|
@ -2873,8 +2844,6 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x7F ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
#if CPU_CLIPS_NEGATIVE == 0
|
||||
if (scaled_value <= (-8.0 * 0x10000000))
|
||||
{ ucptr [0] = 0x00 ;
|
||||
ucptr [1] = 0x00 ;
|
||||
|
|
@ -2882,7 +2851,6 @@ d2lei_clip_array (const double *src, int *dest, int count, int normalize)
|
|||
ucptr [3] = 0x80 ;
|
||||
continue ;
|
||||
} ;
|
||||
#endif
|
||||
|
||||
value = psf_lrint (scaled_value) ;
|
||||
ucptr [0] = value ;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
|
|||
} ;
|
||||
} ;
|
||||
|
||||
if (psf->filelength != riff_size + 8)
|
||||
if (psf->filelength - 8 != riff_size)
|
||||
psf_log_printf (psf, " Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ;
|
||||
else
|
||||
psf_log_printf (psf, " Riff size : %D\n", riff_size) ;
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
|
|||
|
||||
ucptr = psds->read_data + 5 ;
|
||||
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) ;
|
||||
} ;
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
|
|||
|
||||
ucptr = psds->read_data + 5 ;
|
||||
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) ;
|
||||
} ;
|
||||
|
||||
|
|
@ -542,7 +542,7 @@ sds_4byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds)
|
|||
|
||||
ucptr = psds->read_data + 5 ;
|
||||
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) ;
|
||||
} ;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@
|
|||
#define HAVE_ALSA_ASOUNDLIB_H 0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SNDIO_H
|
||||
#define HAVE_SNDIO_H 0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BYTESWAP_H
|
||||
#define HAVE_BYTESWAP_H 0
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ SNDFILE*
|
|||
sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data)
|
||||
{ SF_PRIVATE *psf ;
|
||||
|
||||
/* Make sure we have a valid set ot virtual pointers. */
|
||||
/* Make sure we have a valid set of virtual pointers. */
|
||||
if (sfvirtual->get_filelen == NULL)
|
||||
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
||||
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
|
||||
** SF_INFO struct is valid.
|
||||
** Return 0 on failure, 1 ons success.
|
||||
** Return 0 on failure, 1 on success.
|
||||
*/
|
||||
|
||||
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) ;
|
||||
|
||||
/* Only files containg the following data types support the PEAK chunk. */
|
||||
/* Only files containing the following data types support the PEAK chunk. */
|
||||
if (format != SF_FORMAT_FLOAT && format != SF_FORMAT_DOUBLE)
|
||||
return SF_FALSE ;
|
||||
|
||||
|
|
@ -1522,7 +1522,7 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence)
|
|||
** used with SEEK_SET.
|
||||
*/
|
||||
switch (whence)
|
||||
{ /* The SEEK_SET behaviour is independant of mode. */
|
||||
{ /* The SEEK_SET behaviour is independent of mode. */
|
||||
case SEEK_SET :
|
||||
case SEEK_SET | SFM_READ :
|
||||
case SEEK_SET | SFM_WRITE :
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
BLOCK 8 - digitized sound attribute extension, must preceed block 1.
|
||||
BLOCK 8 - digitized sound attribute extension, must precede block 1.
|
||||
Used to define stereo, 8 bit audio
|
||||
BYTE bBlockID; // = 8
|
||||
BYTE nBlockLen[3]; // 3 byte length
|
||||
|
|
|
|||
|
|
@ -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
|
||||
** so high that it triggers undefined behaviour whan something is added to it.
|
||||
** so high that it triggers undefined behaviour when something is added to it.
|
||||
*/
|
||||
psf->filelength = SF_COUNT_MAX - 10000 ;
|
||||
psf->datalength = psf->filelength ;
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ wav_open (SF_PRIVATE *psf)
|
|||
} ;
|
||||
|
||||
#if (ENABLE_EXPERIMENTAL_CODE == 0)
|
||||
/* For now, don't support writing MPEGLAYER3 WAVs, as we can't guarentee that
|
||||
/* For now, don't support writing MPEGLAYER3 WAVs, as we can't guarantee that
|
||||
** such a file written by libsndfile would have the same length when opened again.
|
||||
*/
|
||||
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
|
||||
** 0x02 On: Root note is Set Off: No root
|
||||
** 0x04 On: Stretch is On, Off: Strech is OFF
|
||||
** 0x04 On: Stretch is On, Off: Stretch is OFF
|
||||
** 0x08 On: Disk Based Off: Ram based
|
||||
** 0x10 On: ?????????? Off: ????????? (Acidizer puts that ON)
|
||||
**
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static const struct chanmap_s
|
|||
{ int id ;
|
||||
const char * name ;
|
||||
} channel_mask_bits [] =
|
||||
{ /* WAVEFORMATEXTENSIBLE doesn't distuingish FRONT_LEFT from LEFT */
|
||||
{ /* WAVEFORMATEXTENSIBLE doesn't distinguish FRONT_LEFT from LEFT */
|
||||
{ SF_CHANNEL_MAP_LEFT, "L" },
|
||||
{ SF_CHANNEL_MAP_RIGHT, "R" },
|
||||
{ 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, "\n"
|
||||
" Ambiguous information in 'fmt ' chunk. Possibile file types:\n"
|
||||
" Ambiguous information in 'fmt ' chunk. Possible file types:\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"
|
||||
" 2) 24 bit file with incorrect Block Align value.\n"
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ main (void)
|
|||
|
||||
|
||||
/*=================================================================================
|
||||
** The following routines came from the sox-12.15 (Sound eXcahcnge) distribution.
|
||||
** The following routines came from the sox-12.15 (Sound eXchange) distribution.
|
||||
**
|
||||
** This code is not compiled into libsndfile. It is only used to test the
|
||||
** libsndfile lookup tables for correctness.
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
#endif
|
||||
|
||||
/*
|
||||
** Neat solution to the Win32/OS2 binary file flage requirement.
|
||||
** Neat solution to the Win32/OS2 binary file flag requirement.
|
||||
** If O_BINARY isn't already defined by the inclusion of the system
|
||||
** headers, set it to zero.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -714,7 +714,7 @@ instrumet_rw_test (const char *filename)
|
|||
{ inst.basenote = 22 ;
|
||||
|
||||
if (sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
|
||||
printf ("Sucess: [%s] updated\n", filename) ;
|
||||
printf ("Success: [%s] updated\n", filename) ;
|
||||
else
|
||||
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 ;
|
||||
|
||||
if (sf_command (sndfile, SFC_SET_CUE, &cues, sizeof (cues)) == SF_TRUE)
|
||||
printf ("Sucess: [%s] updated\n", filename) ;
|
||||
printf ("Success: [%s] updated\n", filename) ;
|
||||
else
|
||||
printf ("Error: SFC_SET_CUE on [%s] [%s]\n", filename, sf_strerror (sndfile)) ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ compression_size_test (int format, const char * filename)
|
|||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ int all_tests = 0, tests = 0 ;
|
||||
{ int all_tests = 0 ;
|
||||
|
||||
if (argc != 2)
|
||||
{ printf (
|
||||
|
|
@ -197,7 +197,6 @@ main (int argc, char *argv [])
|
|||
{ if (HAVE_EXTERNAL_XIPH_LIBS)
|
||||
{ vorbis_test () ;
|
||||
compression_size_test (SF_FORMAT_OGG | SF_FORMAT_VORBIS, "vorbis.oga") ;
|
||||
tests ++ ;
|
||||
}
|
||||
else
|
||||
puts (" No Ogg Vorbis tests because support was not compiled in.") ;
|
||||
|
|
@ -206,7 +205,6 @@ main (int argc, char *argv [])
|
|||
if (all_tests || strcmp (argv [1], "flac") == 0)
|
||||
{ if (HAVE_EXTERNAL_XIPH_LIBS)
|
||||
{ compression_size_test (SF_FORMAT_FLAC | SF_FORMAT_PCM_16, "pcm16.flac") ;
|
||||
tests ++ ;
|
||||
}
|
||||
else
|
||||
puts (" No FLAC tests because support was not compiled in.") ;
|
||||
|
|
@ -215,7 +213,6 @@ main (int argc, char *argv [])
|
|||
if (all_tests || strcmp (argv [1], "opus") == 0)
|
||||
{ if (HAVE_EXTERNAL_XIPH_LIBS)
|
||||
{ compression_size_test (SF_FORMAT_OGG | SF_FORMAT_OPUS, "opus.opus") ;
|
||||
tests ++ ;
|
||||
}
|
||||
else
|
||||
puts (" No Opus tests because support was not compiled in.") ;
|
||||
|
|
@ -224,7 +221,6 @@ main (int argc, char *argv [])
|
|||
if (all_tests || strcmp (argv [1], "mpeg") == 0)
|
||||
{ if (HAVE_MPEG)
|
||||
{ compression_size_test (SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III, "mpeg.mp3") ;
|
||||
tests ++ ;
|
||||
}
|
||||
else
|
||||
puts (" No MPEG tests because support was not compiled in.") ;
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ filesystem_full_test (int format)
|
|||
sfinfo.frames = 0 ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL)
|
||||
{ printf ("\n\nLine %d : Error, file should not have openned.\n", __LINE__ - 1) ;
|
||||
{ printf ("\n\nLine %d : Error, file should not have opened.\n", __LINE__ - 1) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ static int verbose = SF_FALSE ;
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{ int do_all = 0 ;
|
||||
int test_count = 0 ;
|
||||
|
||||
if (argc == 3 && strcmp (argv [2], "-v") == 0)
|
||||
{ verbose = SF_TRUE ;
|
||||
|
|
@ -107,17 +106,14 @@ main (int argc, char **argv)
|
|||
|
||||
if (do_all || ! strcmp (argv [1], "wav"))
|
||||
{ multi_file_test ("multi_wav.dat", wav_formats, ARRAY_LEN (wav_formats)) ;
|
||||
test_count++ ;
|
||||
} ;
|
||||
|
||||
if (do_all || ! strcmp (argv [1], "aiff"))
|
||||
{ multi_file_test ("multi_aiff.dat", aiff_formats, ARRAY_LEN (aiff_formats)) ;
|
||||
test_count++ ;
|
||||
} ;
|
||||
|
||||
if (do_all || ! strcmp (argv [1], "au"))
|
||||
{ multi_file_test ("multi_au.dat", au_formats, ARRAY_LEN (au_formats)) ;
|
||||
test_count++ ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
|
|
@ -235,4 +231,3 @@ write_file_at_end (int fd, int filetype, int channels, int file_num)
|
|||
|
||||
sf_close (sndfile) ;
|
||||
} /* write_file_at_end */
|
||||
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ read_write_peak_test (const char *filename, int filetype)
|
|||
|
||||
sf_close (file) ;
|
||||
|
||||
/* Open the fiel RDWR, write sample valied 1.25. */
|
||||
/* Open the file RDWR, write sample valid 1.25. */
|
||||
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ main (int argc, char *argv [])
|
|||
} ;
|
||||
|
||||
printf ("Total : %d\n", total) ;
|
||||
printf ("Maximun value : %d\n", max) ;
|
||||
printf ("Maximum value : %d\n", max) ;
|
||||
|
||||
sf_close (file) ;
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ main (void)
|
|||
|
||||
|
||||
/*=================================================================================
|
||||
** The following routines came from the sox-12.15 (Sound eXcahcnge) distribution.
|
||||
** The following routines came from the sox-12.15 (Sound eXchange) distribution.
|
||||
**
|
||||
** This code is not compiled into libsndfile. It is only used to test the
|
||||
** libsndfile lookup tables for correctness.
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ sf_count_t file_length_fd (int fd) ;
|
|||
#define LOG_BUFFER_SIZE 4096
|
||||
|
||||
/*
|
||||
** Neat solution to the Win32/OS2 binary file flage requirement.
|
||||
** Neat solution to the Win32/OS2 binary file flag requirement.
|
||||
** If O_BINARY isn't already defined by the inclusion of the system
|
||||
** headers, set it to zero.
|
||||
*/
|
||||
|
|
@ -426,8 +426,8 @@ check_log_buffer_or_die (SNDFILE *file, int line_num)
|
|||
} ;
|
||||
|
||||
/* Look for "Should" */
|
||||
if (strstr (buffer, "nknown marker"))
|
||||
{ printf ("\n\nLine %d : Log buffer contains `nknown marker'. Dumping.\n", line_num) ;
|
||||
if (strstr (buffer, "unknown marker"))
|
||||
{ printf ("\n\nLine %d : Log buffer contains `unknown marker'. Dumping.\n", line_num) ;
|
||||
puts (buffer) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ show_stat_fstat_error (void)
|
|||
|
||||
assert (write (fd, data, sizeof (data)) > 0) ;
|
||||
|
||||
printf ("1) Now call stat and fstat on the file and retreive the file lengths.\n") ;
|
||||
printf ("1) Now call stat and fstat on the file and retrieve the file lengths.\n") ;
|
||||
|
||||
if (stat (filename, &buf) != 0)
|
||||
{ printf ("\n\nLine %d: stat() failed : %s\n\n", __LINE__, strerror (errno)) ;
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int lo
|
|||
create_short_file (filename) ;
|
||||
|
||||
/* Opening a already existing short file (ie invalid header) RDWR is disallowed.
|
||||
** If this returns a valif pointer sf_open() screwed up.
|
||||
** If this returns a valid pointer sf_open() screwed up.
|
||||
*/
|
||||
if ((file = sf_open (filename, SFM_RDWR, &sfinfo)))
|
||||
{ printf ("\n\nLine %d: sf_open should (SFM_RDWR) have failed but didn't.\n", __LINE__) ;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue