Ticket #23587: lame-4.0-upstream_fixes-1.patch

File lame-4.0-upstream_fixes-1.patch, 7.6 KB (added by zeckma, 3 months ago)

Here is a patch I created to fix LAME-4.0 without the need for CFLAGS and it properly fixes the code.

  • frontend/parse.c

    Submitted by:            Zeckma
    Date:                    2026-08-02
    Initial Package Version: 4.0
    Origin:                  Upstream
    Upstream Status:         Applied
    Description:             Fixes multiple build failures and fixes some settings.
    
    diff '--color=auto' -Naurp lame-4.0.orig/frontend/parse.c lame-4.0/frontend/parse.c
    old new static int getIntValue(char const* token  
    402402}
    403403
    404404#ifdef ID3TAGS_EXTENDED
     405/* Set an ID3v2 tag field from UTF-16 data. The data pointer is genuinely
     406   UTF-16 here, so the UTF-16 id3tag_* setters are used throughout. */
    405407static int
    406 set_id3v2tag(lame_global_flags* gfp, TextEncoding enc, int type, unsigned short const* str)
     408set_id3v2tag_utf16(lame_global_flags* gfp, int type, unsigned short const* str)
    407409{
    408     switch (enc)
     410    switch (type)
    409411    {
    410         case TENC_UTF8:
    411             switch (type)
    412             {
    413                 case 'a': return id3tag_set_textinfo_utf8(gfp, "TPE1", str);
    414                 case 't': return id3tag_set_textinfo_utf8(gfp, "TIT2", str);
    415                 case 'l': return id3tag_set_textinfo_utf8(gfp, "TALB", str);
    416                 case 'g': return id3tag_set_textinfo_utf8(gfp, "TCON", str);
    417                 case 'c': return id3tag_set_comment_ucs2(gfp, 0, 0, str);
    418                 case 'n': return id3tag_set_textinfo_utf8(gfp, "TRCK", str);
    419                 case 'y': return id3tag_set_textinfo_utf8(gfp, "TYER", str);
    420                 case 'v': return id3tag_set_fieldvalue_ucs2(gfp, str);
    421             }
    422             ;;
    423         case TENC_UTF16:
    424             switch (type)
    425             {
    426412                case 'a': return id3tag_set_textinfo_utf16(gfp, "TPE1", str);
    427                 case 't': return id3tag_set_textinfo_utf16(gfp, "TIT2", str);
    428                 case 'l': return id3tag_set_textinfo_utf16(gfp, "TALB", str);
    429                 case 'g': return id3tag_set_textinfo_utf16(gfp, "TCON", str);
    430                 case 'c': return id3tag_set_comment_utf16(gfp, 0, 0, str);
    431                 case 'n': return id3tag_set_textinfo_utf16(gfp, "TRCK", str);
    432                 case 'y': return id3tag_set_textinfo_utf16(gfp, "TYER", str);
    433                 case 'v': return id3tag_set_fieldvalue_utf16(gfp, str);
    434             }
    435             ;;
    436         default:
    437             return -3;
     413        case 't': return id3tag_set_textinfo_utf16(gfp, "TIT2", str);
     414        case 'l': return id3tag_set_textinfo_utf16(gfp, "TALB", str);
     415        case 'g': return id3tag_set_textinfo_utf16(gfp, "TCON", str);
     416        case 'c': return id3tag_set_comment_utf16(gfp, 0, 0, str);
     417        case 'n': return id3tag_set_textinfo_utf16(gfp, "TRCK", str);
     418        case 'y': return id3tag_set_textinfo_utf16(gfp, "TYER", str);
     419        case 'v': return id3tag_set_fieldvalue_utf16(gfp, str);
     420    }
     421    return -3;
     422}
     423
     424/* Set an ID3v2 tag field from UTF-8 data. The data pointer is a UTF-8 char
     425   string (not UTF-16 as the old, mistyped single handler assumed), so the
     426   UTF-8 id3tag_* setters are used - including id3tag_set_fieldvalue_utf8 for
     427   'v', which replaces the removed *_ucs2 calls the UTF-8 path used to make. */
     428static int
     429set_id3v2tag_utf8(lame_global_flags* gfp, int type, char const* str)
     430{
     431    switch (type)
     432    {
     433        case 'a': return id3tag_set_textinfo_utf8(gfp, "TPE1", str);
     434        case 't': return id3tag_set_textinfo_utf8(gfp, "TIT2", str);
     435        case 'l': return id3tag_set_textinfo_utf8(gfp, "TALB", str);
     436        case 'g': return id3tag_set_textinfo_utf8(gfp, "TCON", str);
     437        case 'c': return id3tag_set_comment_utf8(gfp, 0, 0, str);
     438        case 'n': return id3tag_set_textinfo_utf8(gfp, "TRCK", str);
     439        case 'y': return id3tag_set_textinfo_utf8(gfp, "TYER", str);
     440        case 'v': return id3tag_set_fieldvalue_utf8(gfp, str);
    438441    }
     442    return -3;
    439443}
    440444#endif
    441445
    … … id3_tag(lame_global_flags* gfp, int type  
    480484        default:
    481485#ifdef ID3TAGS_EXTENDED
    482486        case TENC_LATIN1: result = set_id3tag(gfp, type, x);   break;
    483         case TENC_UTF16:  result = set_id3v2tag(gfp, enc, type, x); break;
    484         case TENC_UTF8:   result = set_id3v2tag(gfp, enc, type, x); break;
     487        case TENC_UTF16:  result = set_id3v2tag_utf16(gfp, type, x); break;
     488        case TENC_UTF8:   result = set_id3v2tag_utf8(gfp, type, x); break;
    485489#else
    486490        case TENC_RAW:    result = set_id3tag(gfp, type, x);   break;
    487491#endif
  • include/lame.def

    diff '--color=auto' -Naurp lame-4.0.orig/include/lame.def lame-4.0/include/lame.def
    old new id3tag_set_textinfo_utf8 @2028  
    306306; two external functions for ID3v2.4 tag support
    307307id3tag_add_v2_4_UTF8 @2029
    308308id3tag_v2_4_UTF8_only @2030
     309
     310; UTF-8 field-value setter (companion to id3tag_set_fieldvalue_utf16)
     311id3tag_set_fieldvalue_utf8 @2031
  • include/lame.h

    diff '--color=auto' -Naurp lame-4.0.orig/include/lame.h lame-4.0/include/lame.h
    old new int CDECL id3tag_set_fieldvalue_ucs2(lam  
    12971297int CDECL id3tag_set_fieldvalue_utf16(lame_t gfp, const unsigned short *fieldvalue);
    12981298
    12991299/* experimental */
     1300int CDECL id3tag_set_fieldvalue_utf8(lame_t gfp, const char *fieldvalue);
     1301
     1302/* experimental */
    13001303int CDECL id3tag_set_textinfo_utf16(lame_t gfp, char const *id, unsigned short const *text);
    13011304
    13021305/* experimental */
  • include/libmp3lame.sym

    diff '--color=auto' -Naurp lame-4.0.orig/include/libmp3lame.sym lame-4.0/include/libmp3lame.sym
    old new hip_decode_headers  
    193193hip_decode1
    194194hip_decode1_headers
    195195hip_decode1_headersB
     196hip_finish_pinfo
    196197lame_decode_init
    197198lame_decode
    198199lame_decode_headers
    … … id3tag_set_textinfo_ucs2  
    229230id3tag_set_comment_ucs2
    230231id3tag_set_fieldvalue_ucs2
    231232id3tag_set_fieldvalue_utf16
     233id3tag_set_fieldvalue_utf8
    232234id3tag_set_textinfo_utf16
    233235id3tag_set_comment_utf16
    234236id3tag_set_textinfo_utf8
  • libmp3lame/id3tag.c

    diff '--color=auto' -Naurp lame-4.0.orig/libmp3lame/id3tag.c lame-4.0/libmp3lame/id3tag.c
    old new id3tag_set_fieldvalue_ucs2(lame_t gfp, c  
    18441844    return id3tag_set_fieldvalue_utf16(gfp, fieldvalue);
    18451845}
    18461846
     1847int
     1848id3tag_set_fieldvalue_utf8(lame_t gfp, const char *fieldvalue)
     1849{
     1850    if (is_lame_internal_flags_null(gfp)) {
     1851        return 0;
     1852    }
     1853    if (fieldvalue && *fieldvalue) {
     1854        if (strlen(fieldvalue) < 5 || fieldvalue[4] != '=') {
     1855            return -1;
     1856        }
     1857        return id3tag_set_textinfo_utf8(gfp, fieldvalue, &fieldvalue[5]);
     1858    }
     1859    return 0;
     1860}
     1861
    18471862size_t
    18481863lame_get_id3v2_tag(lame_t gfp, unsigned char *buffer, size_t size)
    18491864{
  • libmp3lame/lame.c

    diff '--color=auto' -Naurp lame-4.0.orig/libmp3lame/lame.c lame-4.0/libmp3lame/lame.c
    old new lame_init_params(lame_global_flags * gfp  
    10501050            if (gfp->quality < 0)
    10511051                gfp->quality = LAME_DEFAULT_QUALITY;
    10521052
     1053            /* VBR and ABR don't give good results with noise shaping
     1054             * settings used in quality levels below 4.
     1055             */
     1056            if (gfp->quality < 4)
     1057                gfp->quality = 4;
     1058
    10531059
    10541060            if (cfg->vbr == vbr_off)
    10551061                (void) lame_set_VBR_mean_bitrate_kbps(gfp, gfp->brate);