Commit 736f90d8 authored by Alexandre Julliard's avatar Alexandre Julliard

mpg123: Import upstream release 1.32.2.

parent c5476595
......@@ -30,6 +30,8 @@ The creator: Michael Hipp (email: hippm@informatik.uni-tuebingen.de - please bot
Contributions/ideas Thomas Orgis era (includes backports from mhipp trunk):
Dave Yeo <dave.r.yeo@gmail.com>: continued OS/2 fixing
madebr and manx: github mirror and CI
Vitaly Kirsanov <krokoziabla@gmail.com>: ports/cmake (optional CMake build)
Won-Kyu Park <wkpark@gmail.com>: patch to get rid of asm textrels (x86 PIC)
Michael Weiser <michaelweiser@users.sf.net>: update of coreaudio output to AudioComponents API
......
......@@ -17,6 +17,7 @@ C_SRCS = \
src/libmpg123/layer1.c \
src/libmpg123/layer2.c \
src/libmpg123/layer3.c \
src/libmpg123/lfs_wrap.c \
src/libmpg123/libmpg123.c \
src/libmpg123/ntom.c \
src/libmpg123/optimize.c \
......
......@@ -20,10 +20,6 @@
/* Define if .align takes 3 for alignment of 2^3=8 bytes instead of 8. */
/* #undef ASMALIGN_EXP */
/* No suffixed symbols for large file support (only alias for backwards
compat.) */
#define BUILD_NO_LARGENAME 1
/* Define if __attribute__((aligned(16))) shall be used */
#define CCALIGN 1
......@@ -84,6 +80,9 @@
/* Define to 1 if you have the <byteswap.h> header file. */
/* #undef HAVE_BYTESWAP_H */
/* Define to 1 if you have the `clock_gettime' function. */
/* #undef HAVE_CLOCK_GETTIME */
/* Define to 1 if you have the <CoreServices/CoreServices.h> header file. */
/* #undef HAVE_CORESERVICES_CORESERVICES_H */
......@@ -144,15 +143,15 @@
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define to 1 if you have the `lseek64' function. */
/* #undef HAVE_LSEEK64 */
/* Define to 1 if you have the <machine/soundcard.h> header file. */
/* #undef HAVE_MACHINE_SOUNDCARD_H */
/* Define to 1 if you have the `mbstowcs' function. */
#define HAVE_MBSTOWCS 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mkfifo' function. */
/* #undef HAVE_MKFIFO */
......@@ -183,6 +182,9 @@
/* Define to 1 if you have the <os2.h> header file. */
/* #undef HAVE_OS2_H */
/* Define if O_LARGEFILE flag for open(2) exists. */
/* #undef HAVE_O_LARGEFILE */
/* Define to 1 if you have the `random' function. */
/* #undef HAVE_RANDOM */
......@@ -234,6 +236,9 @@
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the `strerror_l' function. */
/* #undef HAVE_STRERROR_L */
/* Define to 1 if you have the <strings.h> header file. */
/* #undef HAVE_STRINGS_H 1 */
......@@ -297,6 +302,9 @@
/* Define to 1 if you have the `unsetenv' function. */
/* #undef HAVE_UNSETENV */
/* Define to 1 if you have the `uselocale' function. */
/* #undef HAVE_USELOCALE */
/* Define to 1 if you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1
......@@ -330,9 +338,11 @@
/* Define if IPV6 support is enabled. */
#define IPV6 1
/* Define this to the size of native offset type in bits, used for LFS alias
functions. */
#define LFS_ALIAS_BITS 32
/* Define if we use _LARGEFILE64_SOURCE with off64_t and lseek64. */
/* #undef LFS_LARGEFILE_64 */
/* System redefines off_t when defining _FILE_OFFSET_BITS to 64. */
/* #undef LFS_SENSITIVE */
/* Define to the extension used for runtime loadable modules, say, ".so". */
#define LT_MODULE_EXT ".dll"
......@@ -429,7 +439,7 @@
#define PACKAGE_NAME "mpg123"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "mpg123 1.31.1"
#define PACKAGE_STRING "mpg123 1.32.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "mpg123"
......@@ -438,7 +448,10 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.31.1"
#define PACKAGE_VERSION "1.32.2"
/* Define to only include portable library API (no off_t, no internal I/O). */
/* #undef PORTABLE_API */
/* Define if portaudio v18 API is wanted. */
/* #undef PORTAUDIO18 */
......@@ -452,11 +465,8 @@
/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* The size of `off64_t', as computed by sizeof. */
#define SIZEOF_OFF64_T 8
/* The size of `off_t', as computed by sizeof. */
#define SIZEOF_OFF_T 8
#define SIZEOF_OFF_T 4
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 4
......@@ -464,7 +474,9 @@
/* The size of `ssize_t', as computed by sizeof. */
#define SIZEOF_SSIZE_T 4
/* Define to 1 if you have the ANSI C header files. */
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#define STDC_HEADERS 1
/* Define to not duplicate some code for likely cases in libsyn123. */
......@@ -480,7 +492,7 @@
/* #undef USE_YASM_FOR_AVX */
/* Version number of package */
#define VERSION "1.31.1"
#define VERSION "1.32.2"
/* Define to use Win32 named pipes */
#define WANT_WIN32_FIFO 1
......@@ -512,17 +524,6 @@
/* Define for extreme debugging. */
/* #undef XDEBUG */
/* 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. */
#define _FILE_OFFSET_BITS 64
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Windows Vista and later APIs */
/* #undef _WIN32_WINNT */
......@@ -544,11 +545,8 @@
/* 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 */
/* Define to `long' if <sys/types.h> does not define. */
/* #undef ptrdiff_t */
/* Define to `unsigned long' if <sys/types.h> does not define. */
/* #undef size_t */
......
......@@ -4,7 +4,7 @@
The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX.
So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-)
copyright 2007-2020 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2007-2023 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, Windows Unicode stuff by JonY.
*/
......@@ -43,23 +43,23 @@
#ifndef WINDOWS_UWP
char *compat_getenv(const char* name)
char *INT123_compat_getenv(const char* name)
{
char *ret = NULL;
#ifdef WANT_WIN32_UNICODE
wchar_t *env;
wchar_t *wname = NULL;
if(win32_utf8_wide(name, &wname, NULL) > 0)
if(INT123_win32_utf8_wide(name, &wname, NULL) > 0)
{
env = _wgetenv(wname);
free(wname);
if(env)
win32_wide_utf8(env, &ret, NULL);
INT123_win32_wide_utf8(env, &ret, NULL);
}
#else
ret = getenv(name);
if(ret)
ret = compat_strdup(ret);
ret = INT123_compat_strdup(ret);
#endif
return ret;
}
......@@ -69,7 +69,7 @@ char *compat_getenv(const char* name)
#include "wpathconv.h"
/* Always add a default permission mask in case of flags|O_CREAT. */
int compat_open(const char *filename, int flags)
int INT123_compat_open(const char *filename, int flags)
{
int ret;
#if defined (WANT_WIN32_UNICODE)
......@@ -105,8 +105,8 @@ open_ok:
}
/* Moved over from wav.c, logic with fallbacks added from the
example of compat_open(). */
FILE* compat_fopen(const char *filename, const char *mode)
example of INT123_compat_open(). */
FILE* INT123_compat_fopen(const char *filename, const char *mode)
{
FILE* stream = NULL;
#ifdef WANT_WIN32_UNICODE
......@@ -117,7 +117,7 @@ FILE* compat_fopen(const char *filename, const char *mode)
wname = u2wlongpath(filename);
if(!wname)
goto fopen_fallback;
cnt = win32_utf8_wide(mode, &wmode, NULL);
cnt = INT123_win32_utf8_wide(mode, &wmode, NULL);
if( (wmode == NULL) || (cnt == 0))
goto fopen_fallback;
......@@ -136,12 +136,12 @@ fopen_ok:
return stream;
}
FILE* compat_fdopen(int fd, const char *mode)
FILE* INT123_compat_fdopen(int fd, const char *mode)
{
return fdopen(fd, mode);
}
int compat_close(int infd)
int INT123_compat_close(int infd)
{
#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
return _close(infd);
......@@ -150,12 +150,12 @@ int compat_close(int infd)
#endif
}
int compat_fclose(FILE *stream)
int INT123_compat_fclose(FILE *stream)
{
return fclose(stream);
}
void compat_binmode(int fd, int enable)
void INT123_compat_binmode(int fd, int enable)
{
#if defined(HAVE__SETMODE)
_setmode(fd, enable ? _O_BINARY : _O_TEXT);
......@@ -179,7 +179,11 @@ void compat_binmode(int fd, int enable)
it late to some official APIs, that's still fine with us.
*/
char* compat_catpath(const char *prefix, const char* path)
#ifdef WANT_WIN32_UNICODE
typedef HRESULT (__stdcall *PCA_ptr)( const wchar_t *, const wchar_t*, unsigned long, wchar_t **);
#endif
char* INT123_compat_catpath(const char *prefix, const char* path)
{
char *ret = NULL;
#ifdef WANT_WIN32_UNICODE
......@@ -193,8 +197,7 @@ char* compat_catpath(const char *prefix, const char* path)
ThOr: I presume this hack is for supporting pre-8 Windows, as
from Windows 8 on, this is documented in the API.
*/
HRESULT (__stdcall *mypac)( const wchar_t *in, const wchar_t* more
, unsigned long flags, wchar_t **out ) = NULL;
PCA_ptr mypac = NULL;
HMODULE pathcch = NULL;
if(!prefix && !path)
......@@ -207,7 +210,7 @@ char* compat_catpath(const char *prefix, const char* path)
/* Again: I presume this whole fun is to get at PathAllocCombine
even when pathcch.h is not available (like in MinGW32). */
if( (pathcch = GetModuleHandleA("kernelbase")) )
mypac = (void *)GetProcAddress(pathcch, "PathAllocCombine");
mypac = (PCA_ptr) GetProcAddress(pathcch, "PathAllocCombine");
if(mypac) /* PATHCCH_ALLOW_LONG_PATH = 1 per API docs */
{
debug("Actually calling PathAllocCombine!");
......@@ -250,7 +253,7 @@ catpath_end:
return ret;
}
int compat_isdir(const char *path)
int INT123_compat_isdir(const char *path)
{
int ret = 0;
#ifdef WANT_WIN32_UNICODE
......@@ -286,7 +289,7 @@ struct compat_dir
#endif
};
struct compat_dir* compat_diropen(char *path)
struct compat_dir* INT123_compat_diropen(char *path)
{
struct compat_dir *cd;
if(!path)
......@@ -299,7 +302,7 @@ struct compat_dir* compat_diropen(char *path)
{
char *pattern;
wchar_t *wpattern;
pattern = compat_catpath(path, "*");
pattern = INT123_compat_catpath(path, "*");
wpattern = u2wlongpath(pattern);
if(wpattern)
{
......@@ -326,17 +329,17 @@ struct compat_dir* compat_diropen(char *path)
#endif
if(cd)
{
cd->path = compat_strdup(path);
cd->path = INT123_compat_strdup(path);
if(!cd->path)
{
compat_dirclose(cd);
INT123_compat_dirclose(cd);
cd = NULL;
}
}
return cd;
}
void compat_dirclose(struct compat_dir *cd)
void INT123_compat_dirclose(struct compat_dir *cd)
{
if(cd)
{
......@@ -350,7 +353,7 @@ void compat_dirclose(struct compat_dir *cd)
}
}
char* compat_nextfile(struct compat_dir *cd)
char* INT123_compat_nextfile(struct compat_dir *cd)
{
if(!cd)
return NULL;
......@@ -361,7 +364,7 @@ char* compat_nextfile(struct compat_dir *cd)
if(!(cd->d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
char *ret;
win32_wide_utf8(cd->d.cFileName, &ret, NULL);
INT123_win32_wide_utf8(cd->d.cFileName, &ret, NULL);
return ret;
}
}
......@@ -371,11 +374,11 @@ char* compat_nextfile(struct compat_dir *cd)
while((dp = readdir(cd->dir)))
{
struct stat fst;
char *fullpath = compat_catpath(cd->path, dp->d_name);
char *fullpath = INT123_compat_catpath(cd->path, dp->d_name);
if(fullpath && !stat(fullpath, &fst) && S_ISREG(fst.st_mode))
{
free(fullpath);
return compat_strdup(dp->d_name);
return INT123_compat_strdup(dp->d_name);
}
free(fullpath);
}
......@@ -384,7 +387,7 @@ char* compat_nextfile(struct compat_dir *cd)
return NULL;
}
char* compat_nextdir(struct compat_dir *cd)
char* INT123_compat_nextdir(struct compat_dir *cd)
{
if(!cd)
return NULL;
......@@ -395,7 +398,7 @@ char* compat_nextdir(struct compat_dir *cd)
if(cd->d.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
char *ret;
win32_wide_utf8(cd->d.cFileName, &ret, NULL);
INT123_win32_wide_utf8(cd->d.cFileName, &ret, NULL);
return ret;
}
}
......@@ -405,11 +408,11 @@ char* compat_nextdir(struct compat_dir *cd)
while((dp = readdir(cd->dir)))
{
struct stat fst;
char *fullpath = compat_catpath(cd->path, dp->d_name);
char *fullpath = INT123_compat_catpath(cd->path, dp->d_name);
if(fullpath && !stat(fullpath, &fst) && S_ISDIR(fst.st_mode))
{
free(fullpath);
return compat_strdup(dp->d_name);
return INT123_compat_strdup(dp->d_name);
}
free(fullpath);
}
......@@ -435,14 +438,14 @@ char* compat_nextdir(struct compat_dir *cd)
// because of a serious reason (maybe EOF, maybe out of disk space). You
// can inspect errno.
size_t unintr_write(int fd, void const *buffer, size_t bytes)
size_t INT123_unintr_write(int fd, void const *buffer, size_t bytes)
{
size_t written = 0;
errno = 0;
while(bytes)
{
errno = 0;
ssize_t part = write(fd, (char*)buffer+written, bytes);
ptrdiff_t part = write(fd, (char*)buffer+written, bytes);
// Just on short writes, we do not abort. Only when
// there was no successful operation (even zero write) at all.
// Any other error than EINTR ends things here.
......@@ -463,14 +466,14 @@ size_t unintr_write(int fd, void const *buffer, size_t bytes)
}
/* Same for reading the data. */
size_t unintr_read(int fd, void *buffer, size_t bytes)
size_t INT123_unintr_read(int fd, void *buffer, size_t bytes)
{
size_t got = 0;
errno = 0;
while(bytes)
{
errno = 0;
ssize_t part = read(fd, (char*)buffer+got, bytes);
ptrdiff_t part = read(fd, (char*)buffer+got, bytes);
if(part > 0) // == 0 is end of file
{
bytes -= part;
......@@ -486,7 +489,7 @@ size_t unintr_read(int fd, void *buffer, size_t bytes)
}
// and again for streams
size_t unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
size_t INT123_unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t written = 0;
errno = 0;
......@@ -506,7 +509,7 @@ size_t unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
#ifndef NO_CATCHSIGNAL
#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
void (*catchsignal(int signum, void(*handler)()))()
void (*INT123_catchsignal(int signum, void(*handler)(int)))(int)
{
struct sigaction new_sa;
struct sigaction old_sa;
......@@ -520,7 +523,7 @@ void (*catchsignal(int signum, void(*handler)()))()
sigemptyset(&new_sa.sa_mask);
new_sa.sa_flags = 0;
if(sigaction(signum, &new_sa, &old_sa) == -1)
return ((void (*)()) -1);
return ((void (*)(int)) -1); // Not rather NULL?
return (old_sa.sa_handler);
}
#endif
......
......@@ -6,7 +6,7 @@
It is envisioned to include this compat header instead of any of the "standard" headers, to catch compatibility issues.
So, don't include stdlib.h or string.h ... include compat.h.
copyright 2007-21 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2007-23 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
*/
......@@ -26,6 +26,8 @@
#include <stdlib.h>
#endif
#include <stddef.h>
#include <stdio.h>
#include <math.h>
......@@ -63,15 +65,34 @@
#ifndef SSIZE_MAX
#define SSIZE_MAX ((size_t)-1/2)
#endif
#ifndef PTRDIFF_MAX
#define PTRDIFF_MAX SSIZE_MAX
#endif
#ifndef ULONG_MAX
#define ULONG_MAX ((unsigned long)-1)
#endif
#ifndef INT64_MAX
#define INT64_MAX 9223372036854775807LL
#endif
#ifndef INT64_MIN
#define INT64_MIN (-INT64_MAX - 1)
#endif
#ifndef INT32_MAX
#define INT32_MAX 2147483647L
#endif
#ifndef INT32_MIN
#define INT32_MIN (-INT32_MAX - 1)
#endif
#ifndef OFF_MAX
#undef OFF_MIN
#if SIZEOF_OFF_T == 4
#define OFF_MAX ((uint32_t)-1/2)
#define OFF_MAX INT32_MAX
#define OFF_MIN INT32_MIN
#elif SIZEOF_OFF_T == 8
#define OFF_MAX ((uint64_t)-1/2)
#define OFF_MAX INT64_MAX
#define OFF_MIN INT64_MIN
#else
#error "Unexpected width of off_t."
#endif
......@@ -79,6 +100,7 @@
// Add two values (themselves assumed to be < limit), saturating to given limit.
#define SATURATE_ADD(inout, add, limit) inout = (limit-add >= inout) ? inout+add : limit;
#define SATURATE_SUB(inout, sub, limit) inout = (limit+sub >= inout) ? inout-sub : limit;
#ifdef HAVE_STRING_H
#include <string.h>
......@@ -99,7 +121,7 @@
#include <sys/select.h>
#endif
/* compat_open makes little sense without */
/* INT123_compat_open makes little sense without */
#include <fcntl.h>
/* To parse big numbers... */
......@@ -112,34 +134,21 @@
typedef unsigned char byte;
#if defined(_MSC_VER)
// For _setmode(), at least.
#include <io.h>
#if !defined(MPG123_DEF_SSIZE_T)
#define MPG123_DEF_SSIZE_T
#include <stddef.h>
typedef ptrdiff_t ssize_t;
#endif
#endif
// Not too early, leave system headers alone (strerror).
#include "intsym.h"
/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
void *safe_realloc(void *ptr, size_t size);
void *INT123_safe_realloc(void *ptr, size_t size);
// Also freeing ptr if result is NULL. You can do
// ptr = safer_realloc(ptr, size)
// Also, ptr = safer_realloc(ptr, 0) will do free(ptr); ptr=NULL;.
void *safer_realloc(void *ptr, size_t size);
#ifndef HAVE_STRERROR
const char *strerror(int errnum);
#endif
// ptr = INT123_safer_realloc(ptr, size)
// Also, ptr = INT123_safer_realloc(ptr, 0) will do free(ptr); ptr=NULL;.
void *INT123_safer_realloc(void *ptr, size_t size);
const char *INT123_strerror(int errnum);
/* Roll our own strdup() that does not depend on libc feature test macros
and returns NULL on NULL input instead of crashing. */
char* compat_strdup(const char *s);
char* INT123_compat_strdup(const char *s);
/* If we have the size checks enabled, try to derive some sane printfs.
Simple start: Use max integer type and format if long is not big enough.
......@@ -152,25 +161,21 @@ typedef intmax_t off_p;
typedef long off_p;
#endif
#if (defined SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > SIZEOF_LONG) && (defined PRIuMAX)
#if (defined SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > SIZEOF_LONG) && (defined PRIuMAX) && (defined PRIiMAX)
# define SIZE_P PRIuMAX
typedef uintmax_t size_p;
# define SSIZE_P PRIiMAX
typedef intmax_t ssize_p;
#else
# define SIZE_P "lu"
typedef unsigned long size_p;
#endif
#if (defined SIZEOF_SSIZE_T) && (SIZEOF_SSIZE_T > SIZEOF_LONG) && (defined PRIiMAX)
# define SSIZE_P PRIuMAX
typedef intmax_t ssize_p;
#else
# define SSIZE_P "li"
# define SSIZE_P "ld"
typedef long ssize_p;
#endif
/* Get an environment variable, possibly converted to UTF-8 from wide string.
The return value is a copy that you shall free. */
char *compat_getenv(const char* name);
char *INT123_compat_getenv(const char* name);
/**
* Opening a file handle can be different.
......@@ -179,12 +184,12 @@ char *compat_getenv(const char* name);
* @param[in] mbptr Pointer to multibyte string.
* @return file descriptor (>=0) or error code.
*/
int compat_open(const char *filename, int flags);
FILE* compat_fopen(const char *filename, const char *mode);
int INT123_compat_open(const char *filename, int flags);
FILE* INT123_compat_fopen(const char *filename, const char *mode);
/**
* Also fdopen to avoid having to define POSIX macros in various source files.
*/
FILE* compat_fdopen(int fd, const char *mode);
FILE* INT123_compat_fdopen(int fd, const char *mode);
/**
* Closing a file handle can be platform specific.
......@@ -192,8 +197,8 @@ FILE* compat_fdopen(int fd, const char *mode);
* @param[in] infd File descriptor to be closed.
* @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);
int INT123_compat_close(int infd);
int INT123_compat_fclose(FILE* stream);
/**
......@@ -201,7 +206,7 @@ int compat_fclose(FILE* stream);
* We do not bother with errors. This has to work.
* You can enable or disable binary mode.
*/
void compat_binmode(int fd, int enable);
void INT123_compat_binmode(int fd, int enable);
/* 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. */
......@@ -217,7 +222,7 @@ void compat_binmode(int fd, int enable);
*
* WideCharToMultiByte - http://msdn.microsoft.com/en-us/library/dd374130(VS.85).aspx
*/
int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen);
int INT123_win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen);
/**
* win32_uni2mbc
......@@ -230,7 +235,7 @@ int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen);
*
* WideCharToMultiByte - http://msdn.microsoft.com/en-us/library/dd374130(VS.85).aspx
*/
int win32_wide_utf7(const wchar_t * const wptr, char **mbptr, size_t * buflen);
int INT123_win32_wide_utf7(const wchar_t * const wptr, char **mbptr, size_t * buflen);
/**
* win32_mbc2uni
......@@ -244,7 +249,7 @@ int win32_wide_utf7(const wchar_t * const wptr, char **mbptr, size_t * buflen);
* MultiByteToWideChar - http://msdn.microsoft.com/en-us/library/dd319072(VS.85).aspx
*/
int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen);
int INT123_win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen);
#endif
/*
......@@ -270,11 +275,11 @@ int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen);
(meaning: for Windows), else they are preserved (on POSIX, actual
file system access would be needed because of symlinks).
*/
char* compat_catpath(const char *prefix, const char* path);
char* INT123_compat_catpath(const char *prefix, const char* path);
/* Return 1 if the given path indicates an existing directory,
0 otherwise. */
int compat_isdir(const char *path);
int INT123_compat_isdir(const char *path);
/*
Directory traversal. This talks ASCII/UTF-8 paths externally, converts
......@@ -286,14 +291,14 @@ struct compat_dir;
/* Returns NULL if either directory failed to open or listing is empty.
Listing can still be empty even if non-NULL, so always rely on the
nextfile/nextdir functions. */
struct compat_dir* compat_diropen(char *path);
void compat_dirclose(struct compat_dir*);
struct compat_dir* INT123_compat_diropen(char *path);
void INT123_compat_dirclose(struct compat_dir*);
/* Get the next entry that is a file (or symlink to one).
The returned string is a copy that needs to be freed after use. */
char* compat_nextfile(struct compat_dir*);
char* INT123_compat_nextfile(struct compat_dir*);
/* Get the next entry that is a directory (or symlink to one).
The returned string is a copy that needs to be freed after use. */
char* compat_nextdir (struct compat_dir*);
char* INT123_compat_nextdir (struct compat_dir*);
#ifdef USE_MODULES
/*
......@@ -303,17 +308,17 @@ char* compat_nextdir (struct compat_dir*);
Use of absolute paths is a good idea if you want to be sure which
file is openend, as default search paths vary.
*/
void *compat_dlopen (const char *path);
void *compat_dlsym (void *handle, const char* name);
void compat_dlclose(void *handle);
void *INT123_compat_dlopen (const char *path);
void *INT123_compat_dlsym (void *handle, const char* name);
void INT123_compat_dlclose(void *handle);
#endif
/* Blocking write/read of data with signal resilience.
They 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);
size_t unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
size_t INT123_unintr_write(int fd, void const *buffer, size_t bytes);
size_t INT123_unintr_read (int fd, void *buffer, size_t bytes);
size_t INT123_unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
/* OSX SDK defines an enum with "normal" as value. That clashes with
optimize.h */
......@@ -324,7 +329,7 @@ size_t unintr_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
#include "true.h"
#if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H)
void (*catchsignal(int signum, void(*handler)()))();
void (*INT123_catchsignal(int signum, void(*handler)(int)))(int);
#endif
#endif
......@@ -4,11 +4,13 @@
The mpg123 code is determined to keep it's legacy. A legacy of old, old UNIX.
So anything possibly somewhat advanced should be considered to be put here, with proper #ifdef;-)
copyright 2007-2016 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2007-2023 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, Windows Unicode stuff by JonY.
*/
// Need POSIX 2008 for uselocale stuff.
#define _POSIX_C_SOURCE 200809L
#include "compat.h"
/* Win32 is only supported with unicode now. These headers also cover
......@@ -20,10 +22,14 @@
#include <winnls.h>
#endif
#if HAVE_LOCALE_H
#include <locale.h>
#endif
#include "debug.h"
/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
void *safe_realloc(void *ptr, size_t size)
void *INT123_safe_realloc(void *ptr, size_t size)
{
if(ptr == NULL) return malloc(size);
else return realloc(ptr, size);
......@@ -31,25 +37,33 @@ void *safe_realloc(void *ptr, size_t size)
// A more sensible variant of realloc: It deallocates the original memory if
// realloc fails or if size zero was requested.
void *safer_realloc(void *ptr, size_t size)
void *INT123_safer_realloc(void *ptr, size_t size)
{
void *nptr = size ? safe_realloc(ptr, size) : NULL;
void *nptr = size ? INT123_safe_realloc(ptr, size) : NULL;
if(!nptr && ptr)
free(ptr);
return nptr;
}
#ifndef HAVE_STRERROR
const char *strerror(int errnum)
const char *INT123_strerror(int errnum)
{
#if defined(HAVE_STRERROR_L) && defined(HAVE_USELOCALE)
locale_t curloc = uselocale((locale_t)0);
if(curloc != LC_GLOBAL_LOCALE)
return strerror_l(errnum, curloc);
#endif
// Also fall back to strerror() in case of no set locale.
#if defined(HAVE_STRERROR)
return strerror(errnum);
#else
extern int sys_nerr;
extern char *sys_errlist[];
return (errnum < sys_nerr) ? sys_errlist[errnum] : "";
}
#endif
}
char* compat_strdup(const char *src)
char* INT123_compat_strdup(const char *src)
{
char *dest = NULL;
if(src)
......@@ -85,17 +99,17 @@ int win32_wide_common(const wchar_t * const wptr, char **mbptr, size_t * buflen,
return ret;
}
int win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen)
int INT123_win32_wide_utf8(const wchar_t * const wptr, char **mbptr, size_t * buflen)
{
return win32_wide_common(wptr, mbptr, buflen, CP_UTF8);
}
int win32_wide_utf7(const wchar_t * const wptr, char **mbptr, size_t * buflen)
int INT123_win32_wide_utf7(const wchar_t * const wptr, char **mbptr, size_t * buflen)
{
return win32_wide_common(wptr, mbptr, buflen, CP_UTF7);
}
int win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen)
int INT123_win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen)
{
size_t len;
wchar_t *buf;
......
......@@ -18,7 +18,7 @@
static wchar_t* u2wpath(const char *upath)
{
wchar_t* wpath, *p;
if(!upath || win32_utf8_wide(upath, &wpath, NULL) < 1)
if(!upath || INT123_win32_utf8_wide(upath, &wpath, NULL) < 1)
return NULL;
for(p=wpath; *p; ++p)
if(*p == L'/')
......@@ -26,17 +26,19 @@ static wchar_t* u2wpath(const char *upath)
return wpath;
}
#ifndef HIDE_w2upath
/* Convert Windows wide character paths to unix UTF-8. */
static char* w2upath(const wchar_t *wpath)
{
char* upath, *p;
if(!wpath || win32_wide_utf8(wpath, &upath, NULL) < 1)
if(!wpath || INT123_win32_wide_utf8(wpath, &upath, NULL) < 1)
return NULL;
for(p=upath; *p; ++p)
if(*p == '\\')
*p = '/';
return upath;
}
#endif
/* An absolute path that is too long and not already marked with
\\?\ can be marked as a long one and still work. */
......@@ -109,7 +111,7 @@ static wchar_t* u2wlongpath(const char *upath)
static wchar_t* u2wlongpath(const char *upath)
{
wchar_t* wpath, *p;
if (!upath || win32_utf8_wide(upath, &wpath, NULL) < 1)
if (!upath || INT123_win32_utf8_wide(upath, &wpath, NULL) < 1)
return NULL;
for (p = wpath; *p; ++p)
if (*p == L'/')
......
/*
abi_align: An attempt to avoid breakage because of mixing
compilers with different alignment.
abi_align: ABI and alignment stuff for library builds.
copyright 1995-2015 by the mpg123 project
Original use was the definitions for avoiding breakage because of mixing
compilers with different alignment. Then, the switchery for building
DLLs got lumped in.
copyright 1995-2023 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
......@@ -16,6 +19,12 @@
#include "config.h"
// Building any of our libs on/for Windows needs this before
// including the main API header (define MPG123_EXPORT).
#if defined(WIN32) && defined(DYNAMIC_BUILD)
#define BUILD_MPG123_DLL
#endif
/* ABI conformance for other compilers.
mpg123 needs 16byte-aligned (or more) stack for SSE and friends.
gcc provides that, but others don't necessarily. */
......
/*
dct64.c: DCT64, the plain C version
INT123_dct64.c: DCT64, the plain C version
copyright ?-2006 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
......@@ -19,7 +19,7 @@
#include "mpg123lib_intern.h"
void dct64(real *out0,real *out1,real *samples)
void INT123_dct64(real *out0,real *out1,real *samples)
{
real bufs[64];
......@@ -30,7 +30,7 @@ void dct64(real *out0,real *out1,real *samples)
b1 = samples;
bs = bufs;
costab = pnts[0]+16;
costab = INT123_pnts[0]+16;
b2 = b1 + 32;
for(i=15;i>=0;i--)
......@@ -39,7 +39,7 @@ void dct64(real *out0,real *out1,real *samples)
*bs++ = REAL_MUL((*--b2 - *b1++), *--costab);
b1 = bufs;
costab = pnts[1]+8;
costab = INT123_pnts[1]+8;
b2 = b1 + 16;
{
......@@ -57,7 +57,7 @@ void dct64(real *out0,real *out1,real *samples)
}
bs = bufs;
costab = pnts[2];
costab = INT123_pnts[2];
b2 = b1 + 8;
for(j=2;j;j--)
......@@ -75,7 +75,7 @@ void dct64(real *out0,real *out1,real *samples)
}
b1 = bufs;
costab = pnts[3];
costab = INT123_pnts[3];
b2 = b1 + 4;
for(j=4;j;j--)
......@@ -92,7 +92,7 @@ void dct64(real *out0,real *out1,real *samples)
b2 += 8;
}
bs = bufs;
costab = pnts[4];
costab = INT123_pnts[4];
for(j=8;j;j--)
{
......@@ -171,5 +171,3 @@ void dct64(real *out0,real *out1,real *samples)
out1[0x10*15] = REAL_SCALE_DCT64(bufs[16+15]);
}
/* Hack to allow building the same code with and without libtool. */
#include "intsym.h"
#include "dither_impl.h"
......@@ -18,6 +18,6 @@ enum mpg123_noise_type
};
void mpg123_noise(float* table, size_t count, enum mpg123_noise_type noisetype);
void dither_table_init(float *dithertable);
void INT123_dither_table_init(float *dithertable);
#endif
......@@ -113,7 +113,7 @@ void mpg123_noise(float* table, size_t count, enum mpg123_noise_type noisetype)
}
/* Generate white noise and shape it with a high pass filter. */
void dither_table_init(float *dithertable)
void INT123_dither_table_init(float *dithertable)
{
highpass_tpdf_noise(dithertable, DITHERSIZE);
}
......@@ -9,7 +9,7 @@
#include "mpg123lib_intern.h"
void do_equalizer(real *bandPtr,int channel, real equalizer[2][32])
void INT123_do_equalizer(real *bandPtr,int channel, real equalizer[2][32])
{
int i;
for(i=0;i<32;i++)
......
/*
format: routines to deal with audio (output) format
copyright 2008-20 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2008-23 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, starting with parts of the old audio.c, with only faintly manage to show now
......@@ -223,7 +223,7 @@ eend:
/* match constraints against supported audio formats, store possible setup in frame
return: -1: error; 0: no format change; 1: format change */
int frame_output_format(mpg123_handle *fr)
int INT123_frame_output_format(mpg123_handle *fr)
{
struct audioformat nf;
int f0=0;
......@@ -232,7 +232,7 @@ int frame_output_format(mpg123_handle *fr)
int try_float = (p->flags & MPG123_FLOAT_FALLBACK) ? 0 : 1;
/* initialize new format, encoding comes later */
nf.channels = fr->stereo;
mdebug("native frame format: %d ch @ %ld Hz", fr->stereo, frame_freq(fr));
mdebug("native frame format: %d ch @ %ld Hz", fr->stereo, INT123_frame_freq(fr));
// I intended the forcing stuff to be weaved into the format support table,
// but this probably will never happen, as this would change library behaviour.
// One could introduce an additional effective format table that takes for
......@@ -287,30 +287,30 @@ int frame_output_format(mpg123_handle *fr)
}
#endif
// Native decoder rate first.
if(enc_chan_fit(p, frame_freq(fr)>>p->down_sample, &nf, f0, f2, try_float))
if(enc_chan_fit(p, INT123_frame_freq(fr)>>p->down_sample, &nf, f0, f2, try_float))
goto end;
// Then downsamplings.
if(p->flags & MPG123_AUTO_RESAMPLE && p->down_sample < 2)
{
if(enc_chan_fit( p, frame_freq(fr)>>(p->down_sample+1), &nf
if(enc_chan_fit( p, INT123_frame_freq(fr)>>(p->down_sample+1), &nf
, f0, f2, try_float ))
goto end;
if(p->down_sample < 1 && enc_chan_fit( p, frame_freq(fr)>>2, &nf
if(p->down_sample < 1 && enc_chan_fit( p, INT123_frame_freq(fr)>>2, &nf
, f0, f2, try_float ))
goto end;
}
// And again the whole deal with float fallback.
if(!try_float)
{
if(enc_chan_fit(p, frame_freq(fr)>>p->down_sample, &nf, f0, f2, TRUE))
if(enc_chan_fit(p, INT123_frame_freq(fr)>>p->down_sample, &nf, f0, f2, TRUE))
goto end;
// Then downsamplings.
if(p->flags & MPG123_AUTO_RESAMPLE && p->down_sample < 2)
{
if(enc_chan_fit( p, frame_freq(fr)>>(p->down_sample+1), &nf
if(enc_chan_fit( p, INT123_frame_freq(fr)>>(p->down_sample+1), &nf
, f0, f2, TRUE ))
goto end;
if(p->down_sample < 1 && enc_chan_fit( p, frame_freq(fr)>>2, &nf
if(p->down_sample < 1 && enc_chan_fit( p, INT123_frame_freq(fr)>>2, &nf
, f0, f2, TRUE ))
goto end;
}
......@@ -320,7 +320,7 @@ int frame_output_format(mpg123_handle *fr)
if( p->flags & MPG123_AUTO_RESAMPLE && fr->p.down_sample == 0)
{
int i;
int rn = rate2num(p, frame_freq(fr));
int rn = rate2num(p, INT123_frame_freq(fr));
int rrn;
if(rn < 0) return 0;
/* Try higher rates first. */
......@@ -352,9 +352,9 @@ int frame_output_format(mpg123_handle *fr)
(p->flags & MPG123_FORCE_MONO ? "mono, " : "") )
, ( p->flags & MPG123_FORCE_FLOAT ? "float, " :
(p->flags & MPG123_FORCE_8BIT ? "8bit, " : "") )
, frame_freq(fr)>>p->down_sample
, frame_freq(fr)>>(p->down_sample ? p->down_sample : 1)
, frame_freq(fr)>>2 );
, INT123_frame_freq(fr)>>p->down_sample
, INT123_frame_freq(fr)>>(p->down_sample ? p->down_sample : 1)
, INT123_frame_freq(fr)>>2 );
/* if(NOQUIET && p->verbose <= 1) print_capabilities(fr); */
fr->err = MPG123_BAD_OUTFORMAT;
......@@ -549,7 +549,7 @@ int attribute_align_arg mpg123_fmt_support(mpg123_pars *mp, long rate, int encod
}
/* Call this one to ensure that any valid format will be something different than this. */
void invalidate_format(struct audioformat *af)
void INT123_invalidate_format(struct audioformat *af)
{
af->encoding = 0;
af->rate = 0;
......@@ -557,25 +557,25 @@ void invalidate_format(struct audioformat *af)
}
/* Number of bytes the decoder produces. */
off_t decoder_synth_bytes(mpg123_handle *fr, off_t s)
int64_t INT123_decoder_synth_bytes(mpg123_handle *fr, int64_t s)
{
return s * fr->af.dec_encsize * fr->af.channels;
}
/* Samples/bytes for output buffer after post-processing. */
/* take into account: channels, bytes per sample -- NOT resampling!*/
off_t samples_to_bytes(mpg123_handle *fr , off_t s)
int64_t INT123_samples_to_bytes(mpg123_handle *fr , int64_t s)
{
return s * fr->af.encsize * fr->af.channels;
}
off_t bytes_to_samples(mpg123_handle *fr , off_t b)
int64_t INT123_bytes_to_samples(mpg123_handle *fr , int64_t b)
{
return b / fr->af.encsize / fr->af.channels;
}
/* Number of bytes needed for decoding _and_ post-processing. */
off_t outblock_bytes(mpg123_handle *fr, off_t s)
int64_t INT123_outblock_bytes(mpg123_handle *fr, int64_t s)
{
int encsize = (fr->af.encoding & MPG123_ENC_24)
? 4 /* Intermediate 32 bit. */
......@@ -636,7 +636,7 @@ static void conv_s16_to_u16(struct outbuffer *buf)
#ifndef NO_REAL
static void conv_s16_to_f32(struct outbuffer *buf)
{
ssize_t i;
ptrdiff_t i;
int16_t *in = (int16_t*) buf->data;
float *out = (float*) buf->data;
size_t count = buf->fill/sizeof(int16_t);
......@@ -662,7 +662,7 @@ static void conv_s16_to_f32(struct outbuffer *buf)
#ifndef NO_32BIT
static void conv_s16_to_s32(struct outbuffer *buf)
{
ssize_t i;
ptrdiff_t i;
int16_t *in = (int16_t*) buf->data;
int32_t *out = (int32_t*) buf->data;
size_t count = buf->fill/sizeof(int16_t);
......@@ -699,7 +699,7 @@ void swap_endian(struct outbuffer *buf, int block)
}
}
void postprocess_buffer(mpg123_handle *fr)
void INT123_postprocess_buffer(mpg123_handle *fr)
{
/*
This caters for the final output formats that are never produced by
......
/*
frame: Central data structures and opmitization hooks.
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2007-2023 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
*/
......@@ -24,7 +24,7 @@
#ifdef OPT_DITHER
#include "dither.h"
int frame_dither_init(mpg123_handle *fr);
int INT123_frame_dither_init(mpg123_handle *fr);
#endif
/* max = 1728 */
......@@ -56,7 +56,7 @@ struct audioformat
long rate;
};
void invalidate_format(struct audioformat *af);
void INT123_invalidate_format(struct audioformat *af);
struct mpg123_pars_struct
{
......@@ -151,7 +151,7 @@ struct mpg123_handle_struct
#ifndef NO_NTOM
/* decode_ntom */
unsigned long ntom_val[2];
unsigned long INT123_ntom_val[2];
unsigned long ntom_step;
#endif
/* special i486 fun */
......@@ -188,7 +188,7 @@ struct mpg123_handle_struct
func_synth_stereo synth_stereo;
func_synth_mono synth_mono;
/* Yes, this function is runtime-switched, too. */
void (*make_decode_tables)(mpg123_handle *fr); /* That is the volume control. */
void (*INT123_make_decode_tables)(mpg123_handle *fr); /* That is the volume control. */
int stereo; /* I _think_ 1 for mono and 2 for stereo */
int jsbound;
......@@ -220,10 +220,10 @@ struct mpg123_handle_struct
int framesize; /* computed framesize */
int freesize; /* free format frame size */
enum mpg123_vbr vbr; /* 1 if variable bitrate was detected */
off_t num; /* frame offset ... */
off_t input_offset; /* byte offset of this frame in input stream */
off_t playnum; /* playback offset... includes repetitions, reset at seeks */
off_t audio_start; /* The byte offset in the file where audio data begins. */
int64_t num; /* frame offset ... */
int64_t input_offset; /* byte offset of this frame in input stream */
int64_t playnum; /* playback offset... includes repetitions, reset at seeks */
int64_t audio_start; /* The byte offset in the file where audio data begins. */
int state_flags;
char silent_resync; /* Do not complain for the next n resyncs. */
unsigned char* xing_toc; /* The seek TOC from Xing header. */
......@@ -250,10 +250,10 @@ struct mpg123_handle_struct
} rva;
/* input data */
off_t track_frames;
off_t track_samples;
int64_t track_frames;
int64_t track_samples;
double mean_framesize;
off_t mean_frames;
int64_t mean_frames;
int fsizeold;
int ssize;
unsigned int bitreservoir;
......@@ -277,18 +277,18 @@ struct mpg123_handle_struct
size_t outblock; /* number of bytes that this frame produces (upper bound) */
int to_decode; /* this frame holds data to be decoded */
int to_ignore; /* the same, somehow */
off_t firstframe; /* start decoding from here */
off_t lastframe; /* last frame to decode (for gapless or num_frames limit) */
off_t ignoreframe; /* frames to decode but discard before firstframe */
int64_t firstframe; /* start decoding from here */
int64_t lastframe; /* last frame to decode (for gapless or num_frames limit) */
int64_t ignoreframe; /* frames to decode but discard before firstframe */
#ifdef GAPLESS
off_t gapless_frames; /* frame count for the gapless part */
off_t firstoff; /* number of samples to ignore from firstframe */
off_t lastoff; /* number of samples to use from lastframe */
off_t begin_s; /* overall begin offset in samples */
off_t begin_os;
off_t end_s; /* overall end offset in samples */
off_t end_os;
off_t fullend_os; /* gapless_frames translated to output samples */
int64_t gapless_frames; /* frame count for the gapless part */
int64_t firstoff; /* number of samples to ignore from firstframe */
int64_t lastoff; /* number of samples to use from lastframe */
int64_t begin_s; /* overall begin offset in samples */
int64_t begin_os;
int64_t end_s; /* overall end offset in samples */
int64_t end_os;
int64_t fullend_os; /* gapless_frames translated to output samples */
#endif
unsigned int crc; /* Well, I need a safe 16bit type, actually. But wider doesn't hurt. */
struct reader *rd; /* pointer to the reading functions */
......@@ -342,8 +342,6 @@ struct mpg123_handle_struct
/* A place for storing additional data for the large file wrapper.
This is cruft! */
void *wrapperdata;
/* A callback used to properly destruct the wrapper data. */
void (*wrapperclean)(void*);
int enc_delay;
int enc_padding;
#ifndef NO_MOREINFO
......@@ -352,27 +350,27 @@ struct mpg123_handle_struct
};
/* generic init, does not include dynamic buffers */
void frame_init(mpg123_handle *fr);
void frame_init_par(mpg123_handle *fr, mpg123_pars *mp);
void INT123_frame_init(mpg123_handle *fr);
void INT123_frame_init_par(mpg123_handle *fr, mpg123_pars *mp);
/* output buffer and format */
int frame_outbuffer(mpg123_handle *fr);
int frame_output_format(mpg123_handle *fr);
int INT123_frame_outbuffer(mpg123_handle *fr);
int INT123_frame_output_format(mpg123_handle *fr);
int frame_buffers(mpg123_handle *fr); /* various decoder buffers, needed once */
int frame_reset(mpg123_handle* fr); /* reset for next track */
int frame_buffers_reset(mpg123_handle *fr);
void frame_exit(mpg123_handle *fr); /* end, free all buffers */
int INT123_frame_buffers(mpg123_handle *fr); /* various decoder buffers, needed once */
int INT123_frame_reset(mpg123_handle* fr); /* reset for next track */
int INT123_frame_buffers_reset(mpg123_handle *fr);
void INT123_frame_exit(mpg123_handle *fr); /* end, free all buffers */
/* Index functions... */
/* Well... print it... */
int mpg123_print_index(mpg123_handle *fr, FILE* out);
/* Find a seek position in index. */
off_t frame_index_find(mpg123_handle *fr, off_t want_frame, off_t* get_frame);
int64_t INT123_frame_index_find(mpg123_handle *fr, int64_t want_frame, int64_t* get_frame);
/* Apply index_size setting. */
int frame_index_setup(mpg123_handle *fr);
int INT123_frame_index_setup(mpg123_handle *fr);
void do_volume(mpg123_handle *fr, double factor);
void do_rva(mpg123_handle *fr);
void INT123_do_volume(mpg123_handle *fr, double factor);
void INT123_do_rva(mpg123_handle *fr);
/* samples per frame ...
Layer I
......@@ -396,20 +394,20 @@ MPEG 2.5
// The value is needed for mpg123_getstate() in any build.
#define GAPLESS_DELAY 529
#ifdef GAPLESS
void frame_gapless_init(mpg123_handle *fr, off_t framecount, off_t bskip, off_t eskip);
void frame_gapless_realinit(mpg123_handle *fr);
void frame_gapless_update(mpg123_handle *mh, off_t total_samples);
void INT123_frame_gapless_init(mpg123_handle *fr, int64_t framecount, int64_t bskip, int64_t eskip);
void INT123_frame_gapless_realinit(mpg123_handle *fr);
void INT123_frame_gapless_update(mpg123_handle *mh, int64_t total_samples);
/*void frame_gapless_position(mpg123_handle* fr);
void frame_gapless_bytify(mpg123_handle *fr);
void frame_gapless_ignore(mpg123_handle *fr, off_t frames);*/
void INT123_frame_gapless_bytify(mpg123_handle *fr);
void INT123_frame_gapless_ignore(mpg123_handle *fr, int64_t frames);*/
/* void frame_gapless_buffercheck(mpg123_handle *fr); */
#endif
/* Number of samples the decoding of the current frame should yield. */
off_t frame_expect_outsamples(mpg123_handle *fr);
int64_t INT123_frame_expect_outsamples(mpg123_handle *fr);
/* Skip this frame... do some fake action to get away without actually decoding it. */
void frame_skip(mpg123_handle *fr);
void INT123_frame_skip(mpg123_handle *fr);
/*
Seeking core functions:
......@@ -418,14 +416,14 @@ void frame_skip(mpg123_handle *fr);
- get leading frame offset for output sample offset
The offsets are "unadjusted"/internal; resampling is being taken care of.
*/
off_t frame_ins2outs(mpg123_handle *fr, off_t ins);
off_t frame_outs(mpg123_handle *fr, off_t num);
int64_t INT123_frame_ins2outs(mpg123_handle *fr, int64_t ins);
int64_t INT123_frame_outs(mpg123_handle *fr, int64_t num);
/* This one just computes the expected sample count for _this_ frame. */
off_t frame_expect_outsampels(mpg123_handle *fr);
off_t frame_offset(mpg123_handle *fr, off_t outs);
void frame_set_frameseek(mpg123_handle *fr, off_t fe);
void frame_set_seek(mpg123_handle *fr, off_t sp);
off_t frame_tell_seek(mpg123_handle *fr);
int64_t INT123_frame_expect_outsampels(mpg123_handle *fr);
int64_t INT123_frame_offset(mpg123_handle *fr, int64_t outs);
void INT123_frame_set_frameseek(mpg123_handle *fr, int64_t fe);
void INT123_frame_set_seek(mpg123_handle *fr, int64_t sp);
int64_t INT123_frame_tell_seek(mpg123_handle *fr);
/* Take a copy of the Xing VBR TOC for fuzzy seeking. */
int frame_fill_toc(mpg123_handle *fr, unsigned char* in);
int INT123_frame_fill_toc(mpg123_handle *fr, unsigned char* in);
#endif
/*
sampleadjust: gapless sample offset math
copyright 1995-2012 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 1995-2023 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
This is no stand-alone header, precisely to be able to fool it into using fake handle types for testing the math.
......@@ -11,9 +11,9 @@
#ifdef GAPLESS
/* From internal sample number to external. */
static off_t sample_adjust(mpg123_handle *mh, off_t x)
static int64_t sample_adjust(mpg123_handle *mh, int64_t x)
{
off_t s;
int64_t s;
if(mh->p.flags & MPG123_GAPLESS)
{
/* It's a bit tricky to do this computation for the padding samples.
......@@ -35,9 +35,9 @@ static off_t sample_adjust(mpg123_handle *mh, off_t x)
}
/* from external samples to internal */
static off_t sample_unadjust(mpg123_handle *mh, off_t x)
static int64_t sample_unadjust(mpg123_handle *mh, int64_t x)
{
off_t s;
int64_t s;
if(mh->p.flags & MPG123_GAPLESS)
{
s = x + mh->begin_os;
......@@ -74,24 +74,29 @@ static void frame_buffercheck(mpg123_handle *fr)
if(fr->lastframe > -1 && fr->num >= fr->lastframe)
{
/* There can be more than one frame of padding at the end, so we ignore the whole frame if we are beyond lastframe. */
off_t byteoff = (fr->num == fr->lastframe) ? samples_to_bytes(fr, fr->lastoff) : 0;
if((off_t)fr->buffer.fill > byteoff)
int64_t byteoff = (fr->num == fr->lastframe) ? INT123_samples_to_bytes(fr, fr->lastoff) : 0;
if((int64_t)fr->buffer.fill > byteoff)
{
fr->buffer.fill = byteoff;
}
if(VERBOSE3) fprintf(stderr, "\nNote: Cut frame %"OFF_P" buffer on end of stream to %"OFF_P" samples, fill now %"SIZE_P" bytes.\n", (off_p)fr->num, (off_p)(fr->num == fr->lastframe ? fr->lastoff : 0), (size_p)fr->buffer.fill);
if(VERBOSE3)
fprintf(stderr, "\nNote: Cut frame %" PRIi64 " buffer on end of stream to %"
PRIi64 " samples, fill now %"SIZE_P" bytes.\n"
, fr->num, (fr->num == fr->lastframe ? fr->lastoff : 0), (size_p)fr->buffer.fill);
}
/* The first interesting frame: Skip some leading samples. */
if(fr->firstoff && fr->num == fr->firstframe)
{
off_t byteoff = samples_to_bytes(fr, fr->firstoff);
if((off_t)fr->buffer.fill > byteoff)
int64_t byteoff = INT123_samples_to_bytes(fr, fr->firstoff);
if((int64_t)fr->buffer.fill > byteoff)
{
fr->buffer.fill -= byteoff;
/* buffer.p != buffer.data only for own buffer */
debug6("cutting %li samples/%li bytes on begin, own_buffer=%i at %p=%p, buf[1]=%i",
(long)fr->firstoff, (long)byteoff, fr->own_buffer, (void*)fr->buffer.p, (void*)fr->buffer.data, ((short*)fr->buffer.p)[2]);
debug6("cutting %" PRIi64 " samples/%" PRIi64
" bytes on begin, own_buffer=%i at %p=%p, buf[1]=%i"
, fr->firstoff, byteoff, fr->own_buffer
, (void*)fr->buffer.p, (void*)fr->buffer.data, ((short*)fr->buffer.p)[2]);
if(fr->own_buffer) fr->buffer.p = fr->buffer.data + byteoff;
else memmove(fr->buffer.data, fr->buffer.data + byteoff, fr->buffer.fill);
debug3("done cutting, buffer at %p =? %p, buf[1]=%i",
......@@ -99,7 +104,10 @@ static void frame_buffercheck(mpg123_handle *fr)
}
else fr->buffer.fill = 0;
if(VERBOSE3) fprintf(stderr, "\nNote: Cut frame %"OFF_P" buffer on beginning of stream by %"OFF_P" samples, fill now %"SIZE_P" bytes.\n", (off_p)fr->num, (off_p)fr->firstoff, (size_p)fr->buffer.fill);
if(VERBOSE3)
fprintf(stderr, "\nNote: Cut frame %" PRIi64
" buffer on beginning of stream by %" PRIi64 " samples, fill now %zu bytes.\n"
, fr->num, fr->firstoff, fr->buffer.fill);
/* We can only reach this frame again by seeking. And on seeking, firstoff will be recomputed.
So it is safe to null it here (and it makes the if() decision abort earlier). */
fr->firstoff = 0;
......
......@@ -42,7 +42,9 @@ struct cpuflags
#endif
};
unsigned int getcpuflags(struct cpuflags* cf);
unsigned int INT123_getcpuflags(struct cpuflags* cf);
#if ((defined OPT_X86) || (defined OPT_X86_64) || (defined OPT_NEON) || (defined OPT_NEON64)) && (defined OPT_MULTI)
#ifdef WANT_GETCPUFLAGS
#include <string.h>
......@@ -51,16 +53,10 @@ unsigned int getcpuflags(struct cpuflags* cf);
static unsigned int wrap_getcpuflags(struct cpuflags* cf)
{
memset(cf, 0, sizeof(*cf));
#if ((defined OPT_X86) || (defined OPT_X86_64) || (defined OPT_NEON) || (defined OPT_NEON64)) && (defined OPT_MULTI)
return getcpuflags(cf);
#else
return 0;
#endif
return INT123_getcpuflags(cf);
}
#endif
#if ((defined OPT_X86) || (defined OPT_X86_64) || (defined OPT_NEON) || (defined OPT_NEON64)) && (defined OPT_MULTI)
// We really evaluate the CPU flags.
#define OPT_CPU_FLAGS
......
/*
icy: Puny code to pretend for a serious ICY data structure.
copyright 2007-2015 by the mpg123 project
copyright 2007-2023 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)
void INT123_init_icy(struct icy_meta *icy)
{
icy->data = NULL;
}
void clear_icy(struct icy_meta *icy)
void INT123_clear_icy(struct icy_meta *icy)
{
if(icy->data != NULL) free(icy->data);
init_icy(icy);
INT123_init_icy(icy);
}
void reset_icy(struct icy_meta *icy)
void INT123_reset_icy(struct icy_meta *icy)
{
clear_icy(icy);
init_icy(icy);
INT123_clear_icy(icy);
INT123_init_icy(icy);
}
/*void set_icy(struct icy_meta *icy, char* new_data)
{
......
/*
icy: support for SHOUTcast ICY meta info, an attempt to keep it organized
copyright 2006-7 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2006-2023 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 and modelled after patch by Honza
*/
......@@ -16,22 +16,22 @@
struct icy_meta
{
char* data;
off_t interval;
off_t next;
int64_t interval;
int64_t next;
};
void init_icy(struct icy_meta *);
void clear_icy(struct icy_meta *);
void reset_icy(struct icy_meta *);
void INT123_init_icy(struct icy_meta *);
void INT123_clear_icy(struct icy_meta *);
void INT123_reset_icy(struct icy_meta *);
#else
#undef init_icy
#define init_icy(a)
#undef clear_icy
#define clear_icy(a)
#undef reset_icy
#define reset_icy(a)
#undef INT123_init_icy
#define INT123_init_icy(a)
#undef INT123_clear_icy
#define INT123_clear_icy(a)
#undef INT123_reset_icy
#define INT123_reset_icy(a)
#endif /* NO_ICY */
......
......@@ -27,7 +27,6 @@
*/
#include "config.h"
#include "intsym.h"
/* Includes string and stdlib headers... */
#include "compat.h"
......@@ -375,7 +374,7 @@ is_utf8(const char* src)
ICY in CP-1252 (or UTF-8 alreay) to UTF-8 encoded string.
If force is applied, it will always encode to UTF-8, without checking. */
char *
icy2utf8(const char *src, int force)
INT123_icy2utf8(const char *src, int force)
{
const uint8_t *s = (const uint8_t *)src;
size_t srclen, dstlen, i, k;
......@@ -384,7 +383,7 @@ icy2utf8(const char *src, int force)
/* Some funny streams from Apple/iTunes give ICY info in UTF-8 already.
So, be prepared and don't try to re-encode such. Unless forced. */
if(!force && is_utf8(src)) return (compat_strdup(src));
if(!force && is_utf8(src)) return (INT123_compat_strdup(src));
srclen = strlen(src) + 1;
/* allocate conservatively */
......@@ -419,13 +418,13 @@ main(void)
{
char *t, *t2;
if ((t = icy2utf8(intext, 0)) == NULL) {
if ((t = INT123_icy2utf8(intext, 0)) == NULL) {
fprintf(stderr, "out of memory\n");
return (1);
}
/* make sure it won't be converted twice */
if ((t2 = icy2utf8(t), 0) == NULL) {
if ((t2 = INT123_icy2utf8(t), 0) == NULL) {
fprintf(stderr, "out of memory\n");
return (1);
}
......
......@@ -4,7 +4,7 @@
#ifndef NO_ICY
/* (string, force conversion) */
char *icy2utf8(const char *, int);
char *INT123_icy2utf8(const char *, int);
#endif
#endif
/*
id3: ID3v2.3 and ID3v2.4 parsing (a relevant subset)
copyright 2006-2020 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2006-2023 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
......@@ -126,7 +126,7 @@ static void null_id3_links(mpg123_handle *fr)
fr->id3v2.comment = NULL;
}
void init_id3(mpg123_handle *fr)
void INT123_init_id3(mpg123_handle *fr)
{
fr->id3v2.version = 0; /* nothing there */
null_id3_links(fr);
......@@ -241,7 +241,7 @@ static mpg123_text *add_id3_text( mpg123_text **list, size_t *size
}
mdebug("add_id3_text: append to list of %zu", *size);
// Nothing found, add new one.
mpg123_text *x = safe_realloc(*list, sizeof(mpg123_text)*(*size+1));
mpg123_text *x = INT123_safe_realloc(*list, sizeof(mpg123_text)*(*size+1));
if(x == NULL) return NULL; /* bad */
*list = x;
......@@ -269,7 +269,7 @@ static mpg123_picture *add_id3_picture(mpg123_picture **list, size_t *size, char
return entry;
}
// Append a new one.
mpg123_picture *x = safe_realloc(*list, sizeof(mpg123_picture)*(*size+1));
mpg123_picture *x = INT123_safe_realloc(*list, sizeof(mpg123_picture)*(*size+1));
if(x == NULL) return NULL; /* bad */
*list = x;
......@@ -281,7 +281,7 @@ static mpg123_picture *add_id3_picture(mpg123_picture **list, size_t *size, char
/* OK, back to the higher level functions. */
void exit_id3(mpg123_handle *fr)
void INT123_exit_id3(mpg123_handle *fr)
{
free_picture(fr);
free_comment(fr);
......@@ -289,14 +289,14 @@ void exit_id3(mpg123_handle *fr)
free_text(fr);
}
void reset_id3(mpg123_handle *fr)
void INT123_reset_id3(mpg123_handle *fr)
{
exit_id3(fr);
init_id3(fr);
INT123_exit_id3(fr);
INT123_init_id3(fr);
}
/* Set the id3v2.artist id3v2.title ... links to elements of the array. */
void id3_link(mpg123_handle *fr)
void INT123_id3_link(mpg123_handle *fr)
{
size_t i;
mpg123_id3v2 *v2 = &fr->id3v2;
......@@ -363,7 +363,7 @@ static void store_id3_text(mpg123_string *sb, unsigned char *source, size_t sour
error1("Unknown text encoding %u, I take no chances, sorry!", encoding);
return;
}
id3_to_utf8(sb, encoding, source+1, source_size-1, noquiet);
INT123_id3_to_utf8(sb, encoding, source+1, source_size-1, noquiet);
if(sb->fill) debug1("UTF-8 string (the first one): %s", sb->p);
else if(noquiet) error("unable to convert string to UTF-8 (out of memory, junk input?)!");
......@@ -371,7 +371,7 @@ static void store_id3_text(mpg123_string *sb, unsigned char *source, size_t sour
/* On error, sb->size is 0. */
/* Also, encoding has been checked already! */
void id3_to_utf8(mpg123_string *sb, unsigned char encoding, const unsigned char *source, size_t source_size, int noquiet)
void INT123_id3_to_utf8(mpg123_string *sb, unsigned char encoding, const unsigned char *source, size_t source_size, int noquiet)
{
unsigned int bwidth;
if(sb)
......@@ -403,9 +403,12 @@ static unsigned char *next_text(unsigned char* prev, unsigned char encoding, siz
unsigned char *text = prev;
size_t width = encoding_widths[encoding];
if(limit > PTRDIFF_MAX)
return NULL;
/* So I go lengths to find zero or double zero...
Remember bug 2834636: Only check for aligned NULLs! */
while(text-prev < (ssize_t)limit)
while(text-prev < (ptrdiff_t)limit)
{
if(text[0] == 0)
{
......@@ -494,7 +497,7 @@ static void process_picture(mpg123_handle *fr, unsigned char *realdata, size_t r
error("Unable to get mime type for picture; skipping picture.");
return;
}
id3_to_utf8(&mime, 0, realdata, workpoint - realdata, NOQUIET);
INT123_id3_to_utf8(&mime, 0, realdata, workpoint - realdata, NOQUIET);
realsize -= workpoint - realdata;
realdata = workpoint;
/* get picture type */
......@@ -509,7 +512,7 @@ static void process_picture(mpg123_handle *fr, unsigned char *realdata, size_t r
mpg123_free_string(&mime);
return;
}
id3_to_utf8(&description, encoding, realdata, workpoint - realdata, NOQUIET);
INT123_id3_to_utf8(&description, encoding, realdata, workpoint - realdata, NOQUIET);
realsize -= workpoint - realdata;
if(realsize)
image_data = (unsigned char*)malloc(realsize);
......@@ -795,7 +798,7 @@ int store_id3v2( mpg123_handle *fr
, unsigned long first4bytes, unsigned char buf[6], unsigned long length )
{
int ret = 1;
off_t ret2;
int64_t ret2;
unsigned long fullen = 10+length;
if(fr->id3v2_raw)
free(fr->id3v2_raw);
......@@ -842,7 +845,7 @@ int store_id3v2( mpg123_handle *fr
1: good, (possibly) new tag info
<0: reader error (may need more data feed, try again)
*/
int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
int INT123_parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
{
#define UNSYNC_FLAG 128
#define EXTHEAD_FLAG 64 /* ID3v2.3+ */
......@@ -855,7 +858,7 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
unsigned long length=0;
unsigned char flags = 0;
int ret = 1;
off_t ret2;
int64_t ret2;
int storetag = 0;
unsigned int footlen = 0;
#ifndef NO_ID3V2
......@@ -961,7 +964,7 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
{
if(VERBOSE3)
fprintf(stderr, "Note: skipped tag clearing possibly existing ID3v2 data");
reset_id3(fr); // Old data is invalid.
INT123_reset_id3(fr); // Old data is invalid.
#endif
if(!storetag && (ret2=fr->rd->skip_bytes(fr,length+footlen))<0)
ret=ret2;
......@@ -1025,7 +1028,7 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
{
if(VERBOSE3)
fprintf(stderr, "Note: non-update tag replacing existing ID3v2 data\n");
reset_id3(fr);
INT123_reset_id3(fr);
}
if(ret > 0)
{
......@@ -1274,13 +1277,13 @@ int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes)
{
if(VERBOSE3)
fprintf(stderr, "Note: faulty ID3v2 tag still clearing old data\n");
reset_id3(fr);
INT123_reset_id3(fr);
}
} else // No new data, but still there was a tag that invalidates old data.
{
if(VERBOSE3)
fprintf(stderr, "Note: empty ID3v2 clearing old data\n");
reset_id3(fr);
INT123_reset_id3(fr);
}
tagparse_cleanup:
/* Get rid of stored raw data that should not be kept. */
......
......@@ -13,31 +13,31 @@
#include "frame.h"
#ifdef NO_ID3V2
# ifdef init_id3
# undef init_id3
# ifdef INT123_init_id3
# undef INT123_init_id3
# endif
# define init_id3(fr)
# ifdef exit_id3
# undef exit_id3
# define INT123_init_id3(fr)
# ifdef INT123_exit_id3
# undef INT123_exit_id3
# endif
# define exit_id3(fr)
# ifdef reset_id3
# undef reset_id3
# define INT123_exit_id3(fr)
# ifdef INT123_reset_id3
# undef INT123_reset_id3
# endif
# define reset_id3(fr)
# ifdef id3_link
# undef id3_link
# define INT123_reset_id3(fr)
# ifdef INT123_id3_link
# undef INT123_id3_link
# endif
# define id3_link(fr)
# define INT123_id3_link(fr)
#else
void init_id3(mpg123_handle *fr);
void exit_id3(mpg123_handle *fr);
void reset_id3(mpg123_handle *fr);
void id3_link(mpg123_handle *fr);
void INT123_init_id3(mpg123_handle *fr);
void INT123_exit_id3(mpg123_handle *fr);
void INT123_reset_id3(mpg123_handle *fr);
void INT123_id3_link(mpg123_handle *fr);
#endif
int parse_new_id3(mpg123_handle *fr, unsigned long first4bytes);
int INT123_parse_new_id3(mpg123_handle *fr, unsigned long first4bytes);
/* Convert text from some ID3 encoding to UTf-8.
On error, sb->fill is 0. The noquiet flag enables warning/error messages. */
void id3_to_utf8(mpg123_string *sb, unsigned char encoding, const unsigned char *source, size_t source_size, int noquiet);
void INT123_id3_to_utf8(mpg123_string *sb, unsigned char encoding, const unsigned char *source, size_t source_size, int noquiet);
#endif
/*
index: frame index data structure and functions
copyright 2007-2020 by the mpg123 project
copyright 2007-2023 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"
/* The next expected frame offset, one step ahead. */
static off_t fi_next(struct frame_index *fi)
static int64_t fi_next(struct frame_index *fi)
{
return (off_t)fi->fill*fi->step;
return (int64_t)fi->fill*fi->step;
}
/* Shrink down the used index to the half.
......@@ -36,7 +35,7 @@ static void fi_shrink(struct frame_index *fi)
fi->next = fi_next(fi);
}
void fi_init(struct frame_index *fi)
void INT123_fi_init(struct frame_index *fi)
{
fi->data = NULL;
fi->step = 1;
......@@ -46,17 +45,17 @@ void fi_init(struct frame_index *fi)
fi->next = fi_next(fi);
}
void fi_exit(struct frame_index *fi)
void INT123_fi_exit(struct frame_index *fi)
{
debug2("fi_exit: %p and %lu", (void*)fi->data, (unsigned long)fi->size);
debug2("INT123_fi_exit: %p and %lu", (void*)fi->data, (unsigned long)fi->size);
if(fi->size && fi->data != NULL) free(fi->data);
fi_init(fi); /* Be prepared for further fun, still. */
INT123_fi_init(fi); /* Be prepared for further fun, still. */
}
int fi_resize(struct frame_index *fi, size_t newsize)
int INT123_fi_resize(struct frame_index *fi, size_t newsize)
{
off_t *newdata = NULL;
int64_t *newdata = NULL;
if(newsize == fi->size) return 0;
if(newsize > 0 && newsize < fi->size)
......@@ -64,7 +63,7 @@ int fi_resize(struct frame_index *fi, size_t newsize)
while(fi->fill > newsize){ fi_shrink(fi); }
}
newdata = safe_realloc(fi->data, newsize*sizeof(off_t));
newdata = INT123_safe_realloc(fi->data, newsize*sizeof(int64_t));
if(newsize == 0 || newdata != NULL)
{
fi->data = newdata;
......@@ -78,15 +77,15 @@ int fi_resize(struct frame_index *fi, size_t newsize)
return -1;
}
void fi_add(struct frame_index *fi, off_t pos)
void INT123_fi_add(struct frame_index *fi, int64_t pos)
{
debug3("wanting to add to fill %lu, step %lu, size %lu", (unsigned long)fi->fill, (unsigned long)fi->step, (unsigned long)fi->size);
if(fi->fill == fi->size)
{ /* Index is full, we need to shrink... or grow. */
/* Store the current frame number to check later if we still want it. */
off_t framenum = fi->fill*fi->step;
int64_t framenum = fi->fill*fi->step;
/* If we want not / cannot grow, we shrink. */
if( !(fi->grow_size && fi_resize(fi, fi->size+fi->grow_size)==0) )
if( !(fi->grow_size && INT123_fi_resize(fi, fi->size+fi->grow_size)==0) )
fi_shrink(fi);
/* Now check if we still want to add this frame (could be that not, because of changed step). */
......@@ -103,13 +102,13 @@ void fi_add(struct frame_index *fi, off_t pos)
}
}
int fi_set(struct frame_index *fi, off_t *offsets, off_t step, size_t fill)
int INT123_fi_set(struct frame_index *fi, int64_t *offsets, int64_t step, size_t fill)
{
if(fi_resize(fi, fill) == -1) return -1;
if(INT123_fi_resize(fi, fill) == -1) return -1;
fi->step = step;
if(offsets != NULL)
{
memcpy(fi->data, offsets, fill*sizeof(off_t));
memcpy(fi->data, offsets, fill*sizeof(int64_t));
fi->fill = fill;
}
else
......@@ -123,7 +122,7 @@ int fi_set(struct frame_index *fi, off_t *offsets, off_t step, size_t fill)
return 0;
}
void fi_reset(struct frame_index *fi)
void INT123_fi_reset(struct frame_index *fi)
{
debug1("reset with size %"SIZE_P, (size_p)fi->size);
fi->fill = 0;
......
......@@ -15,7 +15,7 @@
In this manner we maintain a good resolution with the given
maximum index size while covering the whole stream.
copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 2007-2023 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
*/
......@@ -25,35 +25,35 @@
struct frame_index
{
off_t *data; /* actual data, the frame positions */
off_t step; /* advancement in frame number per index point */
off_t next; /* frame offset supposed to come next into the index */
int64_t *data; /* actual data, the frame positions */
int64_t step; /* advancement in frame number per index point */
int64_t next; /* frame offset supposed to come next into the index */
size_t size; /* total number of possible entries */
size_t fill; /* number of used entries */
size_t grow_size; /* if > 0: index allowed to grow on need with these steps, instead of lowering resolution */
};
/* The condition for a framenum to be appended to the index.
if(FI_NEXT(fr->index, fr->num)) fi_add(offset); */
if(FI_NEXT(fr->index, fr->num)) INT123_fi_add(offset); */
#define FI_NEXT(fi, framenum) ((fi).size && framenum == (fi).next)
/* Initialize stuff, set things to zero and NULL... */
void fi_init(struct frame_index *fi);
void INT123_fi_init(struct frame_index *fi);
/* Deallocate/zero things. */
void fi_exit(struct frame_index *fi);
void INT123_fi_exit(struct frame_index *fi);
/* Prepare a given size, preserving current fill, if possible.
If the new size is smaller than fill, the entry density is reduced.
Return 0 on success. */
int fi_resize(struct frame_index *fi, size_t newsize);
int INT123_fi_resize(struct frame_index *fi, size_t newsize);
/* Append a frame position, reducing index density if needed. */
void fi_add(struct frame_index *fi, off_t pos);
void INT123_fi_add(struct frame_index *fi, int64_t pos);
/* Replace the frame index */
int fi_set(struct frame_index *fi, off_t *offsets, off_t step, size_t fill);
int INT123_fi_set(struct frame_index *fi, int64_t *offsets, int64_t step, size_t fill);
/* Empty the index (setting fill=0 and step=1), but keep current size. */
void fi_reset(struct frame_index *fi);
void INT123_fi_reset(struct frame_index *fi);
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -208,7 +208,7 @@ static int I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT],
return 0;
}
int do_layer1(mpg123_handle *fr)
int INT123_do_layer1(mpg123_handle *fr)
{
int clip=0;
int i,stereo = fr->stereo;
......@@ -246,5 +246,3 @@ int do_layer1(mpg123_handle *fr)
return clip;
}
......@@ -29,7 +29,7 @@
// The layer12_table is already in real format (fixed or float), just needs
// a little scaling in the MMX/SSE case.
void init_layer12_stuff(mpg123_handle *fr, real* (*init_table)(mpg123_handle *fr, real *table, int m))
void INT123_init_layer12_stuff(mpg123_handle *fr, real* (*init_table)(mpg123_handle *fr, real *table, int m))
{
int k;
real *table;
......@@ -40,7 +40,7 @@ void init_layer12_stuff(mpg123_handle *fr, real* (*init_table)(mpg123_handle *fr
}
}
real* init_layer12_table(mpg123_handle *fr, real *table, int m)
real* INT123_init_layer12_table(mpg123_handle *fr, real *table, int m)
{
int i;
for(i=0;i<63;i++)
......@@ -49,7 +49,7 @@ real* init_layer12_table(mpg123_handle *fr, real *table, int m)
}
#ifdef OPT_MMXORSSE
real* init_layer12_table_mmx(mpg123_handle *fr, real *table, int m)
real* INT123_init_layer12_table_mmx(mpg123_handle *fr, real *table, int m)
{
int i,j;
if(!fr->p.down_sample)
......@@ -324,7 +324,7 @@ static void II_select_table(mpg123_handle *fr)
}
int do_layer2(mpg123_handle *fr)
int INT123_do_layer2(mpg123_handle *fr)
{
int clip=0;
int i,j;
......
......@@ -37,7 +37,7 @@
#include "init_layer3.h"
#endif
/* Decoder state data, living on the stack of do_layer3. */
/* Decoder state data, living on the stack of INT123_do_layer3. */
struct gr_info_s
{
......@@ -75,19 +75,19 @@ struct III_sideinfo
};
#ifdef OPT_MMXORSSE
real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i)
real INT123_init_layer3_gainpow2_mmx(mpg123_handle *fr, int i)
{
if(!fr->p.down_sample) return DOUBLE_TO_REAL(16384.0 * pow((double)2.0,-0.25 * (double) (i+210) ));
else return DOUBLE_TO_REAL(pow((double)2.0,-0.25 * (double) (i+210)));
}
#endif
real init_layer3_gainpow2(mpg123_handle *fr, int i)
real INT123_init_layer3_gainpow2(mpg123_handle *fr, int i)
{
return DOUBLE_TO_REAL_SCALE_LAYER3(pow((double)2.0,-0.25 * (double) (i+210)),i+256);
}
void init_layer3_stuff(mpg123_handle *fr, real (*gainpow2_func)(mpg123_handle *fr, int i))
void INT123_init_layer3_stuff(mpg123_handle *fr, real (*gainpow2_func)(mpg123_handle *fr, int i))
{
int i,j;
......@@ -414,7 +414,7 @@ static int III_get_scale_factors_2(mpg123_handle *fr, int *scf,struct gr_info_s
}
};
if(i_stereo) /* i_stereo AND second channel -> do_layer3() checks this */
if(i_stereo) /* i_stereo AND second channel -> INT123_do_layer3() checks this */
slen = i_slen2[gr_info->scalefac_compress>>1];
else
slen = n_slen2[gr_info->scalefac_compress];
......@@ -499,7 +499,10 @@ static unsigned char pretab_choice[2][22] =
static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT],int *scf, struct gr_info_s *gr_info,int sfreq,int part2bits)
{
int shift = 1 + gr_info->scalefac_scale;
real *xrpnt = (real *) xr;
// Pointer cast to make pedantic compilers happy.
real *xrpnt = (real*)xr;
// Some compiler freaks out over &xr[SBLIMIT][0], which is the same.
real *xrpntlimit = (real*)xr+SBLIMIT*SSLIMIT;
int l[3],l3;
int part2remain = gr_info->part2_3_length - part2bits;
const short *me;
......@@ -552,10 +555,10 @@ static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT],in
}
}
#define CHECK_XRPNT if(xrpnt >= &xr[SBLIMIT][0]) \
#define CHECK_XRPNT if(xrpnt >= xrpntlimit) \
{ \
if(NOQUIET) \
error2("attempted xrpnt overflow (%p !< %p)", (void*) xrpnt, (void*) &xr[SBLIMIT][0]); \
error2("attempted xrpnt overflow (%p !< %p)", (void*) xrpnt, (void*) xrpntlimit); \
return 1; \
}
......@@ -992,7 +995,7 @@ static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT],in
gr_info->maxb = 1;
}
while(xrpnt < &xr[SBLIMIT][0])
while(xrpnt < xrpntlimit)
*xrpnt++ = DOUBLE_TO_REAL(0.0);
while( part2remain > 16 )
......@@ -1256,7 +1259,7 @@ static void III_antialias(real xr[SBLIMIT][SSLIMIT],struct gr_info_s *gr_info)
/* Calculation of the inverse MDCT
used to be static without 3dnow - does that really matter? */
void dct36(real *inbuf,real *o1,real *o2,const real *wintab,real *tsbuf)
void INT123_dct36(real *inbuf,real *o1,real *o2,const real *wintab,real *tsbuf)
{
real tmp[18];
......@@ -1388,7 +1391,7 @@ void dct36(real *inbuf,real *o1,real *o2,const real *wintab,real *tsbuf)
t0 = REAL_MUL(cos9[0], (in[5] + in[9]));
t1 = REAL_MUL(cos9[1], (in[9] - in[17]));
tmp[13] = REAL_MUL((t4 + t2 + t2), tfcos36[17-13]);
tmp[13] = REAL_MUL((t4 + t2 + t2), INT123_tfcos36[17-13]);
t2 = REAL_MUL(cos9[2], (in[5] + in[17]));
t6 = t3 - t0 - t2;
......@@ -1400,21 +1403,21 @@ void dct36(real *inbuf,real *o1,real *o2,const real *wintab,real *tsbuf)
t7 = REAL_MUL(COS6_1, in[7]);
t1 = t2 + t4 + t7;
tmp[17] = REAL_MUL((t0 + t1), tfcos36[17-17]);
tmp[9] = REAL_MUL((t0 - t1), tfcos36[17-9]);
tmp[17] = REAL_MUL((t0 + t1), INT123_tfcos36[17-17]);
tmp[9] = REAL_MUL((t0 - t1), INT123_tfcos36[17-9]);
t1 = REAL_MUL(cos18[2], (in[3] + in[15]));
t2 += t1 - t7;
tmp[14] = REAL_MUL((t3 + t2), tfcos36[17-14]);
tmp[14] = REAL_MUL((t3 + t2), INT123_tfcos36[17-14]);
t0 = REAL_MUL(COS6_1, (in[11] + in[15] - in[3]));
tmp[12] = REAL_MUL((t3 - t2), tfcos36[17-12]);
tmp[12] = REAL_MUL((t3 - t2), INT123_tfcos36[17-12]);
t4 -= t1 + t7;
tmp[16] = REAL_MUL((t5 - t0), tfcos36[17-16]);
tmp[10] = REAL_MUL((t5 + t0), tfcos36[17-10]);
tmp[15] = REAL_MUL((t6 + t4), tfcos36[17-15]);
tmp[11] = REAL_MUL((t6 - t4), tfcos36[17-11]);
tmp[16] = REAL_MUL((t5 - t0), INT123_tfcos36[17-16]);
tmp[10] = REAL_MUL((t5 + t0), INT123_tfcos36[17-10]);
tmp[15] = REAL_MUL((t6 + t4), INT123_tfcos36[17-15]);
tmp[11] = REAL_MUL((t6 - t4), INT123_tfcos36[17-11]);
}
#define MACRO(v) { \
......@@ -1645,7 +1648,7 @@ static void fill_pinfo_side(mpg123_handle *fr, struct III_sideinfo *si, int gr,
{
int i, sb;
float ifqstep; /* Why not double? */
int ch, ss;;
int ch, ss;
for(ch = 0; ch < stereo1; ++ch)
{
......@@ -1709,7 +1712,7 @@ static void fill_pinfo_side(mpg123_handle *fr, struct III_sideinfo *si, int gr,
#endif
/* And at the end... the main layer3 handler */
int do_layer3(mpg123_handle *fr)
int INT123_do_layer3(mpg123_handle *fr)
{
int gr, ch, ss,clip=0;
int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */
......@@ -1747,7 +1750,7 @@ int do_layer3(mpg123_handle *fr)
return clip;
}
set_pointer(fr, 1, sideinfo.main_data_begin);
INT123_set_pointer(fr, 1, sideinfo.main_data_begin);
#ifndef NO_MOREINFO
if(fr->pinfo)
{
......@@ -1930,8 +1933,8 @@ int do_layer3(mpg123_handle *fr)
if(n > (SSLIMIT-ss)) n=SSLIMIT-ss;
/* Clip counting makes no sense with this function. */
absynth_1to1_i486(hybridOut[0][ss], 0, fr, n);
absynth_1to1_i486(hybridOut[1][ss], 1, fr, n);
INT123_absynth_1to1_i486(hybridOut[0][ss], 0, fr, n);
INT123_absynth_1to1_i486(hybridOut[1][ss], 1, fr, n);
ss+=n;
fr->buffer.fill+=(2*2*32)*n;
}
......
/*
lfs_wrap: I/O wrapper code
copyright 2010-2023 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 (after code from Michael Hipp)
This is the interface to the implementation of internal reading/seeking
as well as wrapping of client callbacks to the one and only 64 bit
callback API on opaque handles.
Code outside of this shall not be concerned with I/O details, and
code inside of this shall not be concerned with other
libmpg123 internals. Just the public portable API interface.
*/
// This is to be offered by libmpg123 code that has access to frame struct
// details. It returns the address to load/store the pointer to the
// wrapper handle from/into. A little hack to keep things disentangled.
void ** INT123_wrap_handle(mpg123_handle *mh);
// Set error code in the mpg123 handle and return MPG123_ERR.
int INT123_set_err(mpg123_handle *mh, int err);
// These are offered by the source associated with this header.
// This is one open routine for all ways. One of the given resource arguments is active:
// 1. handle: if path == NULL && fd < 0
// 2. path: if path != NULL
// 3. fd: if fd >= 0
// In case of 64 bit handle setup, this does nothing.
// Return values:
// 0: setup for wrapped I/O successful.
// 1: use user-supplied 64 bit I/O handle directly, no internal wrappery
// <0: error
#define LFS_WRAP_NONE 1
int INT123_wrap_open(mpg123_handle *mh, void *handle, const char *path, int fd, long timeout, int quiet);
// Deallocate all associated resources and handle memory itself.
void INT123_wrap_destroy(void * handle);
// The bulk of functions are implementations of the non-portable
// libmpg123 API declared or implied in the main header.
/*
mpg123lib_intern: Common non-public stuff for libmpg123
copyright 1995-2021 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 1995-2023 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
......@@ -14,15 +14,14 @@
#define MPG123_ENCODINGS 12
#include "config.h" /* Load this before _anything_ */
#include "intsym.h" /* Prefixing of internal symbols that still are public in a static lib. */
#include "abi_align.h"
/* export DLL symbols */
#if defined(WIN32) && defined(DYNAMIC_BUILD)
#define BUILD_MPG123_DLL
#endif
#include "compat.h"
// Only portable API plays a role in the library itself, outside of lfs_wrap.c.
// Also, we need to ensure no suffix renaming for the primary implementations.
#define MPG123_PORTABLE_API
#define MPG123_ENUM_API
#include "mpg123.h"
......@@ -321,17 +320,17 @@ static inline int32_t scale_rounded(int32_t x, int shift)
#define VERBOSE4 (NOQUIET && fr->p.verbose > 3)
#define PVERB(mp, level) (!((mp)->flags & MPG123_QUIET) && (mp)->verbose >= (level))
int decode_update(mpg123_handle *mh);
int INT123_decode_update(mpg123_handle *mh);
/* residing in format.c */
off_t decoder_synth_bytes(mpg123_handle *fr , off_t s);
off_t samples_to_bytes(mpg123_handle *fr , off_t s);
off_t bytes_to_samples(mpg123_handle *fr , off_t b);
off_t outblock_bytes(mpg123_handle *fr, off_t s);
int64_t INT123_decoder_synth_bytes(mpg123_handle *fr , int64_t s);
int64_t INT123_samples_to_bytes(mpg123_handle *fr , int64_t s);
int64_t INT123_bytes_to_samples(mpg123_handle *fr , int64_t b);
int64_t INT123_outblock_bytes(mpg123_handle *fr, int64_t s);
/* Postprocessing format conversion of freshly decoded buffer. */
void postprocess_buffer(mpg123_handle *fr);
void INT123_postprocess_buffer(mpg123_handle *fr);
int open_fixed_pre(mpg123_handle *mh, int channels, int encoding);
int open_fixed_post(mpg123_handle *mh, int channels, int encoding);
int INT123_open_fixed_pre(mpg123_handle *mh, int channels, int encoding);
int INT123_open_fixed_post(mpg123_handle *mh, int channels, int encoding);
/* If networking is enabled and we really mean internal networking, the timeout_read function is available. */
#if defined (NETWORK) && !defined (WANT_WIN32_SOCKETS)
......
/*
ntom.c: N->M down/up sampling; the setup code.
copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 1995-2023 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 Michael Hipp
*/
#define SAFE_NTOM /* Do not depend on off_t*off_t with big values still being in the range... */
#define SAFE_NTOM /* Do not depend on int64_t*int64_t with big values still being in the range... */
#include "mpg123lib_intern.h"
#include "debug.h"
int synth_ntom_set_step(mpg123_handle *fr)
int INT123_synth_ntom_set_step(mpg123_handle *fr)
{
long m,n;
m = frame_freq(fr);
m = INT123_frame_freq(fr);
n = fr->af.rate;
if(VERBOSE2)
fprintf(stderr,"Init rate converter: %ld->%ld\n",m,n);
......@@ -33,21 +33,21 @@ int synth_ntom_set_step(mpg123_handle *fr)
return -1;
}
fr->ntom_val[0] = fr->ntom_val[1] = ntom_val(fr, fr->num);
fr->INT123_ntom_val[0] = fr->INT123_ntom_val[1] = INT123_ntom_val(fr, fr->num);
return 0;
}
/*
The SAFE_NTOM does iterative loops instead of straight multiplication.
The safety is not just about the algorithm closely mimicking the decoder instead of applying some formula,
it is more about avoiding multiplication of possibly big sample offsets (a 32bit off_t could overflow too easily).
it is more about avoiding multiplication of possibly big sample offsets (a 32bit int64_t could overflow too easily).
*/
unsigned long ntom_val(mpg123_handle *fr, off_t frame)
unsigned long INT123_ntom_val(mpg123_handle *fr, int64_t frame)
{
off_t ntm;
int64_t ntm;
#ifdef SAFE_NTOM /* Carry out the loop, without the threatening integer overflow. */
off_t f;
int64_t f;
ntm = NTOM_MUL>>1; /* for frame 0 */
for(f=0; f<frame; ++f) /* for frame > 0 */
{
......@@ -63,29 +63,29 @@ unsigned long ntom_val(mpg123_handle *fr, off_t frame)
/* Set the ntom value for next expected frame to be decoded.
This is for keeping output consistent across seeks. */
void ntom_set_ntom(mpg123_handle *fr, off_t num)
void INT123_ntom_set_ntom(mpg123_handle *fr, int64_t num)
{
fr->ntom_val[1] = fr->ntom_val[0] = ntom_val(fr, num);
fr->INT123_ntom_val[1] = fr->INT123_ntom_val[0] = INT123_ntom_val(fr, num);
}
/* Carry out the ntom sample count operation for this one frame.
No fear of integer overflow here. */
off_t ntom_frame_outsamples(mpg123_handle *fr)
int64_t INT123_ntom_frame_outsamples(mpg123_handle *fr)
{
/* The do this before decoding the separate channels, so there is only one common ntom value. */
int ntm = fr->ntom_val[0];
int ntm = fr->INT123_ntom_val[0];
ntm += fr->spf*fr->ntom_step;
return ntm/NTOM_MUL;
}
/* Convert frame offset to unadjusted output sample offset. */
off_t ntom_frmouts(mpg123_handle *fr, off_t frame)
int64_t INT123_ntom_frmouts(mpg123_handle *fr, int64_t frame)
{
#ifdef SAFE_NTOM
off_t f;
int64_t f;
#endif
off_t soff = 0;
off_t ntm = ntom_val(fr,0);
int64_t soff = 0;
int64_t ntm = INT123_ntom_val(fr,0);
#ifdef SAFE_NTOM
if(frame <= 0) return 0;
for(f=0; f<frame; ++f)
......@@ -95,23 +95,23 @@ off_t ntom_frmouts(mpg123_handle *fr, off_t frame)
ntm -= (ntm/NTOM_MUL)*NTOM_MUL;
}
#else
soff = (ntm + frame*(off_t)fr->spf*(off_t)fr->ntom_step)/(off_t)NTOM_MUL;
soff = (ntm + frame*(int64_t)fr->spf*(int64_t)fr->ntom_step)/(int64_t)NTOM_MUL;
#endif
return soff;
}
/* Convert input samples to unadjusted output samples. */
off_t ntom_ins2outs(mpg123_handle *fr, off_t ins)
int64_t INT123_ntom_ins2outs(mpg123_handle *fr, int64_t ins)
{
off_t soff = 0;
off_t ntm = ntom_val(fr,0);
int64_t soff = 0;
int64_t ntm = INT123_ntom_val(fr,0);
#ifdef SAFE_NTOM
{
off_t block = fr->spf;
int64_t block = fr->spf;
if(ins <= 0) return 0;
do
{
off_t nowblock = ins > block ? block : ins;
int64_t nowblock = ins > block ? block : ins;
ntm += nowblock*fr->ntom_step;
soff += ntm/NTOM_MUL;
ntm -= (ntm/NTOM_MUL)*NTOM_MUL;
......@@ -119,18 +119,18 @@ off_t ntom_ins2outs(mpg123_handle *fr, off_t ins)
} while(ins > 0);
}
#else
/* Beware of overflows: when off_t is 32bits, the multiplication blows too easily.
/* Beware of overflows: when int64_t is 32bits, the multiplication blows too easily.
Of course, it blows for 64bits, too, in theory, but that's for _really_ large files. */
soff = ((off_t)ntm + (off_t)ins*(off_t)fr->ntom_step)/(off_t)NTOM_MUL;
soff = ((int64_t)ntm + (int64_t)ins*(int64_t)fr->ntom_step)/(int64_t)NTOM_MUL;
#endif
return soff;
}
/* Determine frame offset from unadjusted output sample offset. */
off_t ntom_frameoff(mpg123_handle *fr, off_t soff)
int64_t INT123_ntom_frameoff(mpg123_handle *fr, int64_t soff)
{
off_t ioff = 0; /* frames or samples */
off_t ntm = ntom_val(fr,0);
int64_t ioff = 0; /* frames or samples */
int64_t ntm = INT123_ntom_val(fr,0);
#ifdef SAFE_NTOM
if(soff <= 0) return 0;
for(ioff=0; 1; ++ioff)
......@@ -142,7 +142,7 @@ off_t ntom_frameoff(mpg123_handle *fr, off_t soff)
}
return ioff;
#else
ioff = (soff*(off_t)NTOM_MUL-ntm)/(off_t)fr->ntom_step;
return ioff/(off_t)fr->spf;
ioff = (soff*(int64_t)NTOM_MUL-ntm)/(int64_t)fr->ntom_step;
return ioff/(int64_t)fr->spf;
#endif
}
......@@ -32,7 +32,7 @@
Also, one should minimize code size by really ensuring that only functions that are really needed are included.
Currently, all generic functions will be always there (to be safe for fallbacks for advanced decoders).
Strictly, at least the synth_1to1 should not be necessary for single-decoder mode.
Strictly, at least the INT123_synth_1to1 should not be necessary for single-decoder mode.
*/
......@@ -166,15 +166,15 @@ static const char* decname[] =
enum optcla { nocla=0, normal, mmxsse };
/* - Set up the table of synth functions for current decoder choice. */
int frame_cpu_opt(mpg123_handle *fr, const char* cpu);
int INT123_frame_cpu_opt(mpg123_handle *fr, const char* cpu);
/* - Choose, from the synth table, the synth functions to use for current output format/rate. */
int set_synth_functions(mpg123_handle *fr);
int INT123_set_synth_functions(mpg123_handle *fr);
/* - Parse decoder name and return numerical code. */
enum optdec dectype(const char* decoder);
enum optdec INT123_dectype(const char* decoder);
/* - Return the default decoder type. */
enum optdec defdec(void);
enum optdec INT123_defdec(void);
/* - Return the class of a decoder type (mmxsse or normal). */
enum optcla decclass(const enum optdec);
enum optcla INT123_decclass(const enum optdec);
/* Now comes a whole lot of definitions, for multi decoder mode and single decoder mode.
Because of the latter, it may look redundant at times. */
......@@ -265,7 +265,7 @@ enum optcla decclass(const enum optdec);
#define OPT_X86
#ifndef OPT_MULTI
# define defopt sse
# define opt_dct36(fr) dct36_sse
# define opt_dct36(fr) INT123_dct36_sse
#endif
#endif
......@@ -287,22 +287,22 @@ enum optcla decclass(const enum optdec);
#endif
#endif
/* same as above but also using 3DNowExt dct36 */
/* same as above but also using 3DNowExt INT123_dct36 */
#ifdef OPT_3DNOWEXT_VINTAGE
#define OPT_MMXORSSE
#define OPT_MPLAYER
#define OPT_X86
#ifndef OPT_MULTI
# define defopt dreidnowext_vintage
# define opt_dct36(fr) dct36_3dnowext
# define opt_dct36(fr) INT123_dct36_3dnowext
#endif
#endif
#ifdef OPT_MPLAYER
extern const int costab_mmxsse[];
extern const int INT123_costab_mmxsse[];
#endif
/* 3dnow used to use synth_1to1_i586 for mono / 8bit conversion - was that intentional? */
/* 3dnow used to use INT123_synth_1to1_i586 for mono / 8bit conversion - was that intentional? */
/* I'm trying to skip the pentium code here ... until I see that that is indeed a bad idea */
#ifdef OPT_3DNOW
#define OPT_X86
......@@ -311,12 +311,12 @@ extern const int costab_mmxsse[];
#endif
#endif
/* same as above but also using 3DNow dct36 */
/* same as above but also using 3DNow INT123_dct36 */
#ifdef OPT_3DNOW_VINTAGE
#define OPT_X86
#ifndef OPT_MULTI
# define defopt dreidnow_vintage
# define opt_dct36(fr) dct36_3dnow
# define opt_dct36(fr) INT123_dct36_3dnow
#endif
#endif
......@@ -330,7 +330,7 @@ extern const int costab_mmxsse[];
#define OPT_MMXORSSE
#ifndef OPT_MULTI
# define defopt x86_64
# define opt_dct36(fr) dct36_x86_64
# define opt_dct36(fr) INT123_dct36_x86_64
#endif
#endif
......@@ -338,7 +338,7 @@ extern const int costab_mmxsse[];
#define OPT_MMXORSSE
#ifndef OPT_MULTI
# define defopt avx
# define opt_dct36(fr) dct36_avx
# define opt_dct36(fr) INT123_dct36_avx
#endif
#endif
......@@ -352,7 +352,7 @@ extern const int costab_mmxsse[];
#define OPT_MMXORSSE
#ifndef OPT_MULTI
# define defopt neon
# define opt_dct36(fr) dct36_neon
# define opt_dct36(fr) INT123_dct36_neon
#endif
#endif
......@@ -360,7 +360,7 @@ extern const int costab_mmxsse[];
#define OPT_MMXORSSE
#ifndef OPT_MULTI
# define defopt neon64
# define opt_dct36(fr) dct36_neon64
# define opt_dct36(fr) INT123_dct36_neon64
#endif
#endif
......@@ -381,8 +381,7 @@ extern const int costab_mmxsse[];
#endif /* OPT_MULTI else */
# ifndef opt_dct36
# define opt_dct36(fr) dct36
# define opt_dct36(fr) INT123_dct36
# endif
#endif /* MPG123_H_OPTIMIZE */
/*
parse: spawned from common; clustering around stream/frame parsing
copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright ?-2023 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 Michael Hipp & Thomas Orgis
*/
......@@ -11,15 +11,12 @@
#include "frame.h"
int read_frame_init(mpg123_handle* fr);
int frame_bitrate(mpg123_handle *fr);
long frame_freq(mpg123_handle *fr);
int read_frame_recover(mpg123_handle* fr); /* dead? */
int read_frame(mpg123_handle *fr);
void set_pointer(mpg123_handle *fr, int part2, long backstep);
int position_info(mpg123_handle* fr, unsigned long no, long buffsize, unsigned long* frames_left, double* current_seconds, double* seconds_left);
double compute_bpf(mpg123_handle *fr);
long time_to_frame(mpg123_handle *fr, double seconds);
int get_songlen(mpg123_handle *fr,int no);
int INT123_read_frame_init(mpg123_handle* fr);
int INT123_frame_bitrate(mpg123_handle *fr);
long INT123_frame_freq(mpg123_handle *fr);
int INT123_read_frame_recover(mpg123_handle* fr); /* dead? */
int INT123_read_frame(mpg123_handle *fr);
void INT123_set_pointer(mpg123_handle *fr, int part2, long backstep);
double INT123_compute_bpf(mpg123_handle *fr);
#endif
/*
reader: reading input data
copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright ?-2023 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 (after code from Michael Hipp)
*/
......@@ -9,15 +9,16 @@
#ifndef MPG123_READER_H
#define MPG123_READER_H
#include "config.h"
#include "mpg123.h"
#ifndef MPG123_H_INTERN
#error "include internal mpg123 header first"
#endif
#ifndef NO_FEEDER
struct buffy
{
unsigned char *data;
ssize_t size;
ssize_t realsize;
ptrdiff_t size;
ptrdiff_t realsize;
struct buffy *next;
};
......@@ -26,12 +27,14 @@ struct bufferchain
{
struct buffy* first; /* The beginning of the chain. */
struct buffy* last; /* The end... of the chain. */
ssize_t size; /* Aggregated size of all buffies. */
ptrdiff_t size; /* Aggregated size of all buffies. */
/* These positions are relative to buffer chain beginning. */
ssize_t pos; /* Position in whole chain. */
ssize_t firstpos; /* The point of return on non-forget() */
ptrdiff_t pos; /* Position in whole chain. */
ptrdiff_t firstpos; /* The point of return on non-forget() */
/* The "real" filepos is fileoff + pos. */
off_t fileoff; /* Beginning of chain is at this file offset. */
int64_t fileoff; /* Beginning of chain is at this file offset. */
// Unsigned since no direct arithmetic with offsets. Overflow of overall
// size needs to be checked anyway.
size_t bufblock; /* Default (minimal) size of buffers. */
size_t pool_size; /* Keep that many buffers in storage. */
size_t pool_fill; /* That many buffers are there. */
......@@ -40,40 +43,28 @@ struct bufferchain
};
/* Call this before any buffer chain use (even bc_init()). */
void bc_prepare(struct bufferchain *, size_t pool_size, size_t bufblock);
void INT123_bc_prepare(struct bufferchain *, size_t pool_size, size_t bufblock);
/* Free persistent data in the buffer chain, after bc_reset(). */
void bc_cleanup(struct bufferchain *);
void INT123_bc_cleanup(struct bufferchain *);
/* Change pool size. This does not actually allocate/free anything on itself, just instructs later operations to free less / allocate more buffers. */
void bc_poolsize(struct bufferchain *, size_t pool_size, size_t bufblock);
void INT123_bc_poolsize(struct bufferchain *, size_t pool_size, size_t bufblock);
/* Return available byte count in the buffer. */
size_t bc_fill(struct bufferchain *bc);
size_t INT123_bc_fill(struct bufferchain *bc);
#endif
struct reader_data
{
off_t filelen; /* total file length or total buffer size */
off_t filepos; /* position in file or position in buffer chain */
int filept;
int64_t filelen; /* total file length or total buffer size */
int64_t filepos; /* position in file or position in buffer chain */
/* Custom opaque I/O handle from the client. */
void *iohandle;
int flags;
long timeout_sec;
ssize_t (*fdread) (mpg123_handle *, void *, size_t);
/* User can replace the read and lseek functions. The r_* are the stored replacement functions or NULL. */
ssize_t (*r_read) (int fd, void *buf, size_t count);
off_t (*r_lseek)(int fd, off_t offset, int whence);
/* These are custom I/O routines for opaque user handles.
They get picked if there's some iohandle set. */
ssize_t (*r_read_handle) (void *handle, void *buf, size_t count);
off_t (*r_lseek_handle)(void *handle, off_t offset, int whence);
/* An optional cleaner for the handle on closing the stream. */
// The one and only lowlevel reader wrapper, wrapping over all others.
// This is either libmpg123's wrapper or directly the user-supplied functions.
int (*r_read64) (void *, void *, size_t, size_t *);
int64_t (*r_lseek64)(void *, int64_t, int);
void (*cleanup_handle)(void *handle);
/* These two pointers are the actual workers (default map to POSIX read/lseek). */
ssize_t (*read) (int fd, void *buf, size_t count);
off_t (*lseek)(int fd, off_t offset, int whence);
/* Buffered readers want that abstracted, set internally. */
ssize_t (*fullread)(mpg123_handle *, unsigned char *, ssize_t);
#ifndef NO_FEEDER
struct bufferchain buffer; /* Not dynamically allocated, these few struct bytes aren't worth the trouble. */
#endif
......@@ -87,39 +78,35 @@ struct reader
{
int (*init) (mpg123_handle *);
void (*close) (mpg123_handle *);
ssize_t (*fullread) (mpg123_handle *, unsigned char *, ssize_t);
ptrdiff_t (*fullread) (mpg123_handle *, unsigned char *, ptrdiff_t);
int (*head_read) (mpg123_handle *, unsigned long *newhead); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */
int (*head_shift) (mpg123_handle *, unsigned long *head); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */
off_t (*skip_bytes) (mpg123_handle *, off_t len); /* succ: >=0, else error or READER_MORE */
int64_t (*skip_bytes) (mpg123_handle *, int64_t len); /* succ: >=0, else error or READER_MORE */
int (*read_frame_body)(mpg123_handle *, unsigned char *, int size);
int (*back_bytes) (mpg123_handle *, off_t bytes);
int (*seek_frame) (mpg123_handle *, off_t num);
off_t (*tell) (mpg123_handle *);
int (*back_bytes) (mpg123_handle *, int64_t bytes);
int (*seek_frame) (mpg123_handle *, int64_t num);
int64_t (*tell) (mpg123_handle *);
void (*rewind) (mpg123_handle *);
void (*forget) (mpg123_handle *);
};
/* Open a file by path or use an opened file descriptor. */
int open_stream(mpg123_handle *, const char *path, int fd);
/* Open an external handle. */
int open_stream_handle(mpg123_handle *, void *iohandle);
int INT123_open_stream_handle(mpg123_handle *, void *iohandle);
/* feed based operation has some specials */
int open_feed(mpg123_handle *);
int INT123_open_feed(mpg123_handle *);
/* externally called function, returns 0 on success, -1 on error */
int feed_more(mpg123_handle *fr, const unsigned char *in, long count);
void feed_forget(mpg123_handle *fr); /* forget the data that has been read (free some buffers) */
off_t feed_set_pos(mpg123_handle *fr, off_t pos); /* Set position (inside available data if possible), return wanted byte offset of next feed. */
int INT123_feed_more(mpg123_handle *fr, const unsigned char *in, size_t count);
void INT123_feed_forget(mpg123_handle *fr); /* forget the data that has been read (free some buffers) */
int64_t INT123_feed_set_pos(mpg123_handle *fr, int64_t pos); /* Set position (inside available data if possible), return wanted byte offset of next feed. */
void open_bad(mpg123_handle *);
void INT123_open_bad(mpg123_handle *);
#define READER_FD_OPENED 0x1
#define READER_ID3TAG 0x2
#define READER_SEEKABLE 0x4
#define READER_BUFFERED 0x8
#define READER_NONBLOCK 0x20
#define READER_NOSEEK 0x10
#define READER_HANDLEIO 0x40
#define READER_STREAM 0
#define READER_ICY_STREAM 1
#define READER_FEED 2
......@@ -127,13 +114,6 @@ void open_bad(mpg123_handle *);
#define READER_BUF_STREAM 3
#define READER_BUF_ICY_STREAM 4
#ifdef READ_SYSTEM
#define READER_SYSTEM 5
#define READERS 6
#else
#define READERS 5
#endif
#define READER_ERROR MPG123_ERR
#define READER_MORE MPG123_NEED_MORE
......
......@@ -71,8 +71,8 @@ int attribute_align_arg mpg123_resize_string(mpg123_string* sb, size_t new)
{
char* t;
debug("really!");
t = (char*) safe_realloc(sb->p, new*sizeof(char));
debug1("safe_realloc returned %p", (void*) t);
t = (char*) INT123_safe_realloc(sb->p, new*sizeof(char));
debug1("INT123_safe_realloc returned %p", (void*) t);
if(t != NULL)
{
sb->p = t;
......@@ -217,23 +217,19 @@ size_t attribute_align_arg mpg123_strlen(mpg123_string *sb, int utf8)
int attribute_align_arg mpg123_chomp_string(mpg123_string *sb)
{
ssize_t i;
if(!sb || !sb->fill) return 0;
/* Ensure that it is zero-terminated. */
sb->p[sb->fill-1] = 0;
for(i=sb->fill-2; i>=0; --i)
char *c = sb->p+sb->fill-1;
*c = 0;
for(; c >= sb->p; --c)
{
char *c = sb->p+i;
/* Stop at the first proper character. */
if(*c && *c != '\r' && *c != '\n') break;
else *c = 0;
}
/* initial fill at least 1, so i at least -1,
+2 means nothing happened for fill=1 .
With i=0, we got one non-null character, fill shall be 2
to accomodate the trailing zero. */
sb->fill = (size_t)i+2;
// We at least got a trailing zero.
sb->fill = (size_t)(c - sb->p + 1) + 1;
return 1;
}
......
......@@ -20,15 +20,15 @@
*/
/* Main synth function, uses the plain dct64 or dct64_i386. */
/* Main synth function, uses the plain INT123_dct64 or INT123_dct64_i386. */
int SYNTH_NAME(real *bandPtr, int channel, mpg123_handle *fr, int final)
{
#ifndef NO_AUTOINCREMENT
#define BACKPEDAL 0x10 /* We use autoincrement and thus need this re-adjustment for window/b0. */
#define MY_DCT64 dct64
#define MY_DCT64 INT123_dct64
#else
#define BACKPEDAL 0x00 /* i386 code does not need that. */
#define MY_DCT64 dct64_i386
#define MY_DCT64 INT123_dct64_i386
#endif
static const int step = 2;
SAMPLE_T *samples = (SAMPLE_T *) (fr->buffer.data + fr->buffer.fill);
......@@ -37,7 +37,7 @@ int SYNTH_NAME(real *bandPtr, int channel, mpg123_handle *fr, int final)
int clip = 0;
int bo1;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
if(fr->have_eq_settings) INT123_do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
......
......@@ -13,7 +13,7 @@
/*
Part 2: All synth functions that produce 8bit output.
What we need is just a special WRITE_SAMPLE. For the generic and i386 functions, that is.
For the rather optimized synth_1to1, we will need the postprocessing 8bit converters from synth_8bit.h .
For the rather optimized INT123_synth_1to1, we will need the postprocessing 8bit converters from synth_8bit.h .
*/
#define SAMPLE_T unsigned char
......@@ -22,14 +22,14 @@
/* Part 2a: All straight 1to1 decoding functions */
#define BLOCK 0x40 /* One decoding block is 64 samples. */
#define SYNTH_NAME synth_1to1_8bit
#define SYNTH_NAME INT123_synth_1to1_8bit
#include "synth.h"
#undef SYNTH_NAME
/* Mono-related synths; they wrap over _some_ synth_1to1_8bit (could be generic, could be i386). */
/* Mono-related synths; they wrap over _some_ INT123_synth_1to1_8bit (could be generic, could be i386). */
#define SYNTH_NAME fr->synths.plain[r_1to1][f_8]
#define MONO_NAME synth_1to1_8bit_mono
#define MONO2STEREO_NAME synth_1to1_8bit_m2s
#define MONO_NAME INT123_synth_1to1_8bit_mono
#define MONO2STEREO_NAME INT123_synth_1to1_8bit_m2s
#include "synth_mono.h"
#undef SYNTH_NAME
#undef MONO_NAME
......@@ -37,20 +37,20 @@
#ifdef OPT_X86
#define NO_AUTOINCREMENT
#define SYNTH_NAME synth_1to1_8bit_i386
#define SYNTH_NAME INT123_synth_1to1_8bit_i386
#include "synth.h"
#undef SYNTH_NAME
/* i386 uses the normal mono functions. */
#undef NO_AUTOINCREMENT
#endif
/* But now, we need functions that take the 16bit output of optimized synth_1to1 and convert it.
/* But now, we need functions that take the 16bit output of optimized INT123_synth_1to1 and convert it.
I suppose that is still faster than dropping the optimization altogether! */
#define BASE_SYNTH_NAME fr->synths.plain[r_1to1][f_16]
#define SYNTH_NAME synth_1to1_8bit_wrap
#define MONO_NAME synth_1to1_8bit_wrap_mono
#define MONO2STEREO_NAME synth_1to1_8bit_wrap_m2s
#define SYNTH_NAME INT123_synth_1to1_8bit_wrap
#define MONO_NAME INT123_synth_1to1_8bit_wrap_mono
#define MONO2STEREO_NAME INT123_synth_1to1_8bit_wrap_m2s
#include "synth_8bit.h"
#undef BASE_SYNTH_NAME
#undef SYNTH_NAME
......@@ -66,14 +66,14 @@
*/
#define BLOCK 0x20 /* One decoding block is 32 samples. */
#define SYNTH_NAME synth_2to1_8bit
#define SYNTH_NAME INT123_synth_2to1_8bit
#include "synth.h"
#undef SYNTH_NAME
/* Mono-related synths; they wrap over _some_ synth_2to1_8bit (could be generic, could be i386). */
/* Mono-related synths; they wrap over _some_ INT123_synth_2to1_8bit (could be generic, could be i386). */
#define SYNTH_NAME fr->synths.plain[r_2to1][f_8]
#define MONO_NAME synth_2to1_8bit_mono
#define MONO2STEREO_NAME synth_2to1_8bit_m2s
#define MONO_NAME INT123_synth_2to1_8bit_mono
#define MONO2STEREO_NAME INT123_synth_2to1_8bit_m2s
#include "synth_mono.h"
#undef SYNTH_NAME
#undef MONO_NAME
......@@ -81,7 +81,7 @@
#ifdef OPT_X86
#define NO_AUTOINCREMENT
#define SYNTH_NAME synth_2to1_8bit_i386
#define SYNTH_NAME INT123_synth_2to1_8bit_i386
#include "synth.h"
#undef SYNTH_NAME
/* i386 uses the normal mono functions. */
......@@ -95,14 +95,14 @@
*/
#define BLOCK 0x10 /* One decoding block is 16 samples. */
#define SYNTH_NAME synth_4to1_8bit
#define SYNTH_NAME INT123_synth_4to1_8bit
#include "synth.h"
#undef SYNTH_NAME
/* Mono-related synths; they wrap over _some_ synth_4to1_8bit (could be generic, could be i386). */
/* Mono-related synths; they wrap over _some_ INT123_synth_4to1_8bit (could be generic, could be i386). */
#define SYNTH_NAME fr->synths.plain[r_4to1][f_8]
#define MONO_NAME synth_4to1_8bit_mono
#define MONO2STEREO_NAME synth_4to1_8bit_m2s
#define MONO_NAME INT123_synth_4to1_8bit_mono
#define MONO2STEREO_NAME INT123_synth_4to1_8bit_m2s
#include "synth_mono.h"
#undef SYNTH_NAME
#undef MONO_NAME
......@@ -110,7 +110,7 @@
#ifdef OPT_X86
#define NO_AUTOINCREMENT
#define SYNTH_NAME synth_4to1_8bit_i386
#define SYNTH_NAME INT123_synth_4to1_8bit_i386
#include "synth.h"
#undef SYNTH_NAME
/* i386 uses the normal mono functions. */
......@@ -124,13 +124,13 @@
#ifndef NO_NTOM
/*
Part 2d: ntom synth.
Same procedure as above... Just no extra play anymore, straight synth that may use an optimized dct64.
Same procedure as above... Just no extra play anymore, straight synth that may use an optimized INT123_dct64.
*/
/* These are all in one header, there's no flexibility to gain. */
#define SYNTH_NAME synth_ntom_8bit
#define MONO_NAME synth_ntom_8bit_mono
#define MONO2STEREO_NAME synth_ntom_8bit_m2s
#define SYNTH_NAME INT123_synth_ntom_8bit
#define MONO_NAME INT123_synth_ntom_8bit_mono
#define MONO2STEREO_NAME INT123_synth_ntom_8bit_m2s
#include "synth_ntom.h"
#undef SYNTH_NAME
#undef MONO_NAME
......
......@@ -7,7 +7,7 @@
Only variable is the BLOCK size to choose 1to1, 2to1 or 4to1.
Oh, and the names: BASE_SYNTH_NAME, SYNTH_NAME, MONO_NAME, MONO2STEREO_NAME
(p.ex. opt_synth_1to1(fr), synth_1to1_8bit, synth_1to1_8bit_mono, ...).
(p.ex. opt_synth_1to1(fr), INT123_synth_1to1_8bit, INT123_synth_1to1_8bit_mono, ...).
*/
int SYNTH_NAME(real *bandPtr, int channel, mpg123_handle *fr, int final)
......@@ -83,4 +83,3 @@ int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr)
return ret;
}
......@@ -13,7 +13,7 @@
This is what resulted...
Reason to separate this from synth.h:
There are decoders that have a special synth_1to1 but still can use these generic derivations for the mono stuff.
There are decoders that have a special INT123_synth_1to1 but still can use these generic derivations for the mono stuff.
It generally makes a good deal of sense to set SYNTH_NAME to opt_synth_1to1(fr) (or opt_synth_2to1(fr), etc.).
*/
......
/*
synth_ntom.h: ntom-resampling synth functions
This header is used multiple times to create different variants of this function.
Hint: MONO_NAME, MONO2STEREO_NAME, SYNTH_NAME and SAMPLE_T as well as WRITE_SAMPLE do vary.
......@@ -73,33 +73,33 @@ int SYNTH_NAME(real *bandPtr,int channel, mpg123_handle *fr, int final)
int bo1;
int ntom;
#ifndef NO_EQUALIZER
if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer);
if(fr->have_eq_settings) INT123_do_equalizer(bandPtr,channel,fr->equalizer);
#endif
if(!channel)
{
fr->bo--;
fr->bo &= 0xf;
buf = fr->real_buffs[0];
ntom = fr->ntom_val[1] = fr->ntom_val[0];
ntom = fr->INT123_ntom_val[1] = fr->INT123_ntom_val[0];
}
else
{
samples++;
buf = fr->real_buffs[1];
ntom = fr->ntom_val[1];
ntom = fr->INT123_ntom_val[1];
}
if(fr->bo & 0x1)
{
b0 = buf[0];
bo1 = fr->bo;
dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr);
INT123_dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr);
}
else
{
b0 = buf[1];
bo1 = fr->bo+1;
dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr);
INT123_dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr);
}
{
......@@ -205,9 +205,8 @@ int SYNTH_NAME(real *bandPtr,int channel, mpg123_handle *fr, int final)
}
}
fr->ntom_val[channel] = ntom;
fr->INT123_ntom_val[channel] = ntom;
if(final) fr->buffer.fill = ((unsigned char *) samples - fr->buffer.data - (channel ? sizeof(SAMPLE_T) : 0));
return clip;
}
......@@ -16,7 +16,7 @@
#else
const
#endif
real *pnts[] = { cos64,cos32,cos16,cos8,cos4 };
real *INT123_pnts[] = { cos64,cos32,cos16,cos8,cos4 };
static const long intwinbase[] = {
0, -1, -1, -1, -1, -1, -1, -2, -2, -2,
......@@ -48,12 +48,12 @@ static const long intwinbase[] = {
#ifdef OPT_MMXORSSE
#if !defined(OPT_X86_64) && !defined(OPT_NEON) && !defined(OPT_NEON64) && !defined(OPT_AVX)
void make_decode_tables_mmx_asm(long scaleval, float* decwin_mmx, float *decwins);
void make_decode_tables_mmx(mpg123_handle *fr)
void INT123_make_decode_tables_mmx_asm(long scaleval, float* decwin_mmx, float *decwins);
void INT123_make_decode_tables_mmx(mpg123_handle *fr)
{
debug("MMX decode tables");
/* Take care: The scale should be like before, when we didn't have float output all around. */
make_decode_tables_mmx_asm((long)((fr->lastscale < 0 ? fr->p.outscale : fr->lastscale)*SHORT_SCALE), fr->decwin_mmx, fr->decwins);
INT123_make_decode_tables_mmx_asm((long)((fr->lastscale < 0 ? fr->p.outscale : fr->lastscale)*SHORT_SCALE), fr->decwin_mmx, fr->decwins);
debug("MMX decode tables done");
}
#else
......@@ -65,7 +65,7 @@ static int rounded(double f)
}
/* x86-64 doesn't use asm version */
void make_decode_tables_mmx(mpg123_handle *fr)
void INT123_make_decode_tables_mmx(mpg123_handle *fr)
{
int i,j,val;
int idx = 0;
......@@ -135,7 +135,7 @@ static int32_t sat_mul32(int32_t a, int32_t b)
}
#endif
void make_decode_tables(mpg123_handle *fr)
void INT123_make_decode_tables(mpg123_handle *fr)
{
int i,j;
int idx = 0;
......@@ -231,7 +231,7 @@ void make_decode_tables(mpg123_handle *fr)
}
#ifndef NO_8BIT
int make_conv16to8_table(mpg123_handle *fr)
int INT123_make_conv16to8_table(mpg123_handle *fr)
{
int i;
int mode = fr->af.dec_enc;
......@@ -342,4 +342,3 @@ int make_conv16to8_table(mpg123_handle *fr)
return 0;
}
#endif
#ifndef MPG123_VERSION_H
#define MPG123_VERSION_H
/*
version: mpg123 distribution version
This is the main source of mpg123 distribution version information, parsed
by the build system for packaging.
copyright 2023 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
*/
// only single spaces as separator to ease parsing by build scripts
#define MPG123_MAJOR 1
#define MPG123_MINOR 32
#define MPG123_PATCH 2
// Don't get too wild with that to avoid confusing m4. No brackets.
// Also, it should fit well into a sane file name for the tarball.
#define MPG123_SUFFIX ""
#define MPG123_VERSION_CAT_REALLY(a, b, c) #a "." #b "." #c
#define MPG123_VERSION_CAT(a, b, c) MPG123_VERSION_CAT_REALLY(a, b, c)
#define MPG123_VERSION \
MPG123_VERSION_CAT(MPG123_MAJOR, MPG123_MINOR, MPG123_PATCH) MPG123_SUFFIX
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment