Skip to content

Commit

Permalink
Merged revision(s) 21914 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Var] mpg123: Update to 1.32.8-dev+r5433 (2024-10-24).
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@21940 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
manxorist committed Oct 26, 2024
1 parent 9a5c192 commit fd4fa76
Show file tree
Hide file tree
Showing 20 changed files with 277 additions and 168 deletions.
1 change: 1 addition & 0 deletions include/mpg123/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The creator: Michael Hipp (email: [email protected] - please bot

Contributions/ideas Thomas Orgis era (includes backports from mhipp trunk):

Bill Roberts <[email protected]>: PAC/BTI for aarch64
Dave Yeo <[email protected]>: continued OS/2 fixing
madebr and manx: github mirror and CI
Vitaly Kirsanov <[email protected]>: ports/cmake (optional CMake build)
Expand Down
2 changes: 1 addition & 1 deletion include/mpg123/OpenMPT.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libmpg123 library version 1.32.7 (2024-08-07).
libmpg123 library version 1.32.8-dev+r5433 (2024-10-24).
The following changes have been made:
* `ports/makefile/config.h` has been added for plain `Makefile` builds.
* `ports/MSVC++/config.h` has been added for MSVC builds.
Expand Down
52 changes: 52 additions & 0 deletions include/mpg123/src/libmpg123/aarch64_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* SPDX-License-Identifier: LGPL-2.1
*
* aarch64_defs.h: Support macros for the aarch64 architectural features
*/

#ifndef SRC_LIBMPG123_AARCH64_DEFS_H_
#define SRC_LIBMPG123_AARCH64_DEFS_H_

/*
* Guard this header so arm assembly files can just include it without the need
* to if-def each instance.
*/
#ifdef __aarch64__

/*
* References:
* - https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros
* - https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst
*/

#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
#define GNU_PROPERTY_AARCH64_BTI 1 /* bit 0 GNU Notes is for BTI support */
#else
#define GNU_PROPERTY_AARCH64_BTI 0
#endif

#if defined(__ARM_FEATURE_PAC_DEFAULT)
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 2 /* bit 1 GNU Notes is for PAC support */
#else
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
#endif

/* Add the BTI support to GNU Notes section */
#if defined(__ASSEMBLER__) && defined(__ELF__)
#if GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_POINTER_AUTH != 0
.pushsection .note.gnu.property, "a"; /* Start a new allocatable section */
.balign 8; /* align it on a byte boundry */
.long 4; /* size of "GNU\0" */
.long 0x10; /* size of descriptor */
.long 0x5; /* NT_GNU_PROPERTY_TYPE_0 */
.asciz "GNU";
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
.long 4; /* Four bytes of data */
.long (GNU_PROPERTY_AARCH64_BTI|GNU_PROPERTY_AARCH64_POINTER_AUTH); /* BTI or PAC is enabled */
.long 0; /* padding for 8 byte alignment */
.popsection; /* end the section */
#endif /* GNU Notes additions */
#endif /* if __ASSEMBLER__ and __ELF__ */

#endif /* __arch64__ */

#endif /* SRC_LIBMPG123_AARCH64_DEFS_H_ */
1 change: 1 addition & 0 deletions include/mpg123/src/libmpg123/check_neon.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
initially written by Taihei Momma
*/

#include "aarch64_defs.h"
#include "mangle.h"

#ifndef __aarch64__
Expand Down
1 change: 1 addition & 0 deletions include/mpg123/src/libmpg123/dct36_neon64.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
initially written by Taihei Monma
*/

#include "aarch64_defs.h"
#include "mangle.h"

#ifndef __APPLE__
Expand Down
1 change: 1 addition & 0 deletions include/mpg123/src/libmpg123/dct64_neon64_float.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
initially written by Taihei Monma
*/

#include "aarch64_defs.h"
#include "mangle.h"

#ifndef __APPLE__
Expand Down
15 changes: 6 additions & 9 deletions include/mpg123/src/libmpg123/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ static void frame_fixed_reset(mpg123_handle *fr)
{
frame_icy_reset(fr);
INT123_open_bad(fr);
memset(&(fr->hdr), 0, sizeof(fr->hdr));
fr->to_decode = FALSE;
fr->to_ignore = FALSE;
fr->metaflags = 0;
Expand All @@ -524,15 +525,12 @@ static void frame_fixed_reset(mpg123_handle *fr)
fr->clip = 0;
fr->oldhead = 0;
fr->firsthead = 0;
fr->lay = 0;
fr->vbr = MPG123_CBR;
fr->abr_rate = 0;
fr->track_frames = 0;
fr->track_samples = -1;
fr->framesize=0;
fr->mean_frames = 0;
fr->mean_framesize = 0;
fr->freesize = 0;
fr->lastscale = -1;
fr->rva.level[0] = -1;
fr->rva.level[1] = -1;
Expand Down Expand Up @@ -567,8 +565,7 @@ static void frame_fixed_reset(mpg123_handle *fr)
fr->icy.next = 0;
#endif
fr->halfphase = 0; /* here or indeed only on first-time init? */
fr->error_protection = 0;
fr->freeformat_framesize = fr->p.freeformat_framesize;
fr->hdr.freeformat_framesize = fr->p.freeformat_framesize;
fr->enc_delay = -1;
fr->enc_padding = -1;
memset(fr->id3buf, 0, sizeof(fr->id3buf));
Expand Down Expand Up @@ -627,7 +624,7 @@ int attribute_align_arg mpg123_framedata(mpg123_handle *mh, unsigned long *heade

if(header != NULL) *header = mh->oldhead;
if(bodydata != NULL) *bodydata = mh->bsbuf;
if(bodybytes != NULL) *bodybytes = mh->framesize;
if(bodybytes != NULL) *bodybytes = mh->hdr.framesize;

return MPG123_OK;
}
Expand Down Expand Up @@ -900,9 +897,9 @@ static int64_t ignoreframe(mpg123_handle *fr)
{
int64_t preshift = fr->p.preframes;
/* Layer 3 _really_ needs at least one frame before. */
if(fr->lay==3 && preshift < 1) preshift = 1;
if(fr->hdr.lay==3 && preshift < 1) preshift = 1;
/* Layer 1 & 2 reall do not need more than 2. */
if(fr->lay!=3 && preshift > 2) preshift = 2;
if(fr->hdr.lay!=3 && preshift > 2) preshift = 2;

return fr->firstframe - preshift;
}
Expand Down Expand Up @@ -949,7 +946,7 @@ void INT123_frame_set_frameseek(mpg123_handle *fr, int64_t fe)
void INT123_frame_skip(mpg123_handle *fr)
{
#ifndef NO_LAYER3
if(fr->lay == 3) INT123_set_pointer(fr, 1, 512);
if(fr->hdr.lay == 3) INT123_set_pointer(fr, 1, 512);
#endif
}

Expand Down
46 changes: 28 additions & 18 deletions include/mpg123/src/libmpg123/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,33 @@ enum frame_state_flags
,FRAME_DECODER_LIVE = 0x8 /**< 1000 Decoder can be used. */
};

// separate frame header structure for safe decoding of headers without
// modifying the main frame struct before we are sure that we can read a
// frame into it
struct frame_header
{
int lay;
// lots of flags that could share storage, should reform that
int lsf; /* 0: MPEG 1.0; 1: MPEG 2.0/2.5 -- both used as bool and array index! */
int mpeg25;
int error_protection;
int bitrate_index;
int sampling_frequency;
int padding;
int extension;
int mode;
int mode_ext;
int copyright;
int original;
int emphasis;
// Even 16 bit int is enough for MAXFRAMESIZE
int framesize; /* computed framesize */
int freeformat;
int freeformat_framesize;
// Derived from header and checked against the above.
int ssize;
};

/* There is a lot to condense here... many ints can be merged as flags; though the main space is still consumed by buffers. */
struct mpg123_handle_struct
{
Expand Down Expand Up @@ -197,26 +224,12 @@ struct mpg123_handle_struct
int single;
int II_sblimit;
int down_sample_sblimit;
int lsf; /* 0: MPEG 1.0; 1: MPEG 2.0/2.5 -- both used as bool and array index! */
/* Many flags in disguise as integers... wasting bytes. */
int mpeg25;
int down_sample;
int header_change;
int lay;
struct frame_header hdr;
long spf; /* cached count of samples per frame */
int (*do_layer)(mpg123_handle *);
int error_protection;
int bitrate_index;
int sampling_frequency;
int padding;
int extension;
int mode;
int mode_ext;
int copyright;
int original;
int emphasis;
int framesize; /* computed framesize */
int freesize; /* free format frame size */
enum mpg123_vbr vbr; /* 1 if variable bitrate was detected */
int64_t num; /* frame offset ... */
int64_t input_offset; /* byte offset of this frame in input stream */
Expand All @@ -225,8 +238,6 @@ struct mpg123_handle_struct
int state_flags;
char silent_resync; /* Do not complain for the next n resyncs. */
unsigned char* xing_toc; /* The seek TOC from Xing header. */
int freeformat;
long freeformat_framesize;

/* bitstream info; bsi */
int bitindex;
Expand All @@ -253,7 +264,6 @@ struct mpg123_handle_struct
double mean_framesize;
int64_t mean_frames;
int fsizeold;
int ssize;
unsigned int bitreservoir;
unsigned char bsspace[2][MAXFRAMESIZE+512+4]; /* MAXFRAMESIZE */
unsigned char *bsbuf;
Expand Down
2 changes: 1 addition & 1 deletion include/mpg123/src/libmpg123/layer1.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ int INT123_do_layer1(mpg123_handle *fr)
real (*fraction)[SBLIMIT] = fr->layer1.fraction; /* fraction[2][SBLIMIT] */
int single = fr->single;

fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32;
fr->jsbound = (fr->hdr.mode == MPG_MD_JOINT_STEREO) ? (fr->hdr.mode_ext<<2)+4 : 32;

if(stereo == 1 || single == SINGLE_MIX) /* I don't see mixing handled here */
single = SINGLE_LEFT;
Expand Down
6 changes: 3 additions & 3 deletions include/mpg123/src/libmpg123/layer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ static void II_select_table(mpg123_handle *fr)
const struct al_table *tables[5] = { alloc_0, alloc_1, alloc_2, alloc_3 , alloc_4 };
const int sblims[5] = { 27 , 30 , 8, 12 , 30 };

if(fr->sampling_frequency >= 3) /* Or equivalent: (fr->lsf == 1) */
if(fr->hdr.sampling_frequency >= 3) /* Or equivalent: (fr->lsf == 1) */
table = 4;
else
table = translate[fr->sampling_frequency][2-fr->stereo][fr->bitrate_index];
table = translate[fr->hdr.sampling_frequency][2-fr->stereo][fr->hdr.bitrate_index];

sblim = sblims[table];
fr->alloc = tables[table];
Expand All @@ -337,7 +337,7 @@ int INT123_do_layer2(mpg123_handle *fr)
int single = fr->single;

II_select_table(fr);
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : fr->II_sblimit;
fr->jsbound = (fr->hdr.mode == MPG_MD_JOINT_STEREO) ? (fr->hdr.mode_ext<<2)+4 : fr->II_sblimit;

if(fr->jsbound > fr->II_sblimit)
{
Expand Down
Loading

0 comments on commit fd4fa76

Please sign in to comment.