Skip to content

Commit

Permalink
[Var] mpg123: Update to v1.28.0 (2021-06-05).
Browse files Browse the repository at this point in the history
[Fix] mpg123: Work-around <https://sourceforge.net/p/mpg123/bugs/313/> by keeping #ifndef MPG123_NO_CONFIGURE in mpg123.h.in.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@15309 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
manxorist committed Jun 5, 2021
1 parent 19fc0e9 commit f146350
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 26 deletions.
4 changes: 3 additions & 1 deletion include/mpg123/OpenMPT.txt
@@ -1,9 +1,11 @@
libmpg123 library version 1.27.2.
libmpg123 library version 1.28.0 (2021-06-05).
The following changes have been made:
- ports/makefile/config.h and ports/makefile/mpg123.h have been added for plain
Makefile builds.
- ports/MSVC++/config.h and ports/MSVC++/mpg123.h have been retained from older
versions.
- #ifndef MPG123_NO_CONFIGURE hsa been kept in mpg123.h.in. See
<https://sourceforge.net/p/mpg123/bugs/313/>.
- Modifications are marked by // OpenMPT.
- Obviously, unnecessary folders and files have been removed.
- For building, premake is used to generate Visual Studio project files.
Expand Down
9 changes: 8 additions & 1 deletion include/mpg123/src/compat/compat.h
Expand Up @@ -103,12 +103,19 @@

typedef unsigned char byte;

#if defined(_MSC_VER) && !defined(MPG123_DEF_SSIZE_T)
#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

/* A safe realloc also for very old systems where realloc(NULL, size) returns NULL. */
void *safe_realloc(void *ptr, size_t size);
// Also freeing ptr if result is NULL. You can do
Expand Down
1 change: 1 addition & 0 deletions include/mpg123/src/intsym.h
Expand Up @@ -8,6 +8,7 @@
#define pnts INT123_pnts
#define catchsignal INT123_catchsignal
#define safe_realloc INT123_safe_realloc
#define safer_realloc INT123_safer_realloc
#define compat_strdup INT123_compat_strdup
#define compat_getenv INT123_compat_getenv
#define compat_open INT123_compat_open
Expand Down
2 changes: 1 addition & 1 deletion include/mpg123/src/libmpg123/frame.c
Expand Up @@ -178,9 +178,9 @@ void attribute_align_arg mpg123_delete_pars(mpg123_pars* mp)

int attribute_align_arg mpg123_reset_eq(mpg123_handle *mh)
{
int i;
if(mh == NULL) return MPG123_BAD_HANDLE;
#ifndef NO_EQUALIZER
int i;
mh->have_eq_settings = 0;
for(i=0; i < 32; ++i) mh->equalizer[0][i] = mh->equalizer[1][i] = DOUBLE_TO_REAL(1.0);
#endif
Expand Down
21 changes: 3 additions & 18 deletions include/mpg123/src/libmpg123/layer3.c
Expand Up @@ -309,20 +309,12 @@ static int III_get_scale_factors_1(mpg123_handle *fr, int *scf,struct gr_info_s
int num0 = slen[0][gr_info->scalefac_compress];
int num1 = slen[1][gr_info->scalefac_compress];

if(gr_info->part2_3_length == 0)
{
int i;
for(i=0;i<39;i++)
*scf++ = 0;
return 0;
}

if(gr_info->block_type == 2)
{
int i=18;
numbits = (num0 + num1) * 18 /* num0 * (17+1?) + num1 * 18 */
- (gr_info->mixed_block_flag ? num0 : 0);
if(numbits > gr_info->part2_3_length)
if(fr->bits_avail < numbits)
return -1;

if(gr_info->mixed_block_flag)
Expand All @@ -347,7 +339,7 @@ static int III_get_scale_factors_1(mpg123_handle *fr, int *scf,struct gr_info_s
if(scfsi < 0)
{ /* scfsi < 0 => granule == 0 */
numbits = (num0 + num1) * 10 + num0;
if(numbits > gr_info->part2_3_length)
if(fr->bits_avail < numbits)
return -1;

for(i=11;i;i--) *scf++ = getbits_fast(fr, num0);
Expand All @@ -362,7 +354,7 @@ static int III_get_scale_factors_1(mpg123_handle *fr, int *scf,struct gr_info_s
+ !(scfsi & 0x4) * num0 * 5
+ !(scfsi & 0x2) * num1 * 5
+ !(scfsi & 0x1) * num1 * 5;
if(numbits > gr_info->part2_3_length)
if(fr->bits_avail < numbits)
return -1;

if(!(scfsi & 0x8))
Expand Down Expand Up @@ -435,13 +427,6 @@ static int III_get_scale_factors_2(mpg123_handle *fr, int *scf,struct gr_info_s

pnt = stab[n][(slen>>12)&0x7];

if(gr_info->part2_3_length == 0)
{
for(i=0;i<39;i++)
*scf++ = 0;
return 0;
}

slen2 = slen;
for(i=0;i<4;i++)
{
Expand Down
26 changes: 21 additions & 5 deletions include/mpg123/src/libmpg123/mpg123.h.in
Expand Up @@ -76,10 +76,18 @@ typedef ptrdiff_t ssize_t;

#endif

#ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */
#ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */ // OpenMPT
@INCLUDE_STDLIB_H@
@INCLUDE_SYS_TYPE_H@

/* You can always enforce largefile hackery by setting MPG123_LARGESUFFIX. */
/* Otherwise, this header disables it if the build system decided so. */
#if !defined(MPG123_LARGESUFFIX) && @BUILD_NO_LARGENAME@
#ifndef MPG123_NO_LARGENAME
#define MPG123_NO_LARGENAME
#endif
#endif

/* Simplified large file handling.
I used to have a check here that prevents building for a library with conflicting large file setup
(application that uses 32 bit offsets with library that uses 64 bits).
Expand Down Expand Up @@ -136,8 +144,8 @@ typedef ptrdiff_t ssize_t;

#endif /* largefile hackery */

#endif /* MPG123_NO_CONFIGURE */

#endif /* MPG123_NO_CONFIGURE */ // OpenMPT
// OpenMPT
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -732,7 +740,7 @@ MPG123_EXPORT int mpg123_getformat2( mpg123_handle *mh
* will also be decoded without you really noticing. Just the speed could be
* wrong if you do not care about sample rate at all.
* \param mh handle
* \param path filesystem path
* \param path filesystem path (see mpg123_open())
* \param channels allowed channel count, either 1 (MPG123_MONO) or
* 2 (MPG123_STEREO), or bitwise or of them, but then you're halfway back to
* calling mpg123_format() again;-)
Expand All @@ -745,8 +753,16 @@ MPG123_EXPORT int mpg123_open_fixed(mpg123_handle *mh, const char *path
/** Open and prepare to decode the specified file by filesystem path.
* This does not open HTTP urls; libmpg123 contains no networking code.
* If you want to decode internet streams, use mpg123_open_fd() or mpg123_open_feed().
*
* The path parameter usually is just a string that is handed to the underlying
* OS routine for opening, treated as a blob of binary data. On platforms
* where encoding needs to be involved, something like _wopen() is called
* underneath and the path argument to libmpg123 is assumed to be encoded in UTF-8.
* So, if you have to ask yourself which encoding is needed, the answer is
* UTF-8, which also fits any sane modern install of Unix-like systems.
*
* \param mh handle
* \param path filesystem path
* \param path filesystem
* \return MPG123_OK on success
*/
MPG123_EXPORT int mpg123_open(mpg123_handle *mh, const char *path);
Expand Down

0 comments on commit f146350

Please sign in to comment.