[LIBMPG123]

- Update to version 1.23.0
CORE-13451

svn path=/trunk/; revision=75091
This commit is contained in:
Thomas Faber 2017-06-18 13:21:16 +00:00
parent eda316218d
commit bb12a351c7
33 changed files with 1304 additions and 604 deletions

View file

@ -1,10 +1,14 @@
/*
mpg123lib_intern: Common non-public stuff for libmpg123
abi_align: An attempt to avoid breakage because of mixing
compilers with different alignment.
copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 1995-2015 by the mpg123 project
free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
derived from the old mpg123.h
There used to be code that checks alignment, but it did not really
work anyway. The only straw we have is putting that alignment
attribute to API functions.
*/
#ifndef MPG123_H_ABI_ALIGN
@ -13,27 +17,25 @@
#include "config.h"
/* ABI conformance for other compilers.
mpg123 needs 16byte-aligned stack for SSE and friends.
mpg123 needs 16byte-aligned (or more) stack for SSE and friends.
gcc provides that, but others don't necessarily. */
#ifdef ABI_ALIGN_FUN
#ifndef attribute_align_arg
#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1)
# define attribute_align_arg __attribute__((force_align_arg_pointer))
/* The gcc that can align the stack does not need the check... nor does it work with gcc 4.3+, anyway. */
#else
# define attribute_align_arg
/* Other compilers get code to catch misaligned stack.
Well, except Sun Studio, which accepts the aligned attribute but does not honor it. */
#if !defined(__SUNPRO_C)
# define NEED_ALIGNCHECK
#endif
#endif
#endif
#else
#endif /* attribute_align_arg */
#else /* ABI_ALIGN_FUN */
#define attribute_align_arg
/* We won't try the align check... */
#endif
#endif
#endif /* ABI_ALIGN_FUN */
#endif /* MPG123_H_ABI_ALIGN */

View file

@ -15,7 +15,13 @@
#define MPG123_COMPAT_H
#include "config.h"
#include "intsym.h"
/* Needed for strdup(), in strict mode ... */
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#endif
#include <errno.h>
#ifdef HAVE_STDLIB_H
/* realloc, size_t */
@ -63,6 +69,9 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef OS2
#include <float.h>
@ -88,6 +97,10 @@
typedef unsigned char byte;
#ifdef _MSC_VER
typedef long ssize_t;
#endif
/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
void *safe_realloc(void *ptr, size_t size);
#ifndef HAVE_STRERROR
@ -133,6 +146,7 @@ typedef long ssize_p;
* @return file descriptor (>=0) or error code.
*/
int compat_open(const char *filename, int flags);
FILE* compat_fopen(const char *filename, const char *mode);
/**
* Closing a file handle can be platform specific.
@ -141,6 +155,7 @@ int compat_open(const char *filename, int flags);
* @return 0 if the file was successfully closed. A return value of -1 indicates an error.
*/
int compat_close(int infd);
int compat_fclose(FILE* stream);
/* Those do make sense in a separate file, but I chose to include them in compat.c because that's the one source whose object is shared between mpg123 and libmpg123 -- and both need the functionality internally. */
@ -173,6 +188,12 @@ int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen);
int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen);
#endif
/* Blocking write/read of data with signal resilience.
Both continue after being interrupted by signals and always return the
amount of processed data (shortage indicating actual problem or EOF). */
size_t unintr_write(int fd, void const *buffer, size_t bytes);
size_t unintr_read (int fd, void *buffer, size_t bytes);
/* That one comes from Tellie on OS/2, needed in resolver. */
#ifdef __KLIBC__
typedef int socklen_t;
@ -186,4 +207,8 @@ typedef int socklen_t;
#include "true.h"
#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
void (*catchsignal(int signum, void(*handler)()))();
#endif
#endif

View file

@ -8,6 +8,15 @@
/* Define to use proper rounding. */
/* #undef ACCURATE_ROUNDING */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* Define if .balign is present. */
#define ASMALIGN_BALIGN 1
/* Define if .align just takes byte count. */
/* #undef ASMALIGN_BYTE */
/* Define if .align takes 3 for alignment of 2^3=8 bytes instead of 8. */
/* #undef ASMALIGN_EXP */
@ -258,10 +267,12 @@
functions. */
#define LFS_ALIAS_BITS 32
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* The suffix for module files. */
#define MODULE_FILE_SUFFIX ".la"
/* Define if network support is enabled. */
#define NETWORK 1
@ -277,6 +288,9 @@
/* Define to disable downsampled decoding. */
/* #undef NO_DOWNSAMPLE */
/* Define to disable equalizer. */
/* #undef NO_EQUALIZER */
/* Define to disable error messages in combination with a return value (the
return is left intact). */
/* #undef NO_ERETURN */
@ -321,13 +335,13 @@
#define PACKAGE "mpg123"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "mpg123-devel@lists.sourceforge.net"
#define PACKAGE_BUGREPORT "maintainer@mpg123.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "mpg123"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "mpg123 1.22.1"
#define PACKAGE_STRING "mpg123 1.23.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "mpg123"
@ -336,7 +350,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.22.1"
#define PACKAGE_VERSION "1.23.0"
/* Define if portaudio v18 API is wanted. */
/* #undef PORTAUDIO18 */
@ -369,7 +383,7 @@
/* #undef USE_YASM_FOR_AVX */
/* Version number of package */
#define VERSION "1.22.1"
#define VERSION "1.23.0"
/* Define to use Win32 named pipes */
#define WANT_WIN32_FIFO 1
@ -380,12 +394,35 @@
/* Define to use Unicode for Windows */
#define WANT_WIN32_UNICODE 1
/* WinXP and above for ipv6 */
/* #undef WINVER */
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* WinXP and above for ipv6 */
/* #undef _WIN32_WINNT */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
@ -401,6 +438,12 @@
/* Define to `int' if <sys/types.h> does not define. */
/* #undef int32_t */
/* Define to `long long' if <sys/types.h> does not define. */
/* #undef int64_t */
/* Define to the native offset type (long or actually off_t). */
#define lfs_alias_t long
/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
@ -408,7 +451,7 @@
/* #undef size_t */
/* Define to `long' if <sys/types.h> does not define. */
#define ssize_t long
/* #undef ssize_t */
/* Define to `unsigned short' if <sys/types.h> does not define. */
/* #undef uint16_t */

View file

@ -22,24 +22,31 @@
It's cumbersome to have them all with different names, though...
*/
#ifdef ME
#define DBGPRFX ME": "
#else
#define DBGPRFX ""
#endif
#ifdef DEBUG
#include <stdio.h>
#define debug(s) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__)
#define debug1(s, a) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a)
#define debug2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b)
#define debug3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c)
#define debug4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d)
#define debug5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e)
#define debug6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f)
#define debug7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define debug8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define debug9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define debug10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
#define debug11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
#define debug12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
#define debug13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
#define debug14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
#define debug15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
#define debug(s) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__)
#define debug1(s, a) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a)
#define debug2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b)
#define debug3(s, a, b, c) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c)
#define debug4(s, a, b, c, d) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d)
#define debug5(s, a, b, c, d, e) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e)
#define debug6(s, a, b, c, d, e, f) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f)
#define debug7(s, a, b, c, d, e, f, g) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define debug8(s, a, b, c, d, e, f, g, h) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define debug9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define debug10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
#define debug11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
#define debug12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
#define debug13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
#define debug14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
#define debug15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
#else
#define debug(s)
#define debug1(s, a)
@ -61,22 +68,22 @@
/* warning macros also here... */
#ifndef NO_WARNING
#define warning(s) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__)
#define warning1(s, a) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a)
#define warning2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b)
#define warning3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c)
#define warning4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d)
#define warning5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e)
#define warning6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f)
#define warning7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define warning8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define warning9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define warning10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
#define warning11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
#define warning12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
#define warning13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
#define warning14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
#define warning15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
#define warning(s) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__)
#define warning1(s, a) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a)
#define warning2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b)
#define warning3(s, a, b, c) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c)
#define warning4(s, a, b, c, d) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d)
#define warning5(s, a, b, c, d, e) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e)
#define warning6(s, a, b, c, d, e, f) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f)
#define warning7(s, a, b, c, d, e, f, g) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define warning8(s, a, b, c, d, e, f, g, h) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define warning9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define warning10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
#define warning11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
#define warning12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
#define warning13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
#define warning14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
#define warning15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
#else
#define warning(s)
#define warning1(s, a)
@ -97,23 +104,23 @@
#endif
/* error macros also here... */
#ifndef NO_ERRORMSG
#define error(s) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__)
#define error1(s, a) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a)
#define error2(s, a, b) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
#define error3(s, a, b, c) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c)
#define error4(s, a, b, c, d) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d)
#define error5(s, a, b, c, d, e) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e)
#define error6(s, a, b, c, d, e, f) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f)
#define error7(s, a, b, c, d, e, f, g) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define error8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define error9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define error10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
#define error11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
#define error12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
#define error13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
#define error14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
#define error15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, "\n[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
#ifndef NO_ERROR
#define error(s) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__)
#define error1(s, a) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a)
#define error2(s, a, b) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
#define error3(s, a, b, c) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c)
#define error4(s, a, b, c, d) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d)
#define error5(s, a, b, c, d, e) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e)
#define error6(s, a, b, c, d, e, f) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f)
#define error7(s, a, b, c, d, e, f, g) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define error8(s, a, b, c, d, e, f, g, h) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define error9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define error10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
#define error11(s, a, b, c, d, e, f, g, h, i, j, k) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k)
#define error12(s, a, b, c, d, e, f, g, h, i, j, k, l) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l)
#define error13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m)
#define error14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
#define error15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
#else
#define error(s)
#define error1(s, a)
@ -135,22 +142,22 @@
/* ereturn macros also here... */
#ifndef NO_ERETURN
#define ereturn(rv, s) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__); return rv; }while(0)
#define ereturn1(rv, s, a) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a); return rv; }while(0)
#define ereturn2(rv, s, a, b) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b); return rv; }while(0)
#define ereturn3(rv, s, a, b, c) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c); return rv; }while(0)
#define ereturn4(rv, s, a, b, c, d) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d); return rv; }while(0)
#define ereturn5(rv, s, a, b, c, d, e) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e); return rv; }while(0)
#define ereturn6(rv, s, a, b, c, d, e, f) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f); return rv; }while(0)
#define ereturn7(rv, s, a, b, c, d, e, f, g) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g); return rv; }while(0)
#define ereturn8(rv, s, a, b, c, d, e, f, g, h) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h); return rv; }while(0)
#define ereturn9(rv, s, a, b, c, d, e, f, g, h, i) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i); return rv; }while(0)
#define ereturn10(rv, s, a, b, c, d, e, f, g, h, i, j) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j); return rv; }while(0)
#define ereturn11(rv, s, a, b, c, d, e, f, g, h, i, j, k) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k); return rv; }while(0)
#define ereturn12(rv, s, a, b, c, d, e, f, g, h, i, j, k, l) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l); return rv; }while(0)
#define ereturn13(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m); return rv; }while(0)
#define ereturn14(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n); return rv; }while(0)
#define ereturn15(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) do{ fprintf(stderr, "\n[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); return rv; }while(0)
#define ereturn(rv, s) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__); return rv; }while(0)
#define ereturn1(rv, s, a) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a); return rv; }while(0)
#define ereturn2(rv, s, a, b) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b); return rv; }while(0)
#define ereturn3(rv, s, a, b, c) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c); return rv; }while(0)
#define ereturn4(rv, s, a, b, c, d) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d); return rv; }while(0)
#define ereturn5(rv, s, a, b, c, d, e) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e); return rv; }while(0)
#define ereturn6(rv, s, a, b, c, d, e, f) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f); return rv; }while(0)
#define ereturn7(rv, s, a, b, c, d, e, f, g) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g); return rv; }while(0)
#define ereturn8(rv, s, a, b, c, d, e, f, g, h) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h); return rv; }while(0)
#define ereturn9(rv, s, a, b, c, d, e, f, g, h, i) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i); return rv; }while(0)
#define ereturn10(rv, s, a, b, c, d, e, f, g, h, i, j) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j); return rv; }while(0)
#define ereturn11(rv, s, a, b, c, d, e, f, g, h, i, j, k) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k); return rv; }while(0)
#define ereturn12(rv, s, a, b, c, d, e, f, g, h, i, j, k, l) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l); return rv; }while(0)
#define ereturn13(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m); return rv; }while(0)
#define ereturn14(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n); return rv; }while(0)
#define ereturn15(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) do{ fprintf(stderr, DBGPRFX"[" __FILE__ ":%i] ereturn: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); return rv; }while(0)
#else
#define ereturn(rv, s) return rv
#define ereturn1(rv, s, a) return rv

View file

@ -131,13 +131,13 @@ int synth_1to1_real_stereo_sse (real*, real*, mpg123_handle*);
int synth_1to1_real_x86_64 (real*, int, mpg123_handle*, int);
int synth_1to1_real_stereo_x86_64(real*, real*, mpg123_handle*);
int synth_1to1_real_avx (real*, int, mpg123_handle*, int);
int synth_1to1_real_stereo_avx (real*, real*, mpg123_handle*);
int synth_1to1_fltst_avx (real*, real*, mpg123_handle*);
int synth_1to1_real_altivec (real*, int, mpg123_handle*, int);
int synth_1to1_real_stereo_altivec(real*, real*, mpg123_handle*);
int synth_1to1_fltst_altivec(real*, real*, mpg123_handle*);
int synth_1to1_real_neon (real*, int, mpg123_handle*, int);
int synth_1to1_real_stereo_neon(real*, real*, mpg123_handle*);
int synth_1to1_real_neon64 (real*, int, mpg123_handle*, int);
int synth_1to1_real_stereo_neon64(real*, real*, mpg123_handle*);
int synth_1to1_fltst_neon64(real*, real*, mpg123_handle*);
int synth_1to1_real_mono (real*, mpg123_handle*);
int synth_1to1_real_m2s(real*, mpg123_handle*);
#ifndef NO_DOWNSAMPLE
@ -172,7 +172,7 @@ int synth_1to1_s32_stereo_altivec(real*, real*, mpg123_handle*);
int synth_1to1_s32_neon (real*, int, mpg123_handle*, int);
int synth_1to1_s32_stereo_neon(real*, real*, mpg123_handle*);
int synth_1to1_s32_neon64 (real*, int, mpg123_handle*, int);
int synth_1to1_s32_stereo_neon64(real*, real*, mpg123_handle*);
int synth_1to1_s32st_neon64(real*, real*, mpg123_handle*);
int synth_1to1_s32_mono (real*, mpg123_handle*);
int synth_1to1_s32_m2s(real*, mpg123_handle*);
#ifndef NO_DOWNSAMPLE

View file

@ -0,0 +1,119 @@
/*
dither: Generate shaped noise for dithering
copyright 2009 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Taihei Monma
*/
#include "config.h"
#include "compat.h"
#include "dither.h"
static const uint32_t init_seed = 2463534242UL;
#define LAP 100
/*
xorshift random number generator, with output scaling to [-0.5, 0.5]
This is the white noise...
See http://www.jstatsoft.org/v08/i14/paper on XOR shift random number generators.
*/
static float rand_xorshift32(uint32_t *seed)
{
union
{
uint32_t i;
float f;
} fi;
fi.i = *seed;
fi.i ^= (fi.i<<13);
fi.i ^= (fi.i>>17);
fi.i ^= (fi.i<<5);
*seed = fi.i;
/* scale the number to [-0.5, 0.5] */
#ifdef IEEE_FLOAT
fi.i = (fi.i>>9)|0x3f800000;
fi.f -= 1.5f;
#else
fi.f = (double)fi.i / 4294967295.0;
fi.f -= 0.5f;
#endif
return fi.f;
}
static void white_noise(float *table, size_t count)
{
size_t i;
uint32_t seed = init_seed;
for(i=0; i<count; ++i)
table[i] = rand_xorshift32(&seed);
}
static void tpdf_noise(float *table, size_t count)
{
size_t i;
uint32_t seed = init_seed;
for(i=0; i<count; ++i)
table[i] = rand_xorshift32(&seed) + rand_xorshift32(&seed);
}
static void highpass_tpdf_noise(float *table, size_t count)
{
size_t i;
uint32_t seed = init_seed;
/* Ensure some minimum lap for keeping the high-pass filter circular. */
size_t lap = count > 2*LAP ? LAP : count/2;
float input_noise;
float xv[9], yv[9];
for(i=0;i<9;i++)
{
xv[i] = yv[i] = 0.0f;
}
for(i=0;i<count+lap;i++)
{
if(i==count) seed=init_seed;
/* generate and add 2 random numbers, to make a TPDF noise distribution */
input_noise = rand_xorshift32(&seed) + rand_xorshift32(&seed);
/* apply 8th order Chebyshev high-pass IIR filter */
/* Coefficients are from http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html
Given parameters are: Chebyshev, Highpass, ripple=-1, order=8, samplerate=44100, corner1=19000 */
xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4]; xv[4] = xv[5]; xv[5] = xv[6]; xv[6] = xv[7]; xv[7] = xv[8];
xv[8] = input_noise / 1.382814179e+07;
yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4]; yv[4] = yv[5]; yv[5] = yv[6]; yv[6] = yv[7]; yv[7] = yv[8];
yv[8] = (xv[0] + xv[8]) - 8 * (xv[1] + xv[7]) + 28 * (xv[2] + xv[6])
- 56 * (xv[3] + xv[5]) + 70 * xv[4]
+ ( -0.6706204984 * yv[0]) + ( -5.3720827038 * yv[1])
+ (-19.0865382480 * yv[2]) + (-39.2831607860 * yv[3])
+ (-51.2308985070 * yv[4]) + (-43.3590135780 * yv[5])
+ (-23.2632305320 * yv[6]) + ( -7.2370122050 * yv[7]);
if(i>=lap) table[i-lap] = yv[8] * 3.0f;
}
}
void mpg123_noise(float* table, size_t count, enum mpg123_noise_type noisetype)
{
switch(noisetype)
{
case mpg123_white_noise: white_noise(table, count); break;
case mpg123_tpdf_noise: tpdf_noise(table, count); break;
case mpg123_highpass_tpdf_noise:
highpass_tpdf_noise(table, count);
break;
}
}
/* Generate white noise and shape it with a high pass filter. */
void dither_table_init(float *dithertable)
{
highpass_tpdf_noise(dithertable, DITHERSIZE);
}

View file

@ -0,0 +1,135 @@
/*
libmpg123: MPEG Audio Decoder library
separate header just for audio format definitions not tied to
library code
copyright 1995-2015 by the mpg123 project
free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
*/
#ifndef MPG123_ENC_H
#define MPG123_ENC_H
/** \file fmt123.h Audio format definitions. */
/** \defgroup mpg123_enc mpg123 PCM sample encodings
* These are definitions for audio formats used by libmpg123 and
* libout123.
*
* @{
*/
/** An enum over all sample types possibly known to mpg123.
* The values are designed as bit flags to allow bitmasking for encoding
* families.
* This is also why the enum is not used as type for actual encoding variables,
* plain integers (at least 16 bit, 15 bit being used) cover the possible
* combinations of these flags.
*
* Note that (your build of) libmpg123 does not necessarily support all these.
* Usually, you can expect the 8bit encodings and signed 16 bit.
* Also 32bit float will be usual beginning with mpg123-1.7.0 .
* What you should bear in mind is that (SSE, etc) optimized routines may be
* absent for some formats. We do have SSE for 16, 32 bit and float, though.
* 24 bit integer is done via postprocessing of 32 bit output -- just cutting
* the last byte, no rounding, even. If you want better, do it yourself.
*
* All formats are in native byte order. If you need different endinaness, you
* can simply postprocess the output buffers (libmpg123 wouldn't do anything
* else). The macro MPG123_SAMPLESIZE() can be helpful there.
*/
enum mpg123_enc_enum
{
/* 0000 0000 0000 1111 Some 8 bit integer encoding. */
MPG123_ENC_8 = 0x00f
/* 0000 0000 0100 0000 Some 16 bit integer encoding. */
, MPG123_ENC_16 = 0x040
/* 0100 0000 0000 0000 Some 24 bit integer encoding. */
, MPG123_ENC_24 = 0x4000
/* 0000 0001 0000 0000 Some 32 bit integer encoding. */
, MPG123_ENC_32 = 0x100
/* 0000 0000 1000 0000 Some signed integer encoding. */
, MPG123_ENC_SIGNED = 0x080
/* 0000 1110 0000 0000 Some float encoding. */
, MPG123_ENC_FLOAT = 0xe00
/* 0000 0000 1101 0000 signed 16 bit */
, MPG123_ENC_SIGNED_16 = (MPG123_ENC_16|MPG123_ENC_SIGNED|0x10)
/* 0000 0000 0110 0000 unsigned 16 bit */
, MPG123_ENC_UNSIGNED_16 = (MPG123_ENC_16|0x20)
/* 0000 0000 0000 0001 unsigned 8 bit */
, MPG123_ENC_UNSIGNED_8 = 0x01
/* 0000 0000 1000 0010 signed 8 bit */
, MPG123_ENC_SIGNED_8 = (MPG123_ENC_SIGNED|0x02)
/* 0000 0000 0000 0100 ulaw 8 bit */
, MPG123_ENC_ULAW_8 = 0x04
/* 0000 0000 0000 1000 alaw 8 bit */
, MPG123_ENC_ALAW_8 = 0x08
/* 0001 0001 1000 0000 signed 32 bit */
, MPG123_ENC_SIGNED_32 = MPG123_ENC_32|MPG123_ENC_SIGNED|0x1000
/* 0010 0001 0000 0000 unsigned 32 bit */
, MPG123_ENC_UNSIGNED_32 = MPG123_ENC_32|0x2000
/* 0101 0000 1000 0000 signed 24 bit */
, MPG123_ENC_SIGNED_24 = MPG123_ENC_24|MPG123_ENC_SIGNED|0x1000
/* 0110 0000 0000 0000 unsigned 24 bit */
, MPG123_ENC_UNSIGNED_24 = MPG123_ENC_24|0x2000
/* 0000 0010 0000 0000 32bit float */
, MPG123_ENC_FLOAT_32 = 0x200
/* 0000 0100 0000 0000 64bit float */
, MPG123_ENC_FLOAT_64 = 0x400
/* Any possibly known encoding from the list above. */
, MPG123_ENC_ANY = ( MPG123_ENC_SIGNED_16 | MPG123_ENC_UNSIGNED_16
| MPG123_ENC_UNSIGNED_8 | MPG123_ENC_SIGNED_8
| MPG123_ENC_ULAW_8 | MPG123_ENC_ALAW_8
| MPG123_ENC_SIGNED_32 | MPG123_ENC_UNSIGNED_32
| MPG123_ENC_SIGNED_24 | MPG123_ENC_UNSIGNED_24
| MPG123_ENC_FLOAT_32 | MPG123_ENC_FLOAT_64 )
};
/** Get size of one PCM sample with given encoding.
* This is included both in libmpg123 and libout123. Both offer
* an API function to provide the macro results from library
* compile-time, not that of you application. This most likely
* does not matter as I do not expect any fresh PCM sample
* encoding to appear. But who knows? Perhaps the encoding type
* will be abused for funny things in future, not even plain PCM.
* And, by the way: Thomas really likes the ?: operator.
* \param enc the encoding (mpg123_enc_enum value)
* \return size of one sample in bytes
*/
#define MPG123_SAMPLESIZE(enc) ( \
(enc) & MPG123_ENC_8 \
? 1 \
: ( (enc) & MPG123_ENC_16 \
? 2 \
: ( (enc) & MPG123_ENC_24 \
? 3 \
: ( ( (enc) & MPG123_ENC_32 \
|| (enc) == MPG123_ENC_FLOAT_32 ) \
? 4 \
: ( (enc) == MPG123_ENC_FLOAT_64 \
? 8 \
: 0 \
) ) ) ) )
/** Structure defining an audio format.
* Providing the members as individual function arguments to define a certain
* output format is easy enough. This struct makes is more comfortable to deal
* with a list of formats.
* Negative values for the members might be used to communicate use of default
* values.
*/
struct mpg123_fmt
{
long rate; /**< sampling rate in Hz */
int channels; /**< channel count */
/** encoding code, can be single value or bitwise or of members of
* mpg123_enc_enum */
int encoding;
};
/* @} */
#endif

View file

@ -121,9 +121,10 @@ struct mpg123_handle_struct
float *decwin_mmx;
float *decwins;
#endif
#ifndef NO_EQUALIZER
int have_eq_settings;
real equalizer[2][32];
#endif
/* for halfspeed mode */
unsigned char ssave[34];
int halfphase;

View file

@ -1,14 +1,20 @@
#ifndef MPG123_INTMAP_H
#define MPG123_INTMAP_H
/* Mapping of internal mpg123 symbols to something that is less likely to conflict in case of static linking. */
#ifndef MPG123_INTSYM_H
#define MPG123_INTSYM_H
/* Mapping of internal mpg123 symbols to something that is less likely to
conflict in case of static linking. */
#include "config.h"
#define COS9 INT123_COS9
#define tfcos36 INT123_tfcos36
#define pnts INT123_pnts
#define safe_realloc INT123_safe_realloc
#define compat_open INT123_compat_open
#define compat_fopen INT123_compat_fopen
#define compat_close INT123_compat_close
#define compat_fclose INT123_compat_fclose
#define win32_wide_utf8 INT123_win32_wide_utf8
#define win32_utf8_wide INT123_win32_utf8_wide
#define unintr_write INT123_unintr_write
#define unintr_read INT123_unintr_read
#define ntom_set_ntom INT123_ntom_set_ntom
#define synth_1to1 INT123_synth_1to1
#define synth_1to1_dither INT123_synth_1to1_dither
@ -29,6 +35,8 @@
#define synth_1to1_arm INT123_synth_1to1_arm
#define synth_1to1_neon INT123_synth_1to1_neon
#define synth_1to1_stereo_neon INT123_synth_1to1_stereo_neon
#define synth_1to1_neon64 INT123_synth_1to1_neon64
#define synth_1to1_stereo_neon64 INT123_synth_1to1_stereo_neon64
#define absynth_1to1_i486 INT123_absynth_1to1_i486
#define synth_1to1_mono INT123_synth_1to1_mono
#define synth_1to1_m2s INT123_synth_1to1_m2s
@ -70,11 +78,13 @@
#define synth_1to1_real_x86_64 INT123_synth_1to1_real_x86_64
#define synth_1to1_real_stereo_x86_64 INT123_synth_1to1_real_stereo_x86_64
#define synth_1to1_real_avx INT123_synth_1to1_real_avx
#define synth_1to1_real_stereo_avx INT123_synth_1to1_real_stereo_avx
#define synth_1to1_fltst_avx INT123_synth_1to1_fltst_avx
#define synth_1to1_real_altivec INT123_synth_1to1_real_altivec
#define synth_1to1_real_stereo_altivec INT123_synth_1to1_real_stereo_altivec
#define synth_1to1_fltst_altivec INT123_synth_1to1_fltst_altivec
#define synth_1to1_real_neon INT123_synth_1to1_real_neon
#define synth_1to1_real_stereo_neon INT123_synth_1to1_real_stereo_neon
#define synth_1to1_real_neon64 INT123_synth_1to1_real_neon64
#define synth_1to1_fltst_neon64 INT123_synth_1to1_fltst_neon64
#define synth_1to1_real_mono INT123_synth_1to1_real_mono
#define synth_1to1_real_m2s INT123_synth_1to1_real_m2s
#define synth_2to1_real INT123_synth_2to1_real
@ -100,6 +110,8 @@
#define synth_1to1_s32_stereo_altivec INT123_synth_1to1_s32_stereo_altivec
#define synth_1to1_s32_neon INT123_synth_1to1_s32_neon
#define synth_1to1_s32_stereo_neon INT123_synth_1to1_s32_stereo_neon
#define synth_1to1_s32_neon64 INT123_synth_1to1_s32_neon64
#define synth_1to1_s32st_neon64 INT123_synth_1to1_s32st_neon64
#define synth_1to1_s32_mono INT123_synth_1to1_s32_mono
#define synth_1to1_s32_m2s INT123_synth_1to1_s32_m2s
#define synth_2to1_s32 INT123_synth_2to1_s32
@ -120,8 +132,8 @@
#define dct36 INT123_dct36
#define dct36_3dnow INT123_dct36_3dnow
#define dct36_3dnowext INT123_dct36_3dnowext
#define dct36_sse INT123_dct36_sse
#define dct36_x86_64 INT123_dct36_x86_64
#define dct36_sse INT123_dct36_sse
#define dct36_avx INT123_dct36_avx
#define dct36_neon INT123_dct36_neon
#define dct36_neon64 INT123_dct36_neon64
@ -198,8 +210,11 @@
#define double_to_long_rounded INT123_double_to_long_rounded
#define scale_rounded INT123_scale_rounded
#define decode_update INT123_decode_update
#define decoder_synth_bytes INT123_decoder_synth_bytes
#define samples_to_bytes INT123_samples_to_bytes
#define bytes_to_samples INT123_bytes_to_samples
#define outblock_bytes INT123_outblock_bytes
#define postprocess_buffer INT123_postprocess_buffer
#define frame_cpu_opt INT123_frame_cpu_opt
#define set_synth_functions INT123_set_synth_functions
#define dectype INT123_dectype
@ -216,6 +231,10 @@
#define compute_bpf INT123_compute_bpf
#define time_to_frame INT123_time_to_frame
#define get_songlen INT123_get_songlen
#define bc_prepare INT123_bc_prepare
#define bc_cleanup INT123_bc_cleanup
#define bc_poolsize INT123_bc_poolsize
#define bc_fill INT123_bc_fill
#define open_stream INT123_open_stream
#define open_stream_handle INT123_open_stream_handle
#define open_feed INT123_open_feed
@ -223,20 +242,21 @@
#define feed_forget INT123_feed_forget
#define feed_set_pos INT123_feed_set_pos
#define open_bad INT123_open_bad
#define check_neon INT123_check_neon
#define dct64_3dnow INT123_dct64_3dnow
#define dct64_3dnowext INT123_dct64_3dnowext
#define dct64_avx INT123_dct64_avx
#define dct64_real_avx INT123_dct64_real_avx
#define dct64_mmx INT123_dct64_mmx
#define dct64_MMX INT123_dct64_MMX
#define dct64_neon INT123_dct64_neon
#define dct64_neon64 INT123_dct64_neon64
#define dct64_real_neon64 INT123_dct64_real_neon64
#define dct64_real_neon INT123_dct64_real_neon
#define dct64_sse INT123_dct64_sse
#define dct64_real_sse INT123_dct64_real_sse
#define dct64_x86_64 INT123_dct64_x86_64
#define dct64_real_x86_64 INT123_dct64_real_x86_64
#define dct64_avx INT123_dct64_avx
#define dct64_real_avx INT123_dct64_real_avx
#define dct64_neon INT123_dct64_neon
#define dct64_real_neon INT123_dct64_real_neon
#define dct64_neon64 INT123_dct64_neon64
#define dct64_real_neon64 INT123_dct64_real_neon64
#define do_equalizer_3dnow INT123_do_equalizer_3dnow
#define synth_1to1_3dnow_asm INT123_synth_1to1_3dnow_asm
#define synth_1to1_arm_asm INT123_synth_1to1_arm_asm
@ -244,9 +264,29 @@
#define synth_1to1_i586_asm INT123_synth_1to1_i586_asm
#define synth_1to1_i586_asm_dither INT123_synth_1to1_i586_asm_dither
#define synth_1to1_MMX INT123_synth_1to1_MMX
#define synth_1to1_neon_asm INT123_synth_1to1_neon_asm
#define synth_1to1_neon64_asm INT123_synth_1to1_neon64_asm
#define synth_1to1_neon64_accurate_asm INT123_synth_1to1_neon64_accurate_asm
#define synth_1to1_real_neon64_asm INT123_synth_1to1_real_neon64_asm
#define synth_1to1_s32_neon64_asm INT123_synth_1to1_s32_neon64_asm
#define synth_1to1_neon_accurate_asm INT123_synth_1to1_neon_accurate_asm
#define synth_1to1_real_neon_asm INT123_synth_1to1_real_neon_asm
#define synth_1to1_s32_neon_asm INT123_synth_1to1_s32_neon_asm
#define synth_1to1_sse_accurate_asm INT123_synth_1to1_sse_accurate_asm
#define synth_1to1_real_sse_asm INT123_synth_1to1_real_sse_asm
#define synth_1to1_s32_sse_asm INT123_synth_1to1_s32_sse_asm
#define synth_1to1_s_avx_asm INT123_synth_1to1_s_avx_asm
#define synth_1to1_s_avx_accurate_asm INT123_synth_1to1_s_avx_accurate_asm
#define synth_1to1_real_s_avx_asm INT123_synth_1to1_real_s_avx_asm
#define synth_1to1_s32_s_avx_asm INT123_synth_1to1_s32_s_avx_asm
#define synth_1to1_s_neon_asm INT123_synth_1to1_s_neon_asm
#define synth_1to1_s_neon64_asm INT123_synth_1to1_s_neon64_asm
#define synth_1to1_s_neon64_accurate_asm INT123_synth_1to1_s_neon64_accurate_asm
#define synth_1to1_real_s_neon64_asm INT123_synth_1to1_real_s_neon64_asm
#define synth_1to1_s32_s_neon64_asm INT123_synth_1to1_s32_s_neon64_asm
#define synth_1to1_s_neon_accurate_asm INT123_synth_1to1_s_neon_accurate_asm
#define synth_1to1_real_s_neon_asm INT123_synth_1to1_real_s_neon_asm
#define synth_1to1_s32_s_neon_asm INT123_synth_1to1_s32_s_neon_asm
#define synth_1to1_s_sse_accurate_asm INT123_synth_1to1_s_sse_accurate_asm
#define synth_1to1_real_s_sse_asm INT123_synth_1to1_real_s_sse_asm
#define synth_1to1_s32_s_sse_asm INT123_synth_1to1_s32_s_sse_asm
@ -258,27 +298,12 @@
#define synth_1to1_x86_64_accurate_asm INT123_synth_1to1_x86_64_accurate_asm
#define synth_1to1_real_x86_64_asm INT123_synth_1to1_real_x86_64_asm
#define synth_1to1_s32_x86_64_asm INT123_synth_1to1_s32_x86_64_asm
#define synth_1to1_s_avx_asm INT123_synth_1to1_s_avx_asm
#define synth_1to1_s_avx_accurate_asm INT123_synth_1to1_s_avx_accurate_asm
#define synth_1to1_real_s_avx_asm INT123_synth_1to1_real_s_avx_asm
#define synth_1to1_s32_s_avx_asm INT123_synth_1to1_s32_s_avx_asm
#define synth_1to1_neon_asm INT123_synth_1to1_neon_asm
#define synth_1to1_neon_accurate_asm INT123_synth_1to1_neon_accurate_asm
#define synth_1to1_real_neon_asm INT123_synth_1to1_real_neon_asm
#define synth_1to1_s32_neon_asm INT123_synth_1to1_s32_neon_asm
#define synth_1to1_s_neon_asm INT123_synth_1to1_s_neon_asm
#define synth_1to1_s_neon_accurate_asm INT123_synth_1to1_s_neon_accurate_asm
#define synth_1to1_real_s_neon_asm INT123_synth_1to1_real_s_neon_asm
#define synth_1to1_s32_s_neon_asm INT123_synth_1to1_s32_s_neon_asm
#define synth_1to1_neon64_asm INT123_synth_1to1_neon64_asm
#define synth_1to1_neon64_accurate_asm INT123_synth_1to1_neon64_accurate_asm
#define synth_1to1_real_neon64_asm INT123_synth_1to1_real_neon64_asm
#define synth_1to1_s32_neon64_asm INT123_synth_1to1_s32_neon64_asm
#define synth_1to1_s_neon64_asm INT123_synth_1to1_s_neon64_asm
#define synth_1to1_s_neon64_accurate_asm INT123_synth_1to1_s_neon64_accurate_asm
#define synth_1to1_real_s_neon64_asm INT123_synth_1to1_real_s_neon64_asm
#define synth_1to1_s32_s_neon64_asm INT123_synth_1to1_s32_s_neon64_asm
#define costab_mmxsse INT123_costab_mmxsse
#define make_decode_tables_mmx_asm INT123_make_decode_tables_mmx_asm
#define check_neon INT123_check_neon
#ifndef HAVE_STRDUP
#define strdup INT123_strdup
#endif
#ifndef HAVE_STRERROR
#define strerror INT123_strerror
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -36,9 +36,9 @@ int SYNTH_NAME(real *bandPtr, int channel, mpg123_handle *fr, int final)
real *b0, **buf; /* (*buf)[0x110]; */
int clip = 0;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;

View file

@ -72,9 +72,9 @@ int SYNTH_NAME(real *bandPtr,int channel, mpg123_handle *fr, int final)
int clip = 0;
int bo1;
int ntom;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;

View file

@ -14,7 +14,7 @@ add_definitions(
include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libmpg123)
list(APPEND SOURCE
compat.c
compat/compat.c
dct64.c
dct64_i386.c
equalizer.c
@ -43,7 +43,3 @@ list(APPEND SOURCE
add_library(libmpg123 ${SOURCE} optimize.c)
add_dependencies(libmpg123 psdk)
add_pch(libmpg123 precomp.h SOURCE)
if((NOT MSVC) AND (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang"))
add_target_compile_flags(libmpg123 "-Wno-unused-but-set-variable")
endif()

View file

@ -0,0 +1,16 @@
/*
Just to ensure that libraries and programs get their separate
compatibility object. There should be a compatibility library,
I presume, but I don't want to create another glib, I just want
some internal functions to ease coding.
I'll sort it out properly sometime.
I smell symbol conflicts, anyway. Actually wondering why it
worked so far.
*/
#include "config.h"
#include "intsym.h"
#define NO_CATCHSIGNAL
#include "compat/compat_impl.h"

View file

@ -56,6 +56,7 @@ char *strdup(const char *src)
}
#endif
/* Always add a default permission mask in case of flags|O_CREAT. */
int compat_open(const char *filename, int flags)
{
int ret;
@ -63,29 +64,67 @@ int compat_open(const char *filename, int flags)
wchar_t *frag = NULL;
ret = win32_utf8_wide(filename, &frag, NULL);
if ((frag == NULL) || (ret == 0)) goto fallback; /* Fallback to plain open when ucs-2 conversion fails */
/* Fallback to plain open when ucs-2 conversion fails */
if((frag == NULL) || (ret == 0))
goto open_fallback;
ret = _wopen(frag, flags); /*Try _wopen */
if (ret != -1 ) goto open_ok; /* msdn says -1 means failure */
/*Try _wopen */
ret = _wopen(frag, flags|_O_BINARY, _S_IREAD | _S_IWRITE);
if(ret != -1 )
goto open_ok; /* msdn says -1 means failure */
fallback:
open_fallback:
#endif
#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
ret = _open(filename, flags); /* Try plain old _open(), if it fails, do nothing */
#if (defined(WIN32) && !defined (__CYGWIN__))
/* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
/* Try plain old _open(), if it fails, do nothing */
ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE);
#else
/* On UNIX, we always add a default permission mask in case flags|O_CREAT. */
ret = open(filename, flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
#endif
#if defined (WANT_WIN32_UNICODE)
open_ok:
free ((void *)frag); /* Freeing a NULL should be OK */
/* A cast to void*? Does Windows need that?! */
free((void *)frag);
#endif
return ret;
}
/* Moved over from wav.c, logic with fallbacks added from the
example of compat_open(). */
FILE* compat_fopen(const char *filename, const char *mode)
{
FILE* stream = NULL;
#ifdef WANT_WIN32_UNICODE
int cnt = 0;
wchar_t *wname = NULL;
wchar_t *wmode = NULL;
cnt = win32_utf8_wide(filename, &wname, NULL);
if( (wname == NULL) || (cnt == 0))
goto fopen_fallback;
cnt = win32_utf8_wide(mode, &wmode, NULL);
if( (wmode == NULL) || (cnt == 0))
goto fopen_fallback;
stream = _wfopen(wname, wmode);
if(stream) goto fopen_ok;
fopen_fallback:
#endif
stream = fopen(filename, mode);
#ifdef WANT_WIN32_UNICODE
fopen_ok:
free(wmode);
free(wname);
#endif
return stream;
}
int compat_close(int infd)
{
#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
@ -95,6 +134,11 @@ int compat_close(int infd)
#endif
}
int compat_fclose(FILE *stream)
{
return fclose(stream);
}
/* Windows Unicode stuff */
#ifdef WANT_WIN32_UNICODE
@ -136,3 +180,57 @@ int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen)
return ret; /* Number of characters written */
}
#endif
/* This shall survive signals and any return value less than given byte count
is an error */
size_t unintr_write(int fd, void const *buffer, size_t bytes)
{
size_t written = 0;
while(bytes)
{
ssize_t part = write(fd, (char*)buffer+written, bytes);
if(part < 0 && errno != EINTR)
break;
bytes -= part;
written += part;
}
return written;
}
/* Same for reading the data. */
size_t unintr_read(int fd, void *buffer, size_t bytes)
{
size_t got = 0;
while(bytes)
{
ssize_t part = read(fd, (char*)buffer+got, bytes);
if(part < 0 && errno != EINTR)
break;
bytes -= part;
got += part;
}
return got;
}
#ifndef NO_CATCHSIGNAL
#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
void (*catchsignal(int signum, void(*handler)()))()
{
struct sigaction new_sa;
struct sigaction old_sa;
#ifdef DONT_CATCH_SIGNALS
fprintf (stderr, "Not catching any signals.\n");
return ((void (*)()) -1);
#endif
new_sa.sa_handler = handler;
sigemptyset(&new_sa.sa_mask);
new_sa.sa_flags = 0;
if(sigaction(signum, &new_sa, &old_sa) == -1)
return ((void (*)()) -1);
return (old_sa.sa_handler);
}
#endif
#endif

View file

@ -1,119 +1,3 @@
/*
dither: Generate shaped noise for dithering
copyright 2009 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Taihei Monma
*/
#include "config.h"
#include "compat.h"
#include "dither.h"
static const uint32_t init_seed = 2463534242UL;
#define LAP 100
/*
xorshift random number generator, with output scaling to [-0.5, 0.5]
This is the white noise...
See http://www.jstatsoft.org/v08/i14/paper on XOR shift random number generators.
*/
static float rand_xorshift32(uint32_t *seed)
{
union
{
uint32_t i;
float f;
} fi;
fi.i = *seed;
fi.i ^= (fi.i<<13);
fi.i ^= (fi.i>>17);
fi.i ^= (fi.i<<5);
*seed = fi.i;
/* scale the number to [-0.5, 0.5] */
#ifdef IEEE_FLOAT
fi.i = (fi.i>>9)|0x3f800000;
fi.f -= 1.5f;
#else
fi.f = (double)fi.i / 4294967295.0;
fi.f -= 0.5f;
#endif
return fi.f;
}
static void white_noise(float *table, size_t count)
{
size_t i;
uint32_t seed = init_seed;
for(i=0; i<count; ++i)
table[i] = rand_xorshift32(&seed);
}
static void tpdf_noise(float *table, size_t count)
{
size_t i;
uint32_t seed = init_seed;
for(i=0; i<count; ++i)
table[i] = rand_xorshift32(&seed) + rand_xorshift32(&seed);
}
static void highpass_tpdf_noise(float *table, size_t count)
{
size_t i;
uint32_t seed = init_seed;
/* Ensure some minimum lap for keeping the high-pass filter circular. */
size_t lap = count > 2*LAP ? LAP : count/2;
float input_noise;
float xv[9], yv[9];
for(i=0;i<9;i++)
{
xv[i] = yv[i] = 0.0f;
}
for(i=0;i<count+lap;i++)
{
if(i==count) seed=init_seed;
/* generate and add 2 random numbers, to make a TPDF noise distribution */
input_noise = rand_xorshift32(&seed) + rand_xorshift32(&seed);
/* apply 8th order Chebyshev high-pass IIR filter */
/* Coefficients are from http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html
Given parameters are: Chebyshev, Highpass, ripple=-1, order=8, samplerate=44100, corner1=19000 */
xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4]; xv[4] = xv[5]; xv[5] = xv[6]; xv[6] = xv[7]; xv[7] = xv[8];
xv[8] = input_noise / 1.382814179e+07;
yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4]; yv[4] = yv[5]; yv[5] = yv[6]; yv[6] = yv[7]; yv[7] = yv[8];
yv[8] = (xv[0] + xv[8]) - 8 * (xv[1] + xv[7]) + 28 * (xv[2] + xv[6])
- 56 * (xv[3] + xv[5]) + 70 * xv[4]
+ ( -0.6706204984 * yv[0]) + ( -5.3720827038 * yv[1])
+ (-19.0865382480 * yv[2]) + (-39.2831607860 * yv[3])
+ (-51.2308985070 * yv[4]) + (-43.3590135780 * yv[5])
+ (-23.2632305320 * yv[6]) + ( -7.2370122050 * yv[7]);
if(i>=lap) table[i-lap] = yv[8] * 3.0f;
}
}
void mpg123_noise(float* table, size_t count, enum mpg123_noise_type noisetype)
{
switch(noisetype)
{
case mpg123_white_noise: white_noise(table, count); break;
case mpg123_tpdf_noise: tpdf_noise(table, count); break;
case mpg123_highpass_tpdf_noise:
highpass_tpdf_noise(table, count);
break;
}
}
/* Generate white noise and shape it with a high pass filter. */
void dither_table_init(float *dithertable)
{
highpass_tpdf_noise(dithertable, DITHERSIZE);
}
/* Hack to allow building the same code with and without libtool. */
#include "intsym.h"
#include "dither_impl.h"

View file

@ -100,6 +100,12 @@ int mpg123_feature(const enum mpg123_feature_set key)
#else
return 0;
#endif
case MPG123_FEATURE_EQUALIZER:
#ifndef NO_EQUALIZER
return 1;
#else
return 0;
#endif
default: return 0;
}

View file

@ -125,18 +125,7 @@ void attribute_align_arg mpg123_encodings(const int **list, size_t *number)
int attribute_align_arg mpg123_encsize(int encoding)
{
if(encoding & MPG123_ENC_8)
return 1;
else if(encoding & MPG123_ENC_16)
return 2;
else if(encoding & MPG123_ENC_24)
return 3;
else if(encoding & MPG123_ENC_32 || encoding == MPG123_ENC_FLOAT_32)
return 4;
else if(encoding == MPG123_ENC_FLOAT_64)
return 8;
else
return 0;
return MPG123_SAMPLESIZE(encoding);
}
/* char audio_caps[NUM_CHANNELS][MPG123_RATES+1][MPG123_ENCODINGS]; */

View file

@ -168,10 +168,10 @@ int attribute_align_arg mpg123_reset_eq(mpg123_handle *mh)
{
int i;
if(mh == NULL) return MPG123_BAD_HANDLE;
#ifndef NO_EQUALIZER
mh->have_eq_settings = 0;
for(i=0; i < 32; ++i) mh->equalizer[0][i] = mh->equalizer[1][i] = DOUBLE_TO_REAL(1.0);
#endif
return MPG123_OK;
}
@ -838,6 +838,8 @@ void frame_gapless_realinit(mpg123_handle *fr)
void frame_gapless_update(mpg123_handle *fr, off_t total_samples)
{
off_t gapless_samples = fr->gapless_frames*fr->spf;
if(fr->gapless_frames < 1) return;
debug2("gapless update with new sample count %"OFF_P" as opposed to known %"OFF_P, total_samples, gapless_samples);
if(NOQUIET && total_samples != gapless_samples)
fprintf(stderr, "\nWarning: Real sample count %"OFF_P" differs from given gapless sample count %"OFF_P". Frankenstein stream?\n"

View file

@ -1,11 +1,13 @@
/*
icy: Puny code to pretend for a serious ICY data structure.
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2007-2015 by the mpg123 project
-= free software under the terms of the LGPL 2.1 =-
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis
*/
#include "intsym.h"
#include "icy.h"
void init_icy(struct icy_meta *icy)

View file

@ -26,6 +26,8 @@
* Convert from ICY encoding (windows-1252 codepage) to UTF-8
*/
#include "config.h"
#include "intsym.h"
/* Includes string and stdlib headers... */
#include "compat.h"

View file

@ -1,11 +1,13 @@
/*
index: frame index data structure and functions
copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2007-2015 by the mpg123 project
-= free software under the terms of the LGPL 2.1 =-
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis
*/
#include "intsym.h"
#include "index.h"
#include "debug.h"

View file

@ -196,6 +196,12 @@ int attribute_align_arg ALIAS_NAME(mpg123_position)( mpg123_handle *mh, lfs_alia
return NATIVE_NAME(mpg123_position)(mh, frame_offset, buffered_bytes, current_frame, frames_left, current_seconds, seconds_left);
}
lfs_alias_t NATIVE_NAME(mpg123_framelength)(mpg123_handle *mh);
lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_framelength)(mpg123_handle *mh)
{
return NATIVE_NAME(mpg123_framelength)(mh);
}
lfs_alias_t NATIVE_NAME(mpg123_length)(mpg123_handle *mh);
lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_length)(mpg123_handle *mh)
{

View file

@ -467,6 +467,23 @@ int attribute_align_arg mpg123_position(mpg123_handle *mh, long frame_offset, lo
return MPG123_OK;
}
#undef mpg123_framelength
/* off_t mpg123_framelength(mpg123_handle *mh); */
long attribute_align_arg mpg123_framelength(mpg123_handle *mh)
{
long val;
off_t largeval;
largeval = MPG123_LARGENAME(mpg123_framelength)(mh);
val = largeval;
if(val != largeval)
{
mh->err = MPG123_LFS_OVERFLOW;
return MPG123_ERR;
}
return val;
}
#undef mpg123_length
/* off_t mpg123_length(mpg123_handle *mh); */
long attribute_align_arg mpg123_length(mpg123_handle *mh)

View file

@ -382,9 +382,9 @@ int attribute_align_arg mpg123_getstate(mpg123_handle *mh, enum mpg123_state key
return ret;
}
int attribute_align_arg mpg123_eq(mpg123_handle *mh, enum mpg123_channels channel, int band, double val)
{
#ifndef NO_EQUALIZER
if(mh == NULL) return MPG123_BAD_HANDLE;
if(band < 0 || band > 31){ mh->err = MPG123_BAD_BAND; return MPG123_ERR; }
switch(channel)
@ -399,12 +399,14 @@ int attribute_align_arg mpg123_eq(mpg123_handle *mh, enum mpg123_channels channe
return MPG123_ERR;
}
mh->have_eq_settings = TRUE;
#endif
return MPG123_OK;
}
double attribute_align_arg mpg123_geteq(mpg123_handle *mh, enum mpg123_channels channel, int band)
{
double ret = 0.;
#ifndef NO_EQUALIZER
/* Handle this gracefully. When there is no band, it has no volume. */
if(mh != NULL && band > -1 && band < 32)
@ -417,11 +419,10 @@ double attribute_align_arg mpg123_geteq(mpg123_handle *mh, enum mpg123_channels
case MPG123_RIGHT: ret = REAL_TO_DOUBLE(mh->equalizer[1][band]); break;
/* Default case is already handled: ret = 0 */
}
#endif
return ret;
}
/* plain file access, no http! */
int attribute_align_arg mpg123_open(mpg123_handle *mh, const char *path)
{
@ -1311,6 +1312,31 @@ int attribute_align_arg mpg123_set_filesize(mpg123_handle *mh, off_t size)
return MPG123_OK;
}
off_t attribute_align_arg mpg123_framelength(mpg123_handle *mh)
{
int b;
if(mh == NULL)
return MPG123_ERR;
b = init_track(mh);
if(b<0)
return b;
if(mh->track_frames > 0)
return mh->track_frames;
if(mh->rdat.filelen > 0)
{ /* A bad estimate. Ignoring tags 'n stuff. */
double bpf = mh->mean_framesize > 0.
? mh->mean_framesize
: compute_bpf(mh);
return (off_t)((double)(mh->rdat.filelen)/bpf+0.5);
}
/* Last resort: No view of the future, can at least count the frames that
were already parsed. */
if(mh->num > -1)
return mh->num+1;
/* Giving up. */
return MPG123_ERR;
}
off_t attribute_align_arg mpg123_length(mpg123_handle *mh)
{
int b;
@ -1338,6 +1364,7 @@ off_t attribute_align_arg mpg123_length(mpg123_handle *mh)
return length;
}
int attribute_align_arg mpg123_scan(mpg123_handle *mh)
{
int b;

View file

@ -750,7 +750,7 @@ int frame_cpu_opt(mpg123_handle *fr, const char* cpu)
# endif
# ifndef NO_REAL
fr->synths.plain[r_1to1][f_real] = synth_1to1_real_avx;
fr->synths.stereo[r_1to1][f_real] = synth_1to1_real_stereo_avx;
fr->synths.stereo[r_1to1][f_real] = synth_1to1_fltst_avx;
# endif
# ifndef NO_32BIT
fr->synths.plain[r_1to1][f_32] = synth_1to1_s32_avx;
@ -797,7 +797,7 @@ int frame_cpu_opt(mpg123_handle *fr, const char* cpu)
# endif
# ifndef NO_REAL
fr->synths.plain[r_1to1][f_real] = synth_1to1_real_altivec;
fr->synths.stereo[r_1to1][f_real] = synth_1to1_real_stereo_altivec;
fr->synths.stereo[r_1to1][f_real] = synth_1to1_fltst_altivec;
# endif
# ifndef NO_32BIT
fr->synths.plain[r_1to1][f_32] = synth_1to1_s32_altivec;
@ -861,11 +861,11 @@ int frame_cpu_opt(mpg123_handle *fr, const char* cpu)
# endif
# ifndef NO_REAL
fr->synths.plain[r_1to1][f_real] = synth_1to1_real_neon64;
fr->synths.stereo[r_1to1][f_real] = synth_1to1_real_stereo_neon64;
fr->synths.stereo[r_1to1][f_real] = synth_1to1_fltst_neon64;
# endif
# ifndef NO_32BIT
fr->synths.plain[r_1to1][f_32] = synth_1to1_s32_neon64;
fr->synths.stereo[r_1to1][f_32] = synth_1to1_s32_stereo_neon64;
fr->synths.stereo[r_1to1][f_32] = synth_1to1_s32st_neon64;
# endif
done = 1;
}

View file

@ -362,7 +362,7 @@ static int check_lame_tag(mpg123_handle *fr)
{
unsigned char gt = fr->bsbuf[lame_offset] >> 5;
unsigned char origin = (fr->bsbuf[lame_offset] >> 2) & 0x7;
float factor = (fr->bsbuf[lame_offset] & 0x2) ? -0.1 : 0.1;
float factor = (fr->bsbuf[lame_offset] & 0x2) ? -0.1f : 0.1f;
unsigned short gain = bit_read_short(fr->bsbuf, &lame_offset) & 0x1ff; /* 19 in (2 cycles) */
if(origin == 0 || gt < 1 || gt > 2) continue;
@ -1077,6 +1077,44 @@ static int handle_id3v2(mpg123_handle *fr, unsigned long newhead)
return PARSE_AGAIN;
}
static int handle_apetag(mpg123_handle *fr, unsigned long newhead)
{
unsigned char apebuf[28];
unsigned long val;
int i, ret;
fr->oldhead = 0;
/* Apetag headers are 32 bytes, newhead contains 4, read the rest */
if((ret=fr->rd->fullread(fr,apebuf,28)) < 0) return ret;
/* Apetags start with "APETAGEX", "APET" is already tested. */
if(strncmp((char *)apebuf,"AGEX",4) != 0)
goto apetag_bad;
/* Version must be 2.000 / 2000 */
val = (apebuf[7]<<24)|(apebuf[6]<<16)|(apebuf[5]<<8)|apebuf[4];
if(val != 2000)
goto apetag_bad;
/* Last 8 bytes must be 0 */
for(i=20; i<28; i++)
if(apebuf[i])
goto apetag_bad;
/* Looks good, skip the rest. */
val = (apebuf[11]<<24)|(apebuf[10]<<16)|(apebuf[9]<<8)|apebuf[8];
if((ret=fr->rd->skip_bytes(fr,val)) < 0) return ret;
return PARSE_AGAIN;
apetag_bad:
if(fr->rd->back_bytes(fr,31) < 0 && NOQUIET)
error("Cannot seek 31 bytes back!");
return PARSE_AGAIN; /* Give the resync code a chance to fix things */
}
/* Advance a byte in stream to get next possible header and forget
buffered data if possible (for feed reader). */
#define FORGET_INTERVAL 1024 /* Used by callers to set forget flag each <n> bytes. */
@ -1202,6 +1240,11 @@ static int wetwork(mpg123_handle *fr, unsigned long *newheadp)
{
return handle_id3v2(fr, newhead);
}
/* Check for an apetag header */
if(newhead == ('A'<<24)+('P'<<16)+('E'<<8)+'T')
{
return handle_apetag(fr, newhead);
}
else if(NOQUIET && fr->silent_resync == 0)
{
fprintf(stderr,"Note: Illegal Audio-MPEG-Header 0x%08lx at offset %"OFF_P".\n",

View file

@ -15,6 +15,7 @@
void attribute_align_arg mpg123_init_string(mpg123_string* sb)
{
/* Handing in NULL here is a fatal mistake and rightfully so. */
sb->p = NULL;
sb->size = 0;
sb->fill = 0;
@ -22,18 +23,24 @@ void attribute_align_arg mpg123_init_string(mpg123_string* sb)
void attribute_align_arg mpg123_free_string(mpg123_string* sb)
{
if(!sb)
return;
if(sb->p != NULL) free(sb->p);
mpg123_init_string(sb);
}
int attribute_align_arg mpg123_grow_string(mpg123_string* sb, size_t new)
{
if(!sb)
return 0;
if(sb->size < new) return mpg123_resize_string(sb, new);
else return 1;
}
int attribute_align_arg mpg123_resize_string(mpg123_string* sb, size_t new)
{
if(!sb)
return 0;
debug3("resizing string pointer %p from %lu to %lu", (void*) sb->p, (unsigned long)sb->size, (unsigned long)new);
if(new == 0)
{
@ -62,9 +69,10 @@ int attribute_align_arg mpg123_copy_string(mpg123_string* from, mpg123_string* t
{
size_t fill;
char *text;
if(to == NULL) return -1;
debug2("called copy_string with %p -> %p", (void*)from, (void*)to);
if(to == NULL)
return 0;
if(from == NULL)
{
fill = 0;
@ -88,12 +96,14 @@ int attribute_align_arg mpg123_copy_string(mpg123_string* from, mpg123_string* t
int attribute_align_arg mpg123_add_string(mpg123_string* sb, const char* stuff)
{
debug1("adding %s", stuff);
return mpg123_add_substring(sb, stuff, 0, strlen(stuff));
return mpg123_add_substring(sb, stuff, 0, stuff ? strlen(stuff) : 0);
}
int attribute_align_arg mpg123_add_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count)
{
debug("adding a substring");
if(!sb || !stuff)
return 0;
if(sb->fill) /* includes zero byte... */
{
if( (SIZE_MAX - sb->fill >= count) /* Avoid overflow. */
@ -120,12 +130,16 @@ int attribute_align_arg mpg123_add_substring(mpg123_string *sb, const char *stuf
int attribute_align_arg mpg123_set_substring(mpg123_string* sb, const char* stuff, size_t from, size_t count)
{
if(!sb)
return 0;
sb->fill = 0;
return mpg123_add_substring(sb, stuff, from, count);
}
int attribute_align_arg mpg123_set_string(mpg123_string* sb, const char* stuff)
{
if(!sb)
return 0;
sb->fill = 0;
return mpg123_add_string(sb, stuff);
}
@ -136,7 +150,7 @@ size_t attribute_align_arg mpg123_strlen(mpg123_string *sb, int utf8)
size_t bytelen;
/* Notions of empty string. If there's only a single character, it has to be the trailing zero, and if the first is the trailing zero anyway, we got empty. */
if(sb->fill < 2 || sb->p[0] == 0) return 0;
if(!sb || sb->fill < 2 || sb->p[0] == 0) return 0;
/* Find the first non-null character from the back.
We already established that the first character is non-null

View file

@ -75,8 +75,9 @@ int synth_1to1_i586_asm(real *bandPtr, int channel, unsigned char *out, unsigned
int synth_1to1_i586(real *bandPtr, int channel, mpg123_handle *fr, int final)
{
int ret;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
ret = synth_1to1_i586_asm(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, &fr->bo, fr->decwin);
if(final) fr->buffer.fill += 128;
return ret;
@ -91,8 +92,9 @@ int synth_1to1_i586_dither(real *bandPtr, int channel, mpg123_handle *fr, int fi
{
int ret;
int bo_dither[2]; /* Temporary workaround? Could expand the asm code. */
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
/* Applying this hack, to change the asm only bit by bit (adding dithernoise pointer). */
bo_dither[0] = fr->bo;
bo_dither[1] = fr->ditherindex;
@ -113,9 +115,9 @@ int synth_1to1_3dnow_asm(real *bandPtr, int channel, unsigned char *out, unsigne
int synth_1to1_3dnow(real *bandPtr, int channel, mpg123_handle *fr, int final)
{
int ret;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer_3dnow(bandPtr,channel,fr->equalizer);
#endif
/* this is in asm, can be dither or not */
/* uh, is this return from pointer correct? */
ret = (int) synth_1to1_3dnow_asm(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, &fr->bo, fr->decwin);
@ -130,8 +132,9 @@ int synth_1to1_MMX(real *bandPtr, int channel, short *out, short *buffs, int *bo
/* This is just a hull to use the mpg123 handle. */
int synth_1to1_mmx(real *bandPtr, int channel, mpg123_handle *fr, int final)
{
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
/* in asm */
synth_1to1_MMX(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins);
if(final) fr->buffer.fill += 128;
@ -152,9 +155,9 @@ int synth_1to1_sse(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -194,13 +197,13 @@ int synth_1to1_stereo_sse(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -235,8 +238,9 @@ void synth_1to1_sse_asm(real *bandPtr, int channel, short *samples, short *buffs
/* This is just a hull to use the mpg123 handle. */
int synth_1to1_sse(real *bandPtr, int channel, mpg123_handle *fr, int final)
{
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
synth_1to1_sse_asm(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins);
if(final) fr->buffer.fill += 128;
return 0;
@ -250,8 +254,9 @@ void synth_1to1_3dnowext_asm(real *bandPtr, int channel, short *samples, short *
/* This is just a hull to use the mpg123 handle. */
int synth_1to1_3dnowext(real *bandPtr, int channel, mpg123_handle *fr, int final)
{
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
synth_1to1_3dnowext_asm(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins);
if(final) fr->buffer.fill += 128;
return 0;
@ -272,9 +277,9 @@ int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -314,13 +319,13 @@ int synth_1to1_stereo_x86_64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -361,9 +366,9 @@ int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final)
short *b0, **buf;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -402,13 +407,13 @@ int synth_1to1_stereo_x86_64(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr)
short *b0l, *b0r, **bufl, **bufr;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->short_buffs[0];
@ -456,9 +461,9 @@ int synth_1to1_avx(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -498,13 +503,13 @@ int synth_1to1_stereo_avx(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -547,9 +552,9 @@ int synth_1to1_avx(real *bandPtr,int channel, mpg123_handle *fr, int final)
short *b0, **buf;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -588,13 +593,13 @@ int synth_1to1_stereo_avx(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr)
short *b0l, *b0r, **bufl, **bufr;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->short_buffs[0];
@ -638,9 +643,9 @@ int synth_1to1_arm(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -683,9 +688,9 @@ int synth_1to1_arm(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -734,9 +739,9 @@ int synth_1to1_neon(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -776,13 +781,13 @@ int synth_1to1_stereo_neon(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -823,9 +828,9 @@ int synth_1to1_neon(real *bandPtr,int channel, mpg123_handle *fr, int final)
short *b0, **buf;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -864,13 +869,13 @@ int synth_1to1_stereo_neon(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr)
short *b0l, *b0r, **bufl, **bufr;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->short_buffs[0];
@ -916,9 +921,9 @@ int synth_1to1_neon64(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -958,13 +963,13 @@ int synth_1to1_stereo_neon64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -1005,9 +1010,9 @@ int synth_1to1_neon64(real *bandPtr,int channel, mpg123_handle *fr, int final)
short *b0, **buf;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -1046,13 +1051,13 @@ int synth_1to1_stereo_neon64(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr)
short *b0l, *b0r, **bufl, **bufr;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->short_buffs[0];

View file

@ -262,9 +262,9 @@ int synth_1to1_altivec(real *bandPtr,int channel,mpg123_handle *fr, int final)
real *b0, **buf;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -393,13 +393,13 @@ int synth_1to1_stereo_altivec(real *bandPtr_l, real *bandPtr_r, mpg123_handle *f
real *b0l, *b0r, **bufl, **bufr;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -543,9 +543,9 @@ int synth_1to1_real_altivec(real *bandPtr,int channel,mpg123_handle *fr, int fin
real *b0, **buf;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -653,19 +653,19 @@ int synth_1to1_real_altivec(real *bandPtr,int channel,mpg123_handle *fr, int fin
return 0;
}
int synth_1to1_real_stereo_altivec(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
int synth_1to1_fltst_altivec(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
{
real *samples = (real *) (fr->buffer.data+fr->buffer.fill);
real *b0l, *b0r, **bufl, **bufr;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -772,9 +772,9 @@ int synth_1to1_s32_altivec(real *bandPtr,int channel,mpg123_handle *fr, int fina
real *b0, **buf;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -914,13 +914,13 @@ int synth_1to1_s32_stereo_altivec(real *bandPtr_l, real *bandPtr_r, mpg123_handl
real *b0l, *b0r, **bufl, **bufr;
int clip;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];

View file

@ -62,9 +62,9 @@ int synth_1to1_real_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int fin
real *b0, **buf;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -103,13 +103,13 @@ int synth_1to1_real_stereo_x86_64(real *bandPtr_l, real *bandPtr_r, mpg123_handl
real *b0l, *b0r, **bufl, **bufr;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -154,9 +154,9 @@ int synth_1to1_real_avx(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -189,19 +189,19 @@ int synth_1to1_real_avx(real *bandPtr,int channel, mpg123_handle *fr, int final)
return 0;
}
int synth_1to1_real_stereo_avx(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
int synth_1to1_fltst_avx(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
{
real *samples = (real *) (fr->buffer.data+fr->buffer.fill);
real *b0l, *b0r, **bufl, **bufr;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -244,9 +244,9 @@ int synth_1to1_real_sse(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -285,13 +285,13 @@ int synth_1to1_real_stereo_sse(real *bandPtr_l, real *bandPtr_r, mpg123_handle *
real *b0l, *b0r, **bufl, **bufr;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -334,9 +334,9 @@ int synth_1to1_real_neon(real *bandPtr,int channel, mpg123_handle *fr, int final
real *b0, **buf;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -374,13 +374,13 @@ int synth_1to1_real_stereo_neon(real *bandPtr_l, real *bandPtr_r, mpg123_handle
real *b0l, *b0r, **bufl, **bufr;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -423,9 +423,9 @@ int synth_1to1_real_neon64(real *bandPtr,int channel, mpg123_handle *fr, int fin
real *b0, **buf;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -457,19 +457,19 @@ int synth_1to1_real_neon64(real *bandPtr,int channel, mpg123_handle *fr, int fin
return 0;
}
int synth_1to1_real_stereo_neon64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
int synth_1to1_fltst_neon64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
{
real *samples = (real *) (fr->buffer.data+fr->buffer.fill);
real *b0l, *b0r, **bufl, **bufr;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];

View file

@ -59,9 +59,9 @@ int synth_1to1_s32_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int fina
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -102,13 +102,13 @@ int synth_1to1_s32_stereo_x86_64(real *bandPtr_l, real *bandPtr_r, mpg123_handle
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -154,9 +154,9 @@ int synth_1to1_s32_avx(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -197,13 +197,13 @@ int synth_1to1_s32_stereo_avx(real *bandPtr_l, real *bandPtr_r, mpg123_handle *f
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -247,9 +247,9 @@ int synth_1to1_s32_sse(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -290,13 +290,13 @@ int synth_1to1_s32_stereo_sse(real *bandPtr_l, real *bandPtr_r, mpg123_handle *f
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -340,9 +340,9 @@ int synth_1to1_s32_neon(real *bandPtr,int channel, mpg123_handle *fr, int final)
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -382,13 +382,13 @@ int synth_1to1_s32_stereo_neon(real *bandPtr_l, real *bandPtr_r, mpg123_handle *
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];
@ -432,9 +432,9 @@ int synth_1to1_s32_neon64(real *bandPtr,int channel, mpg123_handle *fr, int fina
real *b0, **buf;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
@ -467,20 +467,20 @@ int synth_1to1_s32_neon64(real *bandPtr,int channel, mpg123_handle *fr, int fina
return clip;
}
int synth_1to1_s32_stereo_neon64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
int synth_1to1_s32st_neon64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr)
{
int32_t *samples = (int32_t *) (fr->buffer.data+fr->buffer.fill);
real *b0l, *b0r, **bufl, **bufr;
int bo1;
int clip;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings)
{
do_equalizer(bandPtr_l,0,fr->equalizer);
do_equalizer(bandPtr_r,1,fr->equalizer);
}
#endif
fr->bo--;
fr->bo &= 0xf;
bufl = fr->real_buffs[0];

View file

@ -163,6 +163,21 @@ void make_decode_tables_mmx(mpg123_handle *fr)
#endif
#endif
#ifdef REAL_IS_FIXED
/* Need saturating multiplication that keeps table values in 32 bit range,
with the option to swap sign at will (so -2**31 is out).
This code is far from the decoder core and so assembly optimization might
be overkill. */
static int32_t sat_mul32(int32_t a, int32_t b)
{
int64_t prod = (int64_t)a * (int64_t)b;
/* TODO: record the clipping? An extra flag? */
if(prod > 2147483647L) return 2147483647L;
if(prod < -2147483647L) return -2147483647L;
return (int32_t)prod;
}
#endif
void make_decode_tables(mpg123_handle *fr)
{
int i,j;
@ -176,12 +191,23 @@ void make_decode_tables(mpg123_handle *fr)
debug1("decode tables with scaleval %g", scaleval);
#ifdef REAL_IS_FIXED
scaleval_long = DOUBLE_TO_REAL_15(scaleval);
debug1("decode table with fixed scaleval %li", (long)scaleval_long);
if(scaleval_long > 28618 || scaleval_long < -28618)
{
/* TODO: Limit the scaleval itself or limit the multiplication afterwards?
The former basically disables significant amplification for fixed-point
decoders, but avoids (possibly subtle) distortion. */
/* This would limit the amplification instead:
scaleval_long = scaleval_long < 0 ? -28618 : 28618; */
if(NOQUIET) warning("Desired amplification may introduce distortion.");
}
#endif
for(i=0,j=0;i<256;i++,j++,idx+=32)
{
if(idx < 512+16)
#ifdef REAL_IS_FIXED
fr->decwin[idx+16] = fr->decwin[idx] = REAL_SCALE_WINDOW(intwinbase[j] * scaleval_long);
fr->decwin[idx+16] = fr->decwin[idx] =
REAL_SCALE_WINDOW(sat_mul32(intwinbase[j],scaleval_long));
#else
fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval);
#endif
@ -200,7 +226,8 @@ void make_decode_tables(mpg123_handle *fr)
{
if(idx < 512+16)
#ifdef REAL_IS_FIXED
fr->decwin[idx+16] = fr->decwin[idx] = REAL_SCALE_WINDOW(intwinbase[j] * scaleval_long);
fr->decwin[idx+16] = fr->decwin[idx] =
REAL_SCALE_WINDOW(sat_mul32(intwinbase[j],scaleval_long));
#else
fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval);
#endif