|
From: <sv...@op...> - 2026-10-23 15:53:14
|
Author: manx Date: Fri Oct 23 17:53:07 2026 New Revision: 25794 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=25794 Log: [Var] LAME: Update to 4.0 (2026-07-11). See <https://bugs.openmpt.org/view.php?id=1991>. Modified: trunk/OpenMPT/include/lame/ (props changed) trunk/OpenMPT/include/lame/OpenMPT.txt trunk/OpenMPT/include/lame/include/lame.h trunk/OpenMPT/include/lame/libmp3lame/VbrTag.c trunk/OpenMPT/include/lame/libmp3lame/id3tag.c trunk/OpenMPT/include/lame/libmp3lame/machine.h trunk/OpenMPT/include/lame/libmp3lame/util.c trunk/OpenMPT/include/lame/libmp3lame/version.c trunk/OpenMPT/include/lame/libmp3lame/version.h Modified: trunk/OpenMPT/include/lame/OpenMPT.txt ============================================================================== --- trunk/OpenMPT/include/lame/OpenMPT.txt Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/OpenMPT.txt Fri Oct 23 17:53:07 2026 (r25794) @@ -1,4 +1,4 @@ -lame library version 3.101. +lame library version 4.0. The following changes have been made: * Obviously, unnecessary folders and files have been removed. * export ordinals in `include/lame.def` have been removed Modified: trunk/OpenMPT/include/lame/include/lame.h ============================================================================== --- trunk/OpenMPT/include/lame/include/lame.h Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/include/lame.h Fri Oct 23 17:53:07 2026 (r25794) @@ -1308,7 +1308,7 @@ int CDECL id3tag_set_comment_utf16(lame_t gfp, char const *lang, unsigned short const *desc, unsigned short const *text); /* experimental */ -int CDECL id3tag_set_textinfo_utf8(lame_t gfp, char const *id, unsigned short const *text); +int CDECL id3tag_set_textinfo_utf8(lame_t gfp, char const *id, char const *text); /* experimental */ int CDECL id3tag_set_comment_utf8(lame_t gfp, char const *lang, char const *desc, char const *text); Modified: trunk/OpenMPT/include/lame/libmp3lame/VbrTag.c ============================================================================== --- trunk/OpenMPT/include/lame/libmp3lame/VbrTag.c Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/libmp3lame/VbrTag.c Fri Oct 23 17:53:07 2026 (r25794) @@ -782,6 +782,12 @@ CreateI4(&pbtStreamBuffer[nBytesWritten], nQuality); nBytesWritten += 4; + /*! \par LAME tag: encoder-version sub-field, fixed 9-byte width. + * \c szVersion (\c get_lame_tag_encoder_short_version()) must fit in + * 9 bytes - see the \c \\par blocks in that function's doc comment in + * \c version.c for the exact byte budget, the reason the width can't + * be changed, and the compile-time check that enforces it. `strncpy` + * silently truncates (and skips the NUL terminator) if it doesn't fit. */ strncpy((char *) &pbtStreamBuffer[nBytesWritten], szVersion, 9); nBytesWritten += 9; Modified: trunk/OpenMPT/include/lame/libmp3lame/id3tag.c ============================================================================== --- trunk/OpenMPT/include/lame/libmp3lame/id3tag.c Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/libmp3lame/id3tag.c Fri Oct 23 17:53:07 2026 (r25794) @@ -639,17 +639,15 @@ static int -id3tag_set_genre_utf8(lame_t gfp, unsigned short const* text) +id3tag_set_genre_utf8(lame_t gfp, char const* text) { lame_internal_flags* gfc = gfp->internal_flags; int ret; if (text == 0) { return -3; } - if (maybeLatin1(text)) { - char* latin1 = local_strdup_utf16_to_latin1(text); - int num = lookupGenre(latin1); - free(latin1); + { + int num = lookupGenre(text); if (num == -1) return -1; /* number out of range */ if (num >= 0) { /* common genre found */ gfc->tag_spec.flags |= CHANGED_FLAG; @@ -1083,6 +1081,9 @@ if (a >= 0) { char* dup = 0; local_strdup(&dup, fieldvalue); + if (dup == 0) { + return -254; /* memory problem */ + } dup[a] = 0; rc = id3v2_add_latin1_lng(gfp, id, dup, dup+a+1); free(dup); @@ -1099,6 +1100,9 @@ if (a >= 0) { char* dup = 0; local_strdup(&dup, fieldvalue); + if (dup == 0) { + return -254; /* memory problem */ + } dup[a] = 0; rc = id3v2_add_utf8_lng(gfp, id, dup, dup+a+1); free(dup); @@ -1125,7 +1129,7 @@ } int -id3tag_set_textinfo_utf8(lame_t gfp, char const *id, unsigned short const *text) +id3tag_set_textinfo_utf8(lame_t gfp, char const *id, char const *text) { uint32_t const frame_id = toID3v2TagId(id); if (frame_id == 0) { Modified: trunk/OpenMPT/include/lame/libmp3lame/machine.h ============================================================================== --- trunk/OpenMPT/include/lame/libmp3lame/machine.h Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/libmp3lame/machine.h Fri Oct 23 17:53:07 2026 (r25794) @@ -157,7 +157,14 @@ #define dimension_of(array) (sizeof(array)/sizeof(array[0])) #define beyond(array) (array+dimension_of(array)) -#define compiletime_assert(expression) enum{static_assert_##FILE##_##LINE = 1/((expression)?1:0)} +/* ##-pasting does not expand its operands, so pasting __LINE__ directly would + * yield the literal token "__LINE__" instead of the current line number, + * making every use in a translation unit collide on the same enum tag. The + * extra indirection through compiletime_assert_paste() forces __LINE__ to be + * expanded to its numeric value before compiletime_assert_paste2() pastes it. */ +#define compiletime_assert_paste2(a,b) a##b +#define compiletime_assert_paste(a,b) compiletime_assert_paste2(a,b) +#define compiletime_assert(expression) enum{compiletime_assert_paste(static_assert_line_,__LINE__) = 1/((expression)?1:0)} #define lame_calloc(TYPE, COUNT) ((TYPE*)calloc(COUNT, sizeof(TYPE))) #define multiple_of(CHUNK, COUNT) (\ ( (COUNT) < 1 || (CHUNK) < 1 || (COUNT) % (CHUNK) == 0 ) \ Modified: trunk/OpenMPT/include/lame/libmp3lame/util.c ============================================================================== --- trunk/OpenMPT/include/lame/libmp3lame/util.c Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/libmp3lame/util.c Fri Oct 23 17:53:07 2026 (r25794) @@ -602,6 +602,15 @@ /* blackman filter. by default, window centered at j+.5(filter_l%2) */ /* but we want a window centered at time0. */ offset = (time0 - esv->itime[ch] - (j + .5 * (filter_l % 2))); + /* offset is bounded to [-0.5, +0.5) by construction, so joff below + always lands within blackfilt[0 .. 2*bpc] and never over-indexes + the table: for a non-integer resample ratio filter_l is odd, making + offset the fractional part of (time0 - itime) minus 0.5; for a + (near-)integer ratio the intratio branch above is only taken when + the ratio is an *exact* integer (samplerate_in an exact multiple of + samplerate_out), where offset is identically 0. Sample rates are + always integers, so no runtime bounds guard is needed here - the + assert is a development-time sanity check, compiled out under NDEBUG. */ assert(fabs(offset) <= .501); /* find the closest precomputed window for this offset: */ Modified: trunk/OpenMPT/include/lame/libmp3lame/version.c ============================================================================== --- trunk/OpenMPT/include/lame/libmp3lame/version.c Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/libmp3lame/version.c Fri Oct 23 17:53:07 2026 (r25794) @@ -141,7 +141,27 @@ It's used in the LAME VBR tag only, limited to 9 characters max. Due to some 3rd party HW/SW decoders, it has to start with LAME. - \param void + \par Field width and format (fixed, binary-compatibility critical) + This string is copied into a **fixed 9-byte** field of the LAME tag that + gets embedded in every encoded MP3 stream (see \c VbrTag.c, + \c LAMEHEADERSIZE and the \c strncpy(...,9) call in the tag-writing code). + Widening that field would shift every subsequent byte of the tag and break + every third-party decoder that parses it at a fixed offset - it is not + adjustable. The format itself (`"LAME" major "." minor type`) is likewise + fixed for the same reason: some decoders reportedly pattern-match on it. + + \par Byte budget + `strlen("LAME")` (4) + `strlen(major)` + `strlen(".")` (1) + + `strlen(minor)` + `strlen(type)` (1, always exactly one character: + `'a'`/`'b'`/`'r'`/`' '`) must not exceed 9, i.e. + \code + strlen(major) + strlen(minor) <= 3 + \endcode + This invariant is enforced at compile time right below this function + (`compiletime_assert`) - if it ever trips, the version numbers (not this + field's width or format) are what needs to change. + + \param void \return a pointer to the short version of the LAME version string. */ const char* @@ -154,6 +174,11 @@ return str; } +/*! Enforces the byte budget documented above at compile time: catches an + * overflow the moment a version bump reintroduces it, instead of letting + * it silently truncate at run time. */ +compiletime_assert(sizeof("LAME" STR(LAME_MAJOR_VERSION) "." STR(LAME_MINOR_VERSION) P) - 1 <= 9); + /*! Get the version string for GPSYCHO. */ /*! \param void Modified: trunk/OpenMPT/include/lame/libmp3lame/version.h ============================================================================== --- trunk/OpenMPT/include/lame/libmp3lame/version.h Fri Oct 23 17:48:25 2026 (r25793) +++ trunk/OpenMPT/include/lame/libmp3lame/version.h Fri Oct 23 17:53:07 2026 (r25794) @@ -34,8 +34,8 @@ # define LAME_URL "https://lame.sourceforge.io" -# define LAME_MAJOR_VERSION 3 /* Major version number */ -# define LAME_MINOR_VERSION 101 /* Minor version number */ +# define LAME_MAJOR_VERSION 4 /* Major version number */ +# define LAME_MINOR_VERSION 0 /* Minor version number */ # define LAME_TYPE_VERSION 2 /* 0:alpha 1:beta 2:release */ # define LAME_PATCH_VERSION 0 /* Patch level */ # define LAME_ALPHA_VERSION (LAME_TYPE_VERSION==0) |