From 2f8a7f36f547b582c1826dd8e31cd06e1a113d97 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sun, 4 Feb 2018 16:37:07 +0100 Subject: [PATCH] [LIBMPG123] Update to version 1.25.8. CORE-14291 --- sdk/include/reactos/libs/libmpg123/config.h | 6 +-- sdk/include/reactos/libs/libmpg123/getbits.h | 1 + sdk/include/reactos/libs/libmpg123/mpeghead.h | 2 +- sdk/include/reactos/libs/libmpg123/mpg123.h | 2 +- sdk/lib/3rdparty/libmpg123/layer3.c | 48 +++++++++++++++++-- sdk/lib/3rdparty/libmpg123/parse.c | 21 +------- 6 files changed, 52 insertions(+), 28 deletions(-) diff --git a/sdk/include/reactos/libs/libmpg123/config.h b/sdk/include/reactos/libs/libmpg123/config.h index e481e8dfb2e..3f3fdbc9b85 100644 --- a/sdk/include/reactos/libs/libmpg123/config.h +++ b/sdk/include/reactos/libs/libmpg123/config.h @@ -356,7 +356,7 @@ #define PACKAGE_NAME "mpg123" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "mpg123 1.25.6" +#define PACKAGE_STRING "mpg123 1.25.8" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "mpg123" @@ -365,7 +365,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.25.6" +#define PACKAGE_VERSION "1.25.8" /* Define if portaudio v18 API is wanted. */ /* #undef PORTAUDIO18 */ @@ -398,7 +398,7 @@ /* #undef USE_YASM_FOR_AVX */ /* Version number of package */ -#define VERSION "1.25.6" +#define VERSION "1.25.8" /* Define to use Win32 named pipes */ #define WANT_WIN32_FIFO 1 diff --git a/sdk/include/reactos/libs/libmpg123/getbits.h b/sdk/include/reactos/libs/libmpg123/getbits.h index b250b6ca3da..4b452f9d3d1 100644 --- a/sdk/include/reactos/libs/libmpg123/getbits.h +++ b/sdk/include/reactos/libs/libmpg123/getbits.h @@ -45,6 +45,7 @@ static unsigned int getbits(mpg123_handle *fr, int number_of_bits) fprintf(stderr,"g%d",number_of_bits); #endif /* Safety catch until we got the nasty code fully figured out. */ + /* No, that catch stays here, even if we think we got it figured out! */ if( (long)(fr->wordpointer-fr->bsbuf)*8 + fr->bitindex+number_of_bits > (long)fr->framesize*8 ) return 0; diff --git a/sdk/include/reactos/libs/libmpg123/mpeghead.h b/sdk/include/reactos/libs/libmpg123/mpeghead.h index 549d0ee9fb5..7696df748ab 100644 --- a/sdk/include/reactos/libs/libmpg123/mpeghead.h +++ b/sdk/include/reactos/libs/libmpg123/mpeghead.h @@ -78,7 +78,7 @@ #define HDR_CMPMASK (HDR_SYNC|HDR_VERSION|HDR_LAYER|HDR_SAMPLERATE) /* A stricter mask, for matching free format headers. */ -#define HDR_SAMEMASK (HDR_SYNC|HDR_VERSION|HDR_LAYER|HDR_BITRATE|HDR_SAMPLERATE|HDR_CHANNEL|HDR_CHANEX) +#define HDR_SAMEMASK (HDR_SYNC|HDR_VERSION|HDR_LAYER|HDR_BITRATE|HDR_SAMPLERATE|HDR_CHANNEL) /* Free format headers have zero bitrate value. */ #define HDR_FREE_FORMAT(head) (!(head & HDR_BITRATE)) diff --git a/sdk/include/reactos/libs/libmpg123/mpg123.h b/sdk/include/reactos/libs/libmpg123/mpg123.h index 71677a4c2b3..f7dd4a59043 100644 --- a/sdk/include/reactos/libs/libmpg123/mpg123.h +++ b/sdk/include/reactos/libs/libmpg123/mpg123.h @@ -1,5 +1,5 @@ /* - libmpg123: MPEG Audio Decoder library (version 1.25.6) + libmpg123: MPEG Audio Decoder library (version 1.25.8) copyright 1995-2015 by the mpg123 project free software under the terms of the LGPL 2.1 diff --git a/sdk/lib/3rdparty/libmpg123/layer3.c b/sdk/lib/3rdparty/libmpg123/layer3.c index a3e7fee834c..917f3abf914 100644 --- a/sdk/lib/3rdparty/libmpg123/layer3.c +++ b/sdk/lib/3rdparty/libmpg123/layer3.c @@ -280,10 +280,12 @@ void init_layer3(void) int *mp; int cb,lwin; const unsigned char *bdf; + int switch_idx; mp = map[j][0] = mapbuf0[j]; bdf = bi->longDiff; - for(i=0,cb = 0; cb < 8 ; cb++,i+=*bdf++) + switch_idx = (j < 3) ? 8 : 6; + for(i=0,cb = 0; cb < switch_idx ; cb++,i+=*bdf++) { *mp++ = (*bdf) >> 1; *mp++ = i; @@ -465,8 +467,14 @@ static int III_get_side_info(mpg123_handle *fr, struct III_sideinfo *si,int ster } gr_info->pow2gain = fr->gainpow2+256 - getbits_fast(fr, 8) + powdiff; if(ms_stereo) gr_info->pow2gain += 2; - gr_info->scalefac_compress = getbits(fr, tab[4]); + if(gr_info->part2_3_length == 0) + { + if(gr_info->scalefac_compress > 0) + debug1( "scalefac_compress _should_ be zero instead of %i" + , gr_info->scalefac_compress ); + gr_info->scalefac_compress = 0; + } if(get1bit(fr)) { /* window switch flag */ @@ -553,6 +561,14 @@ 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; @@ -667,6 +683,14 @@ 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) + { + int i; + for(i=0;i<39;i++) + *scf++ = 0; + return 0; + } + for(i=0;i<4;i++) { int num = slen & 0x7; @@ -680,7 +704,7 @@ static int III_get_scale_factors_2(mpg123_handle *fr, int *scf,struct gr_info_s else for(j=0;j<(int)(pnt[i]);j++) *scf++ = 0; } - + n = (n << 1) + 1; for(i=0;ipart2_3_length > 0) + { + /* mhipp tree has this split up a bit... */ int num=getbitoffset(fr); MASK_TYPE mask; @@ -1197,6 +1227,18 @@ static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT],in backbits(fr, num); num = 0; + } + else + { + part2remain = 0; + /* Not entirely sure what good values are, must be > 0. */ + gr_info->maxband[0] = + gr_info->maxband[1] = + gr_info->maxband[2] = + gr_info->maxbandl = 0; + gr_info->maxb = 1; + } + while(xrpnt < &xr[SBLIMIT][0]) *xrpnt++ = DOUBLE_TO_REAL(0.0); diff --git a/sdk/lib/3rdparty/libmpg123/parse.c b/sdk/lib/3rdparty/libmpg123/parse.c index 2e3652e8c31..e0059a7feea 100644 --- a/sdk/lib/3rdparty/libmpg123/parse.c +++ b/sdk/lib/3rdparty/libmpg123/parse.c @@ -889,26 +889,7 @@ void set_pointer(mpg123_handle *fr, long backstep) double compute_bpf(mpg123_handle *fr) { - double bpf; - - switch(fr->lay) - { - case 1: - bpf = tabsel_123[fr->lsf][0][fr->bitrate_index]; - bpf *= 12000.0 * 4.0; - bpf /= freqs[fr->sampling_frequency] <<(fr->lsf); - break; - case 2: - case 3: - bpf = tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index]; - bpf *= 144000; - bpf /= freqs[fr->sampling_frequency] << (fr->lsf); - break; - default: - bpf = 1.0; - } - - return bpf; + return (fr->framesize > 0) ? fr->framesize + 4.0 : 1.0; } int attribute_align_arg mpg123_spf(mpg123_handle *mh) -- 2.17.1