| 1 | /* |
| 2 | * id3tag.c -- Write ID3 version 1 and 2 tags. |
| 3 | * |
| 4 | * Copyright (C) 2000 Don Melton |
| 5 | * Copyright (C) 2011-2017 Robert Hegemann |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Library General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Library General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Library General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * HISTORY: This source file is part of LAME (see http://www.mp3dev.org) |
| 24 | * and was originally adapted by Conrad Sanderson <[email protected]> |
| 25 | * from mp3info by Ricardo Cerqueira <[email protected]> to write only ID3 version 1 |
| 26 | * tags. Don Melton <[email protected]> COMPLETELY rewrote it to support version |
| 27 | * 2 tags and be more conformant to other standards while remaining flexible. |
| 28 | * |
| 29 | * NOTE: See http://id3.org/ for more information about ID3 tag formats. |
| 30 | */ |
| 31 | |
| 32 | /* $Id: id3tag.c,v 1.80 2017/08/28 15:39:51 robert Exp $ */ |
| 33 | |
| 34 | //#ifdef HAVE_CONFIG_H |
| 35 | #include "lame__config.h"cxx . . $ `<file>/external/lame/lame__config.h`/ |
| 36 | //#endif |
| 37 | |
| 38 | #ifdef STDC_HEADERScxx . . $ `external/lame/lame__config.h:283:9`! |
| 39 | # include <stddef.h> |
| 40 | # include <stdlib.h> |
| 41 | # include <string.h> |
| 42 | # include <ctype.h> |
| 43 | #else |
| 44 | # ifndef HAVE_STRCHR |
| 45 | # define strchr index |
| 46 | # define strrchr rindex |
| 47 | # endif |
| 48 | char *strchr(), *strrchr(); |
| 49 | # ifndef HAVE_MEMCPY |
| 50 | #error weird |
| 51 | # define memcpy(d, s, n) bcopy ((s), (d), (n)) |
| 52 | # endif |
| 53 | #endif |
| 54 | |
| 55 | |
| 56 | #include "lame.h"cxx . . $ `<file>/external/lame/lame.h`/ |
| 57 | #include "machine.h"cxx . . $ `<file>/external/lame/machine.h`/ |
| 58 | #include "encoder.h"cxx . . $ `<file>/external/lame/encoder.h`/ |
| 59 | #include "id3tag.h"cxx . . $ `<file>/external/lame/id3tag.h`/ |
| 60 | #include "lame_global_flags.h"cxx . . $ `<file>/external/lame/lame_global_flags.h`/ |
| 61 | #include "util.h"cxx . . $ `<file>/external/lame/util.h`/ |
| 62 | #include "bitstream.h"cxx . . $ `<file>/external/lame/bitstream.h`/ |
| 63 | |
| 64 | |
| 65 | static const char *const genre_namescxx . . $ genre_names.[] = { |
| 66 | /* |
| 67 | * NOTE: The spelling of these genre names is identical to those found in |
| 68 | * Winamp and mp3info. |
| 69 | */ |
| 70 | "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", |
| 71 | "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", |
| 72 | "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", |
| 73 | "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", |
| 74 | "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", |
| 75 | "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "Alternative Rock", |
| 76 | "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", |
| 77 | "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", |
| 78 | "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", |
| 79 | "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", |
| 80 | "Native US", "Cabaret", "New Wave", "Psychedelic", "Rave", |
| 81 | "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", |
| 82 | "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", |
| 83 | "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", |
| 84 | "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", |
| 85 | "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", |
| 86 | "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", |
| 87 | "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", |
| 88 | "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", |
| 89 | "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", |
| 90 | "Punk Rock", "Drum Solo", "A Cappella", "Euro-House", "Dance Hall", |
| 91 | "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", |
| 92 | "BritPop", "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta", |
| 93 | "Heavy Metal", "Black Metal", "Crossover", "Contemporary Christian", |
| 94 | "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop", |
| 95 | "SynthPop" |
| 96 | }; |
| 97 | |
| 98 | #define GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`! \ |
| 99 | ((int)(sizeof genre_names / sizeof (const char *const))) |
| 100 | |
| 101 | static const int genre_alpha_mapcxx . . $ genre_alpha_map.[] = { |
| 102 | 123, 34, 74, 73, 99, 20, 40, 26, 145, 90, 116, 41, 135, 85, 96, 138, 89, 0, |
| 103 | 107, 132, 65, 88, 104, 102, 97, 136, 61, 141, 32, 1, 112, 128, 57, 140, 2, |
| 104 | 139, 58, 3, 125, 50, 22, 4, 55, 127, 122, 120, 98, 52, 48, 54, 124, 25, 84, |
| 105 | 80, 115, 81, 119, 5, 30, 36, 59, 126, 38, 49, 91, 6, 129, 79, 137, 7, 35, |
| 106 | 100, 131, 19, 33, 46, 47, 8, 29, 146, 63, 86, 71, 45, 142, 9, 77, 82, 64, |
| 107 | 133, 10, 66, 39, 11, 103, 12, 75, 134, 13, 53, 62, 109, 117, 23, 108, 92, |
| 108 | 67, 93, 43, 121, 15, 68, 14, 16, 76, 87, 118, 17, 78, 143, 114, 110, 69, 21, |
| 109 | 111, 95, 105, 42, 37, 24, 56, 44, 101, 83, 94, 106, 147, 113, 18, 51, 130, |
| 110 | 144, 60, 70, 31, 72, 27, 28 |
| 111 | }; |
| 112 | |
| 113 | #define GENRE_ALPHA_COUNTcxx . . $ `external/lame/id3tag.c:113:9`! ((int)(sizeof genre_alpha_map / sizeof (int))) |
| 114 | |
| 115 | #define GENRE_INDEX_OTHERcxx . . $ `external/lame/id3tag.c:115:9`! 12 |
| 116 | |
| 117 | |
| 118 | #define FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!(a, b, c, d) \ |
| 119 | ( ((unsigned long)(a) << 24) \ |
| 120 | | ((unsigned long)(b) << 16) \ |
| 121 | | ((unsigned long)(c) << 8) \ |
| 122 | | ((unsigned long)(d) << 0) ) |
| 123 | |
| 124 | typedef enum UsualStringIDscxx . . $ UsualStringIDs# { ID_TITLEcxx . . $ ID_TITLE. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'I', 'T', '2') |
| 125 | , ID_ARTISTcxx . . $ ID_ARTIST. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'P', 'E', '1') |
| 126 | , ID_ALBUMcxx . . $ ID_ALBUM. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'A', 'L', 'B') |
| 127 | , ID_GENREcxx . . $ ID_GENRE. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'C', 'O', 'N') |
| 128 | , ID_ENCODERcxx . . $ ID_ENCODER. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'S', 'S', 'E') |
| 129 | , ID_PLAYLENGTHcxx . . $ ID_PLAYLENGTH. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'L', 'E', 'N') |
| 130 | , ID_COMMENTcxx . . $ ID_COMMENT. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('C', 'O', 'M', 'M') /* full text string */ |
| 131 | } UsualStringIDscxx . . $ UsualStringIDs#; |
| 132 | |
| 133 | typedef enum NumericStringIDscxx . . $ NumericStringIDs# { ID_DATEcxx . . $ ID_DATE. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'D', 'A', 'T') /* "ddMM" */ |
| 134 | , ID_TIMEcxx . . $ ID_TIME. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'I', 'M', 'E') /* "hhmm" */ |
| 135 | , ID_TPOScxx . . $ ID_TPOS. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'P', 'O', 'S') /* '0'-'9' and '/' allowed */ |
| 136 | , ID_TRACKcxx . . $ ID_TRACK. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'R', 'C', 'K') /* '0'-'9' and '/' allowed */ |
| 137 | , ID_YEARcxx . . $ ID_YEAR. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'Y', 'E', 'R') /* "yyyy" */ |
| 138 | } NumericStringIDscxx . . $ NumericStringIDs#; |
| 139 | |
| 140 | typedef enum MiscIDscxx . . $ MiscIDs# { ID_TXXXcxx . . $ ID_TXXX. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 'X', 'X', 'X') |
| 141 | , ID_WXXXcxx . . $ ID_WXXX. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('W', 'X', 'X', 'X') |
| 142 | , ID_SYLTcxx . . $ ID_SYLT. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('S', 'Y', 'L', 'T') |
| 143 | , ID_APICcxx . . $ ID_APIC. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('A', 'P', 'I', 'C') |
| 144 | , ID_GEOBcxx . . $ ID_GEOB. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('G', 'E', 'O', 'B') |
| 145 | , ID_PCNTcxx . . $ ID_PCNT. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('P', 'C', 'N', 'T') |
| 146 | , ID_AENCcxx . . $ ID_AENC. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('A', 'E', 'N', 'C') |
| 147 | , ID_LINKcxx . . $ ID_LINK. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('L', 'I', 'N', 'K') |
| 148 | , ID_ENCRcxx . . $ ID_ENCR. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('E', 'N', 'C', 'R') |
| 149 | , ID_GRIDcxx . . $ ID_GRID. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('G', 'R', 'I', 'D') |
| 150 | , ID_PRIVcxx . . $ ID_PRIV. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('P', 'R', 'I', 'V') |
| 151 | , ID_USLTcxx . . $ ID_USLT. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('U', 'S', 'L', 'T') /* full text string */ |
| 152 | , ID_USERcxx . . $ ID_USER. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('U', 'S', 'E', 'R') /* full text string */ |
| 153 | , ID_PCSTcxx . . $ ID_PCST. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('P', 'C', 'S', 'T') /* iTunes Podcast indicator, only presence important */ |
| 154 | , ID_WFEDcxx . . $ ID_WFED. = FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('W', 'F', 'E', 'D') /* iTunes Podcast URL as TEXT FRAME !!! violates standard */ |
| 155 | } MiscIDscxx . . $ MiscIDs#; |
| 156 | |
| 157 | |
| 158 | static int |
| 159 | frame_id_matchescxx . . $ frame_id_matches(9b79fb6aee4c0440).(int id, int mask) |
| 160 | { |
| 161 | int result = 0, i, window = 0xff; |
| 162 | for (i = 0; i < 4; ++i, window <<= 8) { |
| 163 | int const mw = (mask & window); |
| 164 | int const iw = (id & window); |
| 165 | if (mw != 0 && mw != iw) { |
| 166 | result |= iw; |
| 167 | } |
| 168 | } |
| 169 | return result; |
| 170 | } |
| 171 | |
| 172 | static int |
| 173 | isFrameIdMatchingcxx . . $ isFrameIdMatching(9b79fb6aee4c0440).(int id, int mask) |
| 174 | { |
| 175 | return frame_id_matchescxx . . $ frame_id_matches(9b79fb6aee4c0440).(id, mask) == 0 ? 1 : 0; |
| 176 | } |
| 177 | |
| 178 | static int |
| 179 | test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(lame_internal_flagscxx . . $ lame_internal_flags# const *gfc, unsigned int tst) |
| 180 | { |
| 181 | return (gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. & tst) != 0u ? 1 : 0; |
| 182 | } |
| 183 | |
| 184 | #if 0 |
| 185 | static void |
| 186 | debug_tag_spec_flags(lame_internal_flags * gfc, const char* info) |
| 187 | { |
| 188 | MSGF(gfc, "%s\n", info); |
| 189 | MSGF(gfc, "CHANGED_FLAG : %d\n", test_tag_spec_flags(gfc, CHANGED_FLAG )); |
| 190 | MSGF(gfc, "ADD_V2_FLAG : %d\n", test_tag_spec_flags(gfc, ADD_V2_FLAG )); |
| 191 | MSGF(gfc, "V1_ONLY_FLAG : %d\n", test_tag_spec_flags(gfc, V1_ONLY_FLAG )); |
| 192 | MSGF(gfc, "V2_ONLY_FLAG : %d\n", test_tag_spec_flags(gfc, V2_ONLY_FLAG )); |
| 193 | MSGF(gfc, "SPACE_V1_FLAG : %d\n", test_tag_spec_flags(gfc, SPACE_V1_FLAG)); |
| 194 | MSGF(gfc, "PAD_V2_FLAG : %d\n", test_tag_spec_flags(gfc, PAD_V2_FLAG )); |
| 195 | } |
| 196 | #endif |
| 197 | |
| 198 | static int |
| 199 | is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(lame_tcxx . . $ lame_t# gfp) |
| 200 | { |
| 201 | return (gfp && gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.) ? 0 : 1; |
| 202 | } |
| 203 | |
| 204 | static int |
| 205 | id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# frame_id, unsigned short const *desc, unsigned short const *text); |
| 206 | static int |
| 207 | id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# frame_id, char const *desc, char const *text); |
| 208 | |
| 209 | |
| 210 | static void |
| 211 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(lame_tcxx . . $ lame_t# gfp, int frame_id, char const *s) |
| 212 | { |
| 213 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 214 | if (gfc != 0) { |
| 215 | unsigned int flags = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags.; |
| 216 | id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(gfp, frame_id, 0, s); |
| 217 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. = flags; |
| 218 | #if 0 |
| 219 | debug_tag_spec_flags(gfc, "copyV1ToV2"); |
| 220 | #endif |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | |
| 225 | static void |
| 226 | id3v2AddLameVersioncxx . . $ id3v2AddLameVersion(a7aecbfd39053bc4).(lame_tcxx . . $ lame_t# gfp) |
| 227 | { |
| 228 | char buffer[1024]; |
| 229 | const char *b = get_lame_os_bitnesscxx . . $ get_lame_os_bitness(33a1f659e94feb42).(); |
| 230 | const char *v = get_lame_versioncxx . . $ get_lame_version(33a1f659e94feb42).(); |
| 231 | const char *u = get_lame_urlcxx . . $ get_lame_url(33a1f659e94feb42).(); |
| 232 | const size_t lenb = strlencxx . . $ strlen(751346f8406fd082).(b); |
| 233 | |
| 234 | if (lenb > 0) { |
| 235 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "LAME %s version %s (%s)", b, v, u); |
| 236 | } |
| 237 | else { |
| 238 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "LAME version %s (%s)", v, u); |
| 239 | } |
| 240 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_ENCODERcxx . . $ ID_ENCODER., buffer); |
| 241 | } |
| 242 | |
| 243 | static void |
| 244 | id3v2AddAudioDurationcxx . . $ id3v2AddAudioDuration(404f7e20968e6842).(lame_tcxx . . $ lame_t# gfp, double ms) |
| 245 | { |
| 246 | SessionConfig_tcxx . . $ SessionConfig_t# const *const cfg = &gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.->cfgcxx . . $ lame_internal_flags#cfg.; /* caller checked pointers */ |
| 247 | char buffer[1024]; |
| 248 | double const max_ulong = MAX_U_32_NUMcxx . . $ `external/lame/util.h:49:18`!; |
| 249 | unsigned long playlength_ms; |
| 250 | |
| 251 | ms *= 1000; |
| 252 | ms /= cfg->samplerate_incxx . . $ $anonymous_type_fa6ce02aa65ebf3c_13#samplerate_in.; |
| 253 | if (ms > max_ulong) { |
| 254 | playlength_ms = max_ulong; |
| 255 | } |
| 256 | else if (ms < 0) { |
| 257 | playlength_ms = 0; |
| 258 | } |
| 259 | else { |
| 260 | playlength_ms = ms; |
| 261 | } |
| 262 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "%lu", playlength_ms); |
| 263 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_PLAYLENGTHcxx . . $ ID_PLAYLENGTH., buffer); |
| 264 | } |
| 265 | |
| 266 | void |
| 267 | id3tag_genre_listcxx . . $ id3tag_genre_list(e4179449f67fee2a).(void (*handler) (int, const char *, void *), void *cookie) |
| 268 | { |
| 269 | if (handler) { |
| 270 | int i; |
| 271 | for (i = 0; i < GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!; ++i) { |
| 272 | if (i < GENRE_ALPHA_COUNTcxx . . $ `external/lame/id3tag.c:113:9`!) { |
| 273 | int j = genre_alpha_mapcxx . . $ genre_alpha_map.[i]; |
| 274 | handler(j, genre_namescxx . . $ genre_names.[j], cookie); |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | #define GENRE_NUM_UNKNOWNcxx . . $ `external/lame/id3tag.c:280:9`! 255 |
| 281 | |
| 282 | |
| 283 | |
| 284 | void |
| 285 | id3tag_initcxx . . $ id3tag_init(a7aecbfd39053bc4).(lame_tcxx . . $ lame_t# gfp) |
| 286 | { |
| 287 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 288 | |
| 289 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 290 | return; |
| 291 | } |
| 292 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 293 | free_id3tagcxx . . $ free_id3tag(4f558d83b2842a93).(gfc); |
| 294 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec., 0, sizeof gfc->tag_speccxx . . $ lame_internal_flags#tag_spec.); |
| 295 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..genre_id3v1cxx . . $ id3tag_spec#genre_id3v1. = GENRE_NUM_UNKNOWNcxx . . $ `external/lame/id3tag.c:280:9`!; |
| 296 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..padding_sizecxx . . $ id3tag_spec#padding_size. = 128; |
| 297 | id3v2AddLameVersioncxx . . $ id3v2AddLameVersion(a7aecbfd39053bc4).(gfp); |
| 298 | } |
| 299 | |
| 300 | |
| 301 | |
| 302 | void |
| 303 | id3tag_add_v2cxx . . $ id3tag_add_v2(a7aecbfd39053bc4).(lame_tcxx . . $ lame_t# gfp) |
| 304 | { |
| 305 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 306 | |
| 307 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 308 | return; |
| 309 | } |
| 310 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 311 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. &= ~V1_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:8:9`!; |
| 312 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`!; |
| 313 | } |
| 314 | |
| 315 | void |
| 316 | id3tag_v1_onlycxx . . $ id3tag_v1_only(a7aecbfd39053bc4).(lame_tcxx . . $ lame_t# gfp) |
| 317 | { |
| 318 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 319 | |
| 320 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 321 | return; |
| 322 | } |
| 323 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 324 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. &= ~(ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`! | V2_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:9:9`!); |
| 325 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= V1_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:8:9`!; |
| 326 | } |
| 327 | |
| 328 | void |
| 329 | id3tag_v2_onlycxx . . $ id3tag_v2_only(a7aecbfd39053bc4).(lame_tcxx . . $ lame_t# gfp) |
| 330 | { |
| 331 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 332 | |
| 333 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 334 | return; |
| 335 | } |
| 336 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 337 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. &= ~V1_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:8:9`!; |
| 338 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= V2_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:9:9`!; |
| 339 | } |
| 340 | |
| 341 | void |
| 342 | id3tag_space_v1cxx . . $ id3tag_space_v1(a7aecbfd39053bc4).(lame_tcxx . . $ lame_t# gfp) |
| 343 | { |
| 344 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 345 | |
| 346 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 347 | return; |
| 348 | } |
| 349 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 350 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. &= ~V2_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:9:9`!; |
| 351 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= SPACE_V1_FLAGcxx . . $ `external/lame/id3tag.h:10:9`!; |
| 352 | } |
| 353 | |
| 354 | void |
| 355 | id3tag_pad_v2cxx . . $ id3tag_pad_v2(a7aecbfd39053bc4).(lame_tcxx . . $ lame_t# gfp) |
| 356 | { |
| 357 | id3tag_set_padcxx . . $ id3tag_set_pad(fc5bee6581e0e074).(gfp, 128); |
| 358 | } |
| 359 | |
| 360 | void |
| 361 | id3tag_set_padcxx . . $ id3tag_set_pad(fc5bee6581e0e074).(lame_tcxx . . $ lame_t# gfp, size_t n) |
| 362 | { |
| 363 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 364 | |
| 365 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 366 | return; |
| 367 | } |
| 368 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 369 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. &= ~V1_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:8:9`!; |
| 370 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= PAD_V2_FLAGcxx . . $ `external/lame/id3tag.h:11:9`!; |
| 371 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`!; |
| 372 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..padding_sizecxx . . $ id3tag_spec#padding_size. = (unsigned int)n; |
| 373 | } |
| 374 | |
| 375 | static int |
| 376 | hasUcs2ByteOrderMarkercxx . . $ hasUcs2ByteOrderMarker(377f6a3136964dac).(unsigned short bom) |
| 377 | { |
| 378 | if (bom == 0xFFFEu || bom == 0xFEFFu) { |
| 379 | return 1; |
| 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | |
| 385 | static unsigned short |
| 386 | swap_bytescxx . . $ swap_bytes(a18c05e4017afb3d).(unsigned short w) |
| 387 | { |
| 388 | return (0xff00u & (w << 8)) | (0x00ffu & (w >> 8)); |
| 389 | } |
| 390 | |
| 391 | |
| 392 | static unsigned short |
| 393 | toLittleEndiancxx . . $ toLittleEndian(ff8bc1f71bc27ad0).(unsigned short bom, unsigned short c) |
| 394 | { |
| 395 | if (bom == 0xFFFEu) { |
| 396 | return swap_bytescxx . . $ swap_bytes(a18c05e4017afb3d).(c); |
| 397 | } |
| 398 | return c; |
| 399 | } |
| 400 | |
| 401 | static unsigned short |
| 402 | fromLatin1Charcxx . . $ fromLatin1Char(b83265dd17fbb43a).(const unsigned short* s, unsigned short c) |
| 403 | { |
| 404 | if (s[0] == 0xFFFEu) { |
| 405 | return swap_bytescxx . . $ swap_bytes(a18c05e4017afb3d).(c); |
| 406 | } |
| 407 | return c; |
| 408 | } |
| 409 | |
| 410 | |
| 411 | static size_t |
| 412 | local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(char **dst, const char *src) |
| 413 | { |
| 414 | if (dst == 0) { |
| 415 | return 0; |
| 416 | } |
| 417 | freecxx . . $ free(5d22bdacc48458e8).(*dst); |
| 418 | *dst = 0; |
| 419 | if (src != 0) { |
| 420 | size_t n; |
| 421 | for (n = 0; src[n] != 0; ++n) { /* calc src string length */ |
| 422 | } |
| 423 | if (n > 0) { /* string length without zero termination */ |
| 424 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof(*src) == sizeof(**dst)); |
| 425 | *dst = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(char, n + 1); |
| 426 | if (*dst != 0) { |
| 427 | memcpycxx . . $ memcpy(cc817cb175f282d).(*dst, src, n * sizeof(**dst)); |
| 428 | (*dst)[n] = 0; |
| 429 | return n; |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | static size_t |
| 437 | local_ucs2_strdupcxx . . $ local_ucs2_strdup(a6f47942b16dbaec).(unsigned short **dst, unsigned short const *src) |
| 438 | { |
| 439 | if (dst == 0) { |
| 440 | return 0; |
| 441 | } |
| 442 | freecxx . . $ free(5d22bdacc48458e8).(*dst); /* free old string pointer */ |
| 443 | *dst = 0; |
| 444 | if (src != 0) { |
| 445 | size_t n; |
| 446 | for (n = 0; src[n] != 0; ++n) { /* calc src string length */ |
| 447 | } |
| 448 | if (n > 0) { /* string length without zero termination */ |
| 449 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof(*src) >= 2); |
| 450 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof(*src) == sizeof(**dst)); |
| 451 | *dst = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(unsigned short, n + 1); |
| 452 | if (*dst != 0) { |
| 453 | memcpycxx . . $ memcpy(cc817cb175f282d).(*dst, src, n * sizeof(**dst)); |
| 454 | (*dst)[n] = 0; |
| 455 | return n; |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | |
| 463 | static size_t |
| 464 | local_ucs2_strlencxx . . $ local_ucs2_strlen(6fce5c29061b60f9).(unsigned short const *s) |
| 465 | { |
| 466 | size_t n = 0; |
| 467 | if (s != 0) { |
| 468 | while (*s++) { |
| 469 | ++n; |
| 470 | } |
| 471 | } |
| 472 | return n; |
| 473 | } |
| 474 | |
| 475 | |
| 476 | static size_t |
| 477 | local_ucs2_substrcxx . . $ local_ucs2_substr(ee513675e7f14bc8).(unsigned short** dst, unsigned short const* src, size_t start, size_t end) |
| 478 | { |
| 479 | size_t const len = 1 + 1 + ((start < end) ? (end - start) : 0); |
| 480 | size_t n = 0; |
| 481 | unsigned short *ptr = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(unsigned short, len); |
| 482 | *dst = ptr; |
| 483 | if (ptr == 0 || src == 0) { |
| 484 | return 0; |
| 485 | } |
| 486 | if (hasUcs2ByteOrderMarkercxx . . $ hasUcs2ByteOrderMarker(377f6a3136964dac).(src[0])) { |
| 487 | ptr[n++] = src[0]; |
| 488 | if (start == 0) { |
| 489 | ++start; |
| 490 | } |
| 491 | } |
| 492 | while (start < end) { |
| 493 | ptr[n++] = src[start++]; |
| 494 | } |
| 495 | ptr[n] = 0; |
| 496 | return n; |
| 497 | } |
| 498 | |
| 499 | static int |
| 500 | local_ucs2_poscxx . . $ local_ucs2_pos(3997bdce9e8c7edf).(unsigned short const* str, unsigned short c) |
| 501 | { |
| 502 | int i; |
| 503 | for (i = 0; str != 0 && str[i] != 0; ++i) { |
| 504 | if (str[i] == c) { |
| 505 | return i; |
| 506 | } |
| 507 | } |
| 508 | return -1; |
| 509 | } |
| 510 | |
| 511 | static int |
| 512 | local_char_poscxx . . $ local_char_pos(7c0a79fa02e3e627).(char const* str, char c) |
| 513 | { |
| 514 | int i; |
| 515 | for (i = 0; str != 0 && str[i] != 0; ++i) { |
| 516 | if (str[i] == c) { |
| 517 | return i; |
| 518 | } |
| 519 | } |
| 520 | return -1; |
| 521 | } |
| 522 | |
| 523 | static int |
| 524 | maybeLatin1cxx . . $ maybeLatin1(a4a35dd739733fa2).(unsigned short const* text) |
| 525 | { |
| 526 | if (text) { |
| 527 | unsigned short bom = *text++; |
| 528 | while (*text) { |
| 529 | unsigned short c = toLittleEndiancxx . . $ toLittleEndian(ff8bc1f71bc27ad0).(bom, *text++); |
| 530 | if (c > 0x00fe) return 0; |
| 531 | } |
| 532 | } |
| 533 | return 1; |
| 534 | } |
| 535 | |
| 536 | static int searchGenrecxx . . $ searchGenre(5c4306d8553b3696).(char const* genre); |
| 537 | static int sloppySearchGenrecxx . . $ sloppySearchGenre(5c4306d8553b3696).(char const* genre); |
| 538 | |
| 539 | static int |
| 540 | lookupGenrecxx . . $ lookupGenre(5c4306d8553b3696).(char const* genre) |
| 541 | { |
| 542 | char *str; |
| 543 | int num = strtolcxx . . $ strtol(44bbb87609b212fc).(genre, &str, 10); |
| 544 | /* is the input a string or a valid number? */ |
| 545 | if (*str) { |
| 546 | num = searchGenrecxx . . $ searchGenre(5c4306d8553b3696).(genre); |
| 547 | if (num == GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!) { |
| 548 | num = sloppySearchGenrecxx . . $ sloppySearchGenre(5c4306d8553b3696).(genre); |
| 549 | } |
| 550 | if (num == GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!) { |
| 551 | return -2; /* no common genre text found */ |
| 552 | } |
| 553 | } |
| 554 | else { |
| 555 | if ((num < 0) || (num >= GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!)) { |
| 556 | return -1; /* number unknown */ |
| 557 | } |
| 558 | } |
| 559 | return num; |
| 560 | } |
| 561 | |
| 562 | static unsigned char * |
| 563 | writeLoBytescxx . . $ writeLoBytes(78ee832bde1f4258).(unsigned char *frame, unsigned short const *str, size_t n); |
| 564 | |
| 565 | static char* |
| 566 | local_strdup_utf16_to_latin1cxx . . $ local_strdup_utf16_to_latin1(f64126cec441c640).(unsigned short const* utf16) |
| 567 | { |
| 568 | size_t len = local_ucs2_strlencxx . . $ local_ucs2_strlen(6fce5c29061b60f9).(utf16); |
| 569 | unsigned char* latin1 = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(unsigned char, len+1); |
| 570 | writeLoBytescxx . . $ writeLoBytes(78ee832bde1f4258).(latin1, utf16, len); |
| 571 | return (char*)latin1; |
| 572 | } |
| 573 | |
| 574 | |
| 575 | static int |
| 576 | id3tag_set_genre_utf16cxx . . $ id3tag_set_genre_utf16(8f35b8300f3a1dcc).(lame_tcxx . . $ lame_t# gfp, unsigned short const* text) |
| 577 | { |
| 578 | lame_internal_flagscxx . . $ lame_internal_flags#* gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 579 | int ret; |
| 580 | if (text == 0) { |
| 581 | return -3; |
| 582 | } |
| 583 | if (!hasUcs2ByteOrderMarkercxx . . $ hasUcs2ByteOrderMarker(377f6a3136964dac).(text[0])) { |
| 584 | return -3; |
| 585 | } |
| 586 | if (maybeLatin1cxx . . $ maybeLatin1(a4a35dd739733fa2).(text)) { |
| 587 | char* latin1 = local_strdup_utf16_to_latin1cxx . . $ local_strdup_utf16_to_latin1(f64126cec441c640).(text); |
| 588 | int num = lookupGenrecxx . . $ lookupGenre(5c4306d8553b3696).(latin1); |
| 589 | freecxx . . $ free(5d22bdacc48458e8).(latin1); |
| 590 | if (num == -1) return -1; /* number out of range */ |
| 591 | if (num >= 0) { /* common genre found */ |
| 592 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 593 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..genre_id3v1cxx . . $ id3tag_spec#genre_id3v1. = num; |
| 594 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_GENREcxx . . $ ID_GENRE., genre_namescxx . . $ genre_names.[num]); |
| 595 | return 0; |
| 596 | } |
| 597 | } |
| 598 | ret = id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(gfp, ID_GENREcxx . . $ ID_GENRE., 0, text); |
| 599 | if (ret == 0) { |
| 600 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 601 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..genre_id3v1cxx . . $ id3tag_spec#genre_id3v1. = GENRE_INDEX_OTHERcxx . . $ `external/lame/id3tag.c:115:9`!; |
| 602 | } |
| 603 | return ret; |
| 604 | } |
| 605 | |
| 606 | /* |
| 607 | Some existing options for ID3 tag can be specified by --tv option |
| 608 | as follows. |
| 609 | --tt <value>, --tv TIT2=value |
| 610 | --ta <value>, --tv TPE1=value |
| 611 | --tl <value>, --tv TALB=value |
| 612 | --ty <value>, --tv TYER=value |
| 613 | --tn <value>, --tv TRCK=value |
| 614 | --tg <value>, --tv TCON=value |
| 615 | (although some are not exactly same)*/ |
| 616 | |
| 617 | int |
| 618 | id3tag_set_albumartcxx . . $ id3tag_set_albumart(76836836cb24d10f).(lame_tcxx . . $ lame_t# gfp, const char *image, size_t size) |
| 619 | { |
| 620 | int mimetype = MIMETYPE_NONEcxx . . $ MIMETYPE_NONE.; |
| 621 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 622 | |
| 623 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 624 | return 0; |
| 625 | } |
| 626 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 627 | |
| 628 | if (image != 0) { |
| 629 | unsigned char const *data = (unsigned char const *) image; |
| 630 | /* determine MIME type from the actual image data */ |
| 631 | if (2 < size && data[0] == 0xFF && data[1] == 0xD8) { |
| 632 | mimetype = MIMETYPE_JPEGcxx . . $ MIMETYPE_JPEG.; |
| 633 | } |
| 634 | else if (4 < size && data[0] == 0x89 && strncmpcxx . . $ strncmp(fd278af2f295fa2e).((const char *) &data[1], "PNG", 3) == 0) { |
| 635 | mimetype = MIMETYPE_PNGcxx . . $ MIMETYPE_PNG.; |
| 636 | } |
| 637 | else if (4 < size && strncmpcxx . . $ strncmp(fd278af2f295fa2e).((const char *) data, "GIF8", 4) == 0) { |
| 638 | mimetype = MIMETYPE_GIFcxx . . $ MIMETYPE_GIF.; |
| 639 | } |
| 640 | else { |
| 641 | return -1; |
| 642 | } |
| 643 | } |
| 644 | if (gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart. != 0) { |
| 645 | freecxx . . $ free(5d22bdacc48458e8).(gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart.); |
| 646 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart. = 0; |
| 647 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_sizecxx . . $ id3tag_spec#albumart_size. = 0; |
| 648 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_mimetypecxx . . $ id3tag_spec#albumart_mimetype. = MIMETYPE_NONEcxx . . $ MIMETYPE_NONE.; |
| 649 | } |
| 650 | if (size < 1 || mimetype == MIMETYPE_NONEcxx . . $ MIMETYPE_NONE.) { |
| 651 | return 0; |
| 652 | } |
| 653 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart. = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(unsigned char, size); |
| 654 | if (gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart. != 0) { |
| 655 | memcpycxx . . $ memcpy(cc817cb175f282d).(gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart., image, size); |
| 656 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_sizecxx . . $ id3tag_spec#albumart_size. = (unsigned int)size; |
| 657 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_mimetypecxx . . $ id3tag_spec#albumart_mimetype. = mimetype; |
| 658 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 659 | id3tag_add_v2cxx . . $ id3tag_add_v2(a7aecbfd39053bc4).(gfp); |
| 660 | } |
| 661 | return 0; |
| 662 | } |
| 663 | |
| 664 | static unsigned char * |
| 665 | set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(unsigned char *bytes, uint32_tcxx . . $ uint32_t# value) |
| 666 | { |
| 667 | int i; |
| 668 | for (i = 3; i >= 0; --i) { |
| 669 | bytes[i] = value & 0xffUL; |
| 670 | value >>= 8; |
| 671 | } |
| 672 | return bytes + 4; |
| 673 | } |
| 674 | |
| 675 | static uint32_tcxx . . $ uint32_t# |
| 676 | toID3v2TagIdcxx . . $ toID3v2TagId(c61c63047ce273de).(char const *s) |
| 677 | { |
| 678 | unsigned int i, x = 0; |
| 679 | if (s == 0) { |
| 680 | return 0; |
| 681 | } |
| 682 | for (i = 0; i < 4 && s[i] != 0; ++i) { |
| 683 | char const c = s[i]; |
| 684 | unsigned int const u = 0x0ff & c; |
| 685 | x <<= 8; |
| 686 | x |= u; |
| 687 | if (c < 'A' || 'Z' < c) { |
| 688 | if (c < '0' || '9' < c) { |
| 689 | return 0; |
| 690 | } |
| 691 | } |
| 692 | } |
| 693 | return x; |
| 694 | } |
| 695 | |
| 696 | static uint32_tcxx . . $ uint32_t# |
| 697 | toID3v2TagId_ucs2cxx . . $ toID3v2TagId_ucs2(ad0aaa07bfcd0593).(unsigned short const *s) |
| 698 | { |
| 699 | unsigned int i, x = 0; |
| 700 | unsigned short bom = 0; |
| 701 | if (s == 0) { |
| 702 | return 0; |
| 703 | } |
| 704 | bom = s[0]; |
| 705 | if (hasUcs2ByteOrderMarkercxx . . $ hasUcs2ByteOrderMarker(377f6a3136964dac).(bom)) { |
| 706 | ++s; |
| 707 | } |
| 708 | for (i = 0; i < 4 && s[i] != 0; ++i) { |
| 709 | unsigned short const c = toLittleEndiancxx . . $ toLittleEndian(ff8bc1f71bc27ad0).(bom, s[i]); |
| 710 | if (c < 'A' || 'Z' < c) { |
| 711 | if (c < '0' || '9' < c) { |
| 712 | return 0; |
| 713 | } |
| 714 | } |
| 715 | x <<= 8; |
| 716 | x |= c; |
| 717 | } |
| 718 | return x; |
| 719 | } |
| 720 | |
| 721 | #if 0 |
| 722 | static int |
| 723 | isNumericString(uint32_t frame_id) |
| 724 | { |
| 725 | switch (frame_id) { |
| 726 | case ID_DATE: |
| 727 | case ID_TIME: |
| 728 | case ID_TPOS: |
| 729 | case ID_TRACK: |
| 730 | case ID_YEAR: |
| 731 | return 1; |
| 732 | } |
| 733 | return 0; |
| 734 | } |
| 735 | #endif |
| 736 | |
| 737 | static int |
| 738 | isMultiFramecxx . . $ isMultiFrame(4c679297bf94b9eb).(uint32_tcxx . . $ uint32_t# frame_id) |
| 739 | { |
| 740 | switch (frame_id) { |
| 741 | case ID_TXXXcxx . . $ ID_TXXX.: |
| 742 | case ID_WXXXcxx . . $ ID_WXXX.: |
| 743 | case ID_COMMENTcxx . . $ ID_COMMENT.: |
| 744 | case ID_SYLTcxx . . $ ID_SYLT.: |
| 745 | case ID_APICcxx . . $ ID_APIC.: |
| 746 | case ID_GEOBcxx . . $ ID_GEOB.: |
| 747 | case ID_PCNTcxx . . $ ID_PCNT.: |
| 748 | case ID_AENCcxx . . $ ID_AENC.: |
| 749 | case ID_LINKcxx . . $ ID_LINK.: |
| 750 | case ID_ENCRcxx . . $ ID_ENCR.: |
| 751 | case ID_GRIDcxx . . $ ID_GRID.: |
| 752 | case ID_PRIVcxx . . $ ID_PRIV.: |
| 753 | return 1; |
| 754 | } |
| 755 | return 0; |
| 756 | } |
| 757 | |
| 758 | #if 0 |
| 759 | static int |
| 760 | isFullTextString(int frame_id) |
| 761 | { |
| 762 | switch (frame_id) { |
| 763 | case ID_VSLT: |
| 764 | case ID_COMMENT: |
| 765 | return 1; |
| 766 | } |
| 767 | return 0; |
| 768 | } |
| 769 | #endif |
| 770 | |
| 771 | static FrameDataNodecxx . . $ FrameDataNode# * |
| 772 | findNodecxx . . $ findNode(8d89120d72f5a6fb).(id3tag_speccxx . . $ id3tag_spec# const *tag, uint32_tcxx . . $ uint32_t# frame_id, FrameDataNodecxx . . $ FrameDataNode# const *last) |
| 773 | { |
| 774 | FrameDataNodecxx . . $ FrameDataNode# *node = last ? last->nxtcxx . . $ FrameDataNode#nxt. : tag->v2_headcxx . . $ id3tag_spec#v2_head.; |
| 775 | while (node != 0) { |
| 776 | if (node->fidcxx . . $ FrameDataNode#fid. == frame_id) { |
| 777 | return node; |
| 778 | } |
| 779 | node = node->nxtcxx . . $ FrameDataNode#nxt.; |
| 780 | } |
| 781 | return 0; |
| 782 | } |
| 783 | |
| 784 | static void |
| 785 | appendNodecxx . . $ appendNode(b52dfb8070f1b295).(id3tag_speccxx . . $ id3tag_spec# * tag, FrameDataNodecxx . . $ FrameDataNode# * node) |
| 786 | { |
| 787 | if (tag->v2_tailcxx . . $ id3tag_spec#v2_tail. == 0 || tag->v2_headcxx . . $ id3tag_spec#v2_head. == 0) { |
| 788 | tag->v2_headcxx . . $ id3tag_spec#v2_head. = node; |
| 789 | tag->v2_tailcxx . . $ id3tag_spec#v2_tail. = node; |
| 790 | } |
| 791 | else { |
| 792 | tag->v2_tailcxx . . $ id3tag_spec#v2_tail.->nxtcxx . . $ FrameDataNode#nxt. = node; |
| 793 | tag->v2_tailcxx . . $ id3tag_spec#v2_tail. = node; |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | static void |
| 798 | setLangcxx . . $ setLang(72c91e5e80d20bae).(char *dst, char const *src) |
| 799 | { |
| 800 | int i; |
| 801 | if (src == 0 || src[0] == 0) { |
| 802 | dst[0] = 'e'; |
| 803 | dst[1] = 'n'; |
| 804 | dst[2] = 'g'; |
| 805 | } |
| 806 | else { |
| 807 | for (i = 0; i < 3 && src && *src; ++i) { |
| 808 | dst[i] = src[i]; |
| 809 | } |
| 810 | for (; i < 3; ++i) { |
| 811 | dst[i] = ' '; |
| 812 | } |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | static int |
| 817 | isSameLangcxx . . $ isSameLang(5ae29d726ae57f88).(char const *l1, char const *l2) |
| 818 | { |
| 819 | char d[3]; |
| 820 | int i; |
| 821 | setLangcxx . . $ setLang(72c91e5e80d20bae).(d, l2); |
| 822 | for (i = 0; i < 3; ++i) { |
| 823 | char a = tolowercxx . . $ `<external>/17904084882347303253/ctype.h:220:11`!(l1[i]); |
| 824 | char b = tolowercxx . . $ `<external>/17904084882347303253/ctype.h:220:11`!(d[i]); |
| 825 | if (a < ' ') |
| 826 | a = ' '; |
| 827 | if (b < ' ') |
| 828 | b = ' '; |
| 829 | if (a != b) { |
| 830 | return 0; |
| 831 | } |
| 832 | } |
| 833 | return 1; |
| 834 | } |
| 835 | |
| 836 | static int |
| 837 | isSameDescriptorcxx . . $ isSameDescriptor(1ab0541356715b6d).(FrameDataNodecxx . . $ FrameDataNode# const *node, char const *dsc) |
| 838 | { |
| 839 | size_t i; |
| 840 | if (node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. == 1 && node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 841 | return 0; |
| 842 | } |
| 843 | for (i = 0; i < node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.; ++i) { |
| 844 | if (!dsc || node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l.[i] != dsc[i]) { |
| 845 | return 0; |
| 846 | } |
| 847 | } |
| 848 | return 1; |
| 849 | } |
| 850 | |
| 851 | static int |
| 852 | isSameDescriptorUcs2cxx . . $ isSameDescriptorUcs2(df7973e4323ecc3e).(FrameDataNodecxx . . $ FrameDataNode# const *node, unsigned short const *dsc) |
| 853 | { |
| 854 | size_t i; |
| 855 | if (node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. != 1 && node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 856 | return 0; |
| 857 | } |
| 858 | for (i = 0; i < node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.; ++i) { |
| 859 | if (!dsc || node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u.[i] != dsc[i]) { |
| 860 | return 0; |
| 861 | } |
| 862 | } |
| 863 | return 1; |
| 864 | } |
| 865 | |
| 866 | static int |
| 867 | id3v2_add_ucs2cxx . . $ id3v2_add_ucs2(491bbf223ff2426c).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# frame_id, char const *lng, unsigned short const *desc, unsigned short const *text) |
| 868 | { |
| 869 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 870 | if (gfc != 0) { |
| 871 | FrameDataNodecxx . . $ FrameDataNode# *node = findNodecxx . . $ findNode(8d89120d72f5a6fb).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec., frame_id, 0); |
| 872 | char lang[4]; |
| 873 | setLangcxx . . $ setLang(72c91e5e80d20bae).(lang, lng); |
| 874 | if (isMultiFramecxx . . $ isMultiFrame(4c679297bf94b9eb).(frame_id)) { |
| 875 | while (node) { |
| 876 | if (isSameLangcxx . . $ isSameLang(5ae29d726ae57f88).(node->lngcxx . . $ FrameDataNode#lng., lang)) { |
| 877 | if (isSameDescriptorUcs2cxx . . $ isSameDescriptorUcs2(df7973e4323ecc3e).(node, desc)) { |
| 878 | break; |
| 879 | } |
| 880 | } |
| 881 | node = findNodecxx . . $ findNode(8d89120d72f5a6fb).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec., frame_id, node); |
| 882 | } |
| 883 | } |
| 884 | if (node == 0) { |
| 885 | node = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(FrameDataNode, 1); |
| 886 | if (node == 0) { |
| 887 | return -254; /* memory problem */ |
| 888 | } |
| 889 | appendNodecxx . . $ appendNode(b52dfb8070f1b295).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec., node); |
| 890 | } |
| 891 | node->fidcxx . . $ FrameDataNode#fid. = frame_id; |
| 892 | setLangcxx . . $ setLang(72c91e5e80d20bae).(node->lngcxx . . $ FrameDataNode#lng., lang); |
| 893 | node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. = local_ucs2_strdupcxx . . $ local_ucs2_strdup(a6f47942b16dbaec).(&node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., desc); |
| 894 | node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. = 1; |
| 895 | node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. = local_ucs2_strdupcxx . . $ local_ucs2_strdup(a6f47942b16dbaec).(&node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., text); |
| 896 | node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. = 1; |
| 897 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= (CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`! | ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`!); |
| 898 | return 0; |
| 899 | } |
| 900 | return -255; |
| 901 | } |
| 902 | |
| 903 | static int |
| 904 | id3v2_add_latin1cxx . . $ id3v2_add_latin1(696965f4ebc84b41).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# frame_id, char const *lng, char const *desc, char const *text) |
| 905 | { |
| 906 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 907 | if (gfc != 0) { |
| 908 | FrameDataNodecxx . . $ FrameDataNode# *node = findNodecxx . . $ findNode(8d89120d72f5a6fb).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec., frame_id, 0); |
| 909 | char lang[4]; |
| 910 | setLangcxx . . $ setLang(72c91e5e80d20bae).(lang, lng); |
| 911 | if (isMultiFramecxx . . $ isMultiFrame(4c679297bf94b9eb).(frame_id)) { |
| 912 | while (node) { |
| 913 | if (isSameLangcxx . . $ isSameLang(5ae29d726ae57f88).(node->lngcxx . . $ FrameDataNode#lng., lang)) { |
| 914 | if (isSameDescriptorcxx . . $ isSameDescriptor(1ab0541356715b6d).(node, desc)) { |
| 915 | break; |
| 916 | } |
| 917 | } |
| 918 | node = findNodecxx . . $ findNode(8d89120d72f5a6fb).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec., frame_id, node); |
| 919 | } |
| 920 | } |
| 921 | if (node == 0) { |
| 922 | node = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(FrameDataNode, 1); |
| 923 | if (node == 0) { |
| 924 | return -254; /* memory problem */ |
| 925 | } |
| 926 | appendNodecxx . . $ appendNode(b52dfb8070f1b295).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec., node); |
| 927 | } |
| 928 | node->fidcxx . . $ FrameDataNode#fid. = frame_id; |
| 929 | setLangcxx . . $ setLang(72c91e5e80d20bae).(node->lngcxx . . $ FrameDataNode#lng., lang); |
| 930 | node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. = local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(&node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., desc); |
| 931 | node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. = 0; |
| 932 | node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. = local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(&node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., text); |
| 933 | node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. = 0; |
| 934 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= (CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`! | ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`!); |
| 935 | return 0; |
| 936 | } |
| 937 | return -255; |
| 938 | } |
| 939 | |
| 940 | static char const* |
| 941 | id3v2_get_languagecxx . . $ id3v2_get_language(7ee57711a07934cb).(lame_tcxx . . $ lame_t# gfp) |
| 942 | { |
| 943 | lame_internal_flagscxx . . $ lame_internal_flags# const* gfc = gfp ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 944 | if (gfc) return gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..languagecxx . . $ id3tag_spec#language.; |
| 945 | return 0; |
| 946 | } |
| 947 | |
| 948 | static int |
| 949 | id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# frame_id, unsigned short const *desc, unsigned short const *text) |
| 950 | { |
| 951 | char const* lang = id3v2_get_languagecxx . . $ id3v2_get_language(7ee57711a07934cb).(gfp); |
| 952 | return id3v2_add_ucs2cxx . . $ id3v2_add_ucs2(491bbf223ff2426c).(gfp, frame_id, lang, desc, text); |
| 953 | } |
| 954 | |
| 955 | static int |
| 956 | id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# frame_id, char const *desc, char const *text) |
| 957 | { |
| 958 | char const* lang = id3v2_get_languagecxx . . $ id3v2_get_language(7ee57711a07934cb).(gfp); |
| 959 | return id3v2_add_latin1cxx . . $ id3v2_add_latin1(696965f4ebc84b41).(gfp, frame_id, lang, desc, text); |
| 960 | } |
| 961 | |
| 962 | static int |
| 963 | id3tag_set_userinfo_latin1cxx . . $ id3tag_set_userinfo_latin1(92d54c2846243d39).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# id, char const *fieldvalue) |
| 964 | { |
| 965 | char const separator = '='; |
| 966 | int rc = -7; |
| 967 | int a = local_char_poscxx . . $ local_char_pos(7c0a79fa02e3e627).(fieldvalue, separator); |
| 968 | if (a >= 0) { |
| 969 | char* dup = 0; |
| 970 | local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(&dup, fieldvalue); |
| 971 | dup[a] = 0; |
| 972 | rc = id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(gfp, id, dup, dup+a+1); |
| 973 | freecxx . . $ free(5d22bdacc48458e8).(dup); |
| 974 | } |
| 975 | return rc; |
| 976 | } |
| 977 | |
| 978 | static int |
| 979 | id3tag_set_userinfo_ucs2cxx . . $ id3tag_set_userinfo_ucs2(9f1c2d3399f3d568).(lame_tcxx . . $ lame_t# gfp, uint32_tcxx . . $ uint32_t# id, unsigned short const *fieldvalue) |
| 980 | { |
| 981 | unsigned short const separator = fromLatin1Charcxx . . $ fromLatin1Char(b83265dd17fbb43a).(fieldvalue,'='); |
| 982 | int rc = -7; |
| 983 | size_t b = local_ucs2_strlencxx . . $ local_ucs2_strlen(6fce5c29061b60f9).(fieldvalue); |
| 984 | int a = local_ucs2_poscxx . . $ local_ucs2_pos(3997bdce9e8c7edf).(fieldvalue, separator); |
| 985 | if (a >= 0) { |
| 986 | unsigned short* dsc = 0, *val = 0; |
| 987 | local_ucs2_substrcxx . . $ local_ucs2_substr(ee513675e7f14bc8).(&dsc, fieldvalue, 0, a); |
| 988 | local_ucs2_substrcxx . . $ local_ucs2_substr(ee513675e7f14bc8).(&val, fieldvalue, a+1, b); |
| 989 | rc = id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(gfp, id, dsc, val); |
| 990 | freecxx . . $ free(5d22bdacc48458e8).(dsc); |
| 991 | freecxx . . $ free(5d22bdacc48458e8).(val); |
| 992 | } |
| 993 | return rc; |
| 994 | } |
| 995 | |
| 996 | int |
| 997 | id3tag_set_textinfo_utf16cxx . . $ id3tag_set_textinfo_utf16(71601b4317af08d3).(lame_tcxx . . $ lame_t# gfp, char const *id, unsigned short const *text) |
| 998 | { |
| 999 | uint32_tcxx . . $ uint32_t# const frame_id = toID3v2TagIdcxx . . $ toID3v2TagId(c61c63047ce273de).(id); |
| 1000 | if (frame_id == 0) { |
| 1001 | return -1; |
| 1002 | } |
| 1003 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1004 | return 0; |
| 1005 | } |
| 1006 | if (text == 0) { |
| 1007 | return 0; |
| 1008 | } |
| 1009 | if (!hasUcs2ByteOrderMarkercxx . . $ hasUcs2ByteOrderMarker(377f6a3136964dac).(text[0])) { |
| 1010 | return -3; /* BOM missing */ |
| 1011 | } |
| 1012 | if (frame_id == ID_TXXXcxx . . $ ID_TXXX. || frame_id == ID_WXXXcxx . . $ ID_WXXX. || frame_id == ID_COMMENTcxx . . $ ID_COMMENT.) { |
| 1013 | return id3tag_set_userinfo_ucs2cxx . . $ id3tag_set_userinfo_ucs2(9f1c2d3399f3d568).(gfp, frame_id, text); |
| 1014 | } |
| 1015 | if (frame_id == ID_GENREcxx . . $ ID_GENRE.) { |
| 1016 | return id3tag_set_genre_utf16cxx . . $ id3tag_set_genre_utf16(8f35b8300f3a1dcc).(gfp, text); |
| 1017 | } |
| 1018 | if (frame_id == ID_PCSTcxx . . $ ID_PCST.) { |
| 1019 | return id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(gfp, frame_id, 0, text); |
| 1020 | } |
| 1021 | if (frame_id == ID_USERcxx . . $ ID_USER.) { |
| 1022 | return id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(gfp, frame_id, text, 0); |
| 1023 | } |
| 1024 | if (frame_id == ID_WFEDcxx . . $ ID_WFED.) { |
| 1025 | return id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(gfp, frame_id, text, 0); /* iTunes expects WFED to be a text frame */ |
| 1026 | } |
| 1027 | if (isFrameIdMatchingcxx . . $ isFrameIdMatching(9b79fb6aee4c0440).(frame_id, FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 0, 0, 0)) |
| 1028 | ||isFrameIdMatchingcxx . . $ isFrameIdMatching(9b79fb6aee4c0440).(frame_id, FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('W', 0, 0, 0))) { |
| 1029 | #if 0 |
| 1030 | if (isNumericString(frame_id)) { |
| 1031 | return -2; /* must be Latin-1 encoded */ |
| 1032 | } |
| 1033 | #endif |
| 1034 | return id3v2_add_ucs2_lngcxx . . $ id3v2_add_ucs2_lng(fbe35792cb7635cd).(gfp, frame_id, 0, text); |
| 1035 | } |
| 1036 | return -255; /* not supported by now */ |
| 1037 | } |
| 1038 | |
| 1039 | extern int |
| 1040 | id3tag_set_textinfo_ucs2cxx . . $ id3tag_set_textinfo_ucs2(71601b4317af08d3).(lame_tcxx . . $ lame_t# gfp, char const *id, unsigned short const *text); |
| 1041 | |
| 1042 | int |
| 1043 | id3tag_set_textinfo_ucs2cxx . . $ id3tag_set_textinfo_ucs2(71601b4317af08d3).(lame_tcxx . . $ lame_t# gfp, char const *id, unsigned short const *text) |
| 1044 | { |
| 1045 | return id3tag_set_textinfo_utf16cxx . . $ id3tag_set_textinfo_utf16(71601b4317af08d3).(gfp, id, text); |
| 1046 | } |
| 1047 | |
| 1048 | int |
| 1049 | id3tag_set_textinfo_latin1cxx . . $ id3tag_set_textinfo_latin1(51315ce7638df0f9).(lame_tcxx . . $ lame_t# gfp, char const *id, char const *text) |
| 1050 | { |
| 1051 | uint32_tcxx . . $ uint32_t# const frame_id = toID3v2TagIdcxx . . $ toID3v2TagId(c61c63047ce273de).(id); |
| 1052 | if (frame_id == 0) { |
| 1053 | return -1; |
| 1054 | } |
| 1055 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1056 | return 0; |
| 1057 | } |
| 1058 | if (text == 0) { |
| 1059 | return 0; |
| 1060 | } |
| 1061 | if (frame_id == ID_TXXXcxx . . $ ID_TXXX. || frame_id == ID_WXXXcxx . . $ ID_WXXX. || frame_id == ID_COMMENTcxx . . $ ID_COMMENT.) { |
| 1062 | return id3tag_set_userinfo_latin1cxx . . $ id3tag_set_userinfo_latin1(92d54c2846243d39).(gfp, frame_id, text); |
| 1063 | } |
| 1064 | if (frame_id == ID_GENREcxx . . $ ID_GENRE.) { |
| 1065 | return id3tag_set_genrecxx . . $ id3tag_set_genre(6d18827e8c5f3b27).(gfp, text); |
| 1066 | } |
| 1067 | if (frame_id == ID_PCSTcxx . . $ ID_PCST.) { |
| 1068 | return id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(gfp, frame_id, 0, text); |
| 1069 | } |
| 1070 | if (frame_id == ID_USERcxx . . $ ID_USER.) { |
| 1071 | return id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(gfp, frame_id, text, 0); |
| 1072 | } |
| 1073 | if (frame_id == ID_WFEDcxx . . $ ID_WFED.) { |
| 1074 | return id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(gfp, frame_id, text, 0); /* iTunes expects WFED to be a text frame */ |
| 1075 | } |
| 1076 | if (isFrameIdMatchingcxx . . $ isFrameIdMatching(9b79fb6aee4c0440).(frame_id, FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('T', 0, 0, 0)) |
| 1077 | ||isFrameIdMatchingcxx . . $ isFrameIdMatching(9b79fb6aee4c0440).(frame_id, FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('W', 0, 0, 0))) { |
| 1078 | return id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(gfp, frame_id, 0, text); |
| 1079 | } |
| 1080 | return -255; /* not supported by now */ |
| 1081 | } |
| 1082 | |
| 1083 | |
| 1084 | int |
| 1085 | id3tag_set_comment_latin1cxx . . $ id3tag_set_comment_latin1(14589618074eabd2).(lame_tcxx . . $ lame_t# gfp, char const *lang, char const *desc, char const *text) |
| 1086 | { |
| 1087 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1088 | return 0; |
| 1089 | } |
| 1090 | return id3v2_add_latin1cxx . . $ id3v2_add_latin1(696965f4ebc84b41).(gfp, ID_COMMENTcxx . . $ ID_COMMENT., lang, desc, text); |
| 1091 | } |
| 1092 | |
| 1093 | |
| 1094 | int |
| 1095 | id3tag_set_comment_utf16cxx . . $ id3tag_set_comment_utf16(160dc0119f9692e4).(lame_tcxx . . $ lame_t# gfp, char const *lang, unsigned short const *desc, unsigned short const *text) |
| 1096 | { |
| 1097 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1098 | return 0; |
| 1099 | } |
| 1100 | return id3v2_add_ucs2cxx . . $ id3v2_add_ucs2(491bbf223ff2426c).(gfp, ID_COMMENTcxx . . $ ID_COMMENT., lang, desc, text); |
| 1101 | } |
| 1102 | |
| 1103 | extern int |
| 1104 | id3tag_set_comment_ucs2cxx . . $ id3tag_set_comment_ucs2(160dc0119f9692e4).(lame_tcxx . . $ lame_t# gfp, char const *lang, unsigned short const *desc, unsigned short const *text); |
| 1105 | |
| 1106 | |
| 1107 | int |
| 1108 | id3tag_set_comment_ucs2cxx . . $ id3tag_set_comment_ucs2(160dc0119f9692e4).(lame_tcxx . . $ lame_t# gfp, char const *lang, unsigned short const *desc, unsigned short const *text) |
| 1109 | { |
| 1110 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1111 | return 0; |
| 1112 | } |
| 1113 | return id3tag_set_comment_utf16cxx . . $ id3tag_set_comment_utf16(160dc0119f9692e4).(gfp, lang, desc, text); |
| 1114 | } |
| 1115 | |
| 1116 | |
| 1117 | void |
| 1118 | id3tag_set_titlecxx . . $ id3tag_set_title(a24b931e9d839ce5).(lame_tcxx . . $ lame_t# gfp, const char *title) |
| 1119 | { |
| 1120 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 1121 | if (gfc && title && *title) { |
| 1122 | local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..titlecxx . . $ id3tag_spec#title., title); |
| 1123 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 1124 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_TITLEcxx . . $ ID_TITLE., title); |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | void |
| 1129 | id3tag_set_artistcxx . . $ id3tag_set_artist(a24b931e9d839ce5).(lame_tcxx . . $ lame_t# gfp, const char *artist) |
| 1130 | { |
| 1131 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 1132 | if (gfc && artist && *artist) { |
| 1133 | local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..artistcxx . . $ id3tag_spec#artist., artist); |
| 1134 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 1135 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_ARTISTcxx . . $ ID_ARTIST., artist); |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | void |
| 1140 | id3tag_set_albumcxx . . $ id3tag_set_album(a24b931e9d839ce5).(lame_tcxx . . $ lame_t# gfp, const char *album) |
| 1141 | { |
| 1142 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 1143 | if (gfc && album && *album) { |
| 1144 | local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumcxx . . $ id3tag_spec#album., album); |
| 1145 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 1146 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_ALBUMcxx . . $ ID_ALBUM., album); |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | void |
| 1151 | id3tag_set_yearcxx . . $ id3tag_set_year(a24b931e9d839ce5).(lame_tcxx . . $ lame_t# gfp, const char *year) |
| 1152 | { |
| 1153 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 1154 | if (gfc && year && *year) { |
| 1155 | int num = atoicxx . . $ atoi(5c4306d8553b3696).(year); |
| 1156 | if (num < 0) { |
| 1157 | num = 0; |
| 1158 | } |
| 1159 | /* limit a year to 4 digits so it fits in a version 1 tag */ |
| 1160 | if (num > 9999) { |
| 1161 | num = 9999; |
| 1162 | } |
| 1163 | if (num) { |
| 1164 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..yearcxx . . $ id3tag_spec#year. = num; |
| 1165 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 1166 | } |
| 1167 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_YEARcxx . . $ ID_YEAR., year); |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | void |
| 1172 | id3tag_set_commentcxx . . $ id3tag_set_comment(a24b931e9d839ce5).(lame_tcxx . . $ lame_t# gfp, const char *comment) |
| 1173 | { |
| 1174 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 1175 | if (gfc && comment && *comment) { |
| 1176 | local_strdupcxx . . $ local_strdup(bb0b3155827a4a2c).(&gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..commentcxx . . $ id3tag_spec#comment., comment); |
| 1177 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 1178 | { |
| 1179 | uint32_tcxx . . $ uint32_t# const flags = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags.; |
| 1180 | id3v2_add_latin1_lngcxx . . $ id3v2_add_latin1_lng(bf749857be448d9c).(gfp, ID_COMMENTcxx . . $ ID_COMMENT., "", comment); |
| 1181 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. = flags; |
| 1182 | } |
| 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | int |
| 1187 | id3tag_set_trackcxx . . $ id3tag_set_track(6d18827e8c5f3b27).(lame_tcxx . . $ lame_t# gfp, const char *track) |
| 1188 | { |
| 1189 | char const *trackcount; |
| 1190 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 1191 | int ret = 0; |
| 1192 | |
| 1193 | if (gfc && track && *track) { |
| 1194 | int num = atoicxx . . $ atoi(5c4306d8553b3696).(track); |
| 1195 | /* check for valid ID3v1 track number range */ |
| 1196 | if (num < 1 || num > 255) { |
| 1197 | num = 0; |
| 1198 | ret = -1; /* track number out of ID3v1 range, ignored for ID3v1 */ |
| 1199 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= (CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`! | ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`!); |
| 1200 | } |
| 1201 | if (num) { |
| 1202 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..track_id3v1cxx . . $ id3tag_spec#track_id3v1. = num; |
| 1203 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 1204 | } |
| 1205 | /* Look for the total track count after a "/", same restrictions */ |
| 1206 | trackcount = strchrcxx . . $ strchr(2050848944e00d54).(track, '/'); |
| 1207 | if (trackcount && *trackcount) { |
| 1208 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= (CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`! | ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`!); |
| 1209 | } |
| 1210 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_TRACKcxx . . $ ID_TRACK., track); |
| 1211 | } |
| 1212 | return ret; |
| 1213 | } |
| 1214 | |
| 1215 | /* would use real "strcasecmp" but it isn't portable */ |
| 1216 | static int |
| 1217 | local_strcasecmpcxx . . $ local_strcasecmp(5ae29d726ae57f88).(const char *s1, const char *s2) |
| 1218 | { |
| 1219 | unsigned char c1; |
| 1220 | unsigned char c2; |
| 1221 | do { |
| 1222 | c1 = tolowercxx . . $ `<external>/17904084882347303253/ctype.h:220:11`!(*s1); |
| 1223 | c2 = tolowercxx . . $ `<external>/17904084882347303253/ctype.h:220:11`!(*s2); |
| 1224 | if (!c1) { |
| 1225 | break; |
| 1226 | } |
| 1227 | ++s1; |
| 1228 | ++s2; |
| 1229 | } while (c1 == c2); |
| 1230 | return c1 - c2; |
| 1231 | } |
| 1232 | |
| 1233 | |
| 1234 | static |
| 1235 | const char* nextUpperAlphacxx . . $ nextUpperAlpha(98719269de49c51b).(const char* p, char x) |
| 1236 | { |
| 1237 | char c; |
| 1238 | for(c = touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(*p); *p != 0; c = touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(*++p)) { |
| 1239 | if ('A' <= c && c <= 'Z') { |
| 1240 | if (c != x) { |
| 1241 | return p; |
| 1242 | } |
| 1243 | } |
| 1244 | } |
| 1245 | return p; |
| 1246 | } |
| 1247 | |
| 1248 | |
| 1249 | static int |
| 1250 | sloppyComparedcxx . . $ sloppyCompared(5ae29d726ae57f88).(const char* p, const char* q) |
| 1251 | { |
| 1252 | char cp, cq; |
| 1253 | p = nextUpperAlphacxx . . $ nextUpperAlpha(98719269de49c51b).(p, 0); |
| 1254 | q = nextUpperAlphacxx . . $ nextUpperAlpha(98719269de49c51b).(q, 0); |
| 1255 | cp = touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(*p); |
| 1256 | cq = touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(*q); |
| 1257 | while (cp == cq) { |
| 1258 | if (cp == 0) { |
| 1259 | return 1; |
| 1260 | } |
| 1261 | if (p[1] == '.') { /* some abbrevation */ |
| 1262 | while (*q && *q++ != ' ') { |
| 1263 | } |
| 1264 | } |
| 1265 | p = nextUpperAlphacxx . . $ nextUpperAlpha(98719269de49c51b).(p, cp); |
| 1266 | q = nextUpperAlphacxx . . $ nextUpperAlpha(98719269de49c51b).(q, cq); |
| 1267 | cp = touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(*p); |
| 1268 | cq = touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(*q); |
| 1269 | } |
| 1270 | return 0; |
| 1271 | } |
| 1272 | |
| 1273 | |
| 1274 | static int |
| 1275 | sloppySearchGenrecxx . . $ sloppySearchGenre(5c4306d8553b3696).(const char *genre) |
| 1276 | { |
| 1277 | int i; |
| 1278 | for (i = 0; i < GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!; ++i) { |
| 1279 | if (sloppyComparedcxx . . $ sloppyCompared(5ae29d726ae57f88).(genre, genre_namescxx . . $ genre_names.[i])) { |
| 1280 | return i; |
| 1281 | } |
| 1282 | } |
| 1283 | return GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!; |
| 1284 | } |
| 1285 | |
| 1286 | |
| 1287 | static int |
| 1288 | searchGenrecxx . . $ searchGenre(5c4306d8553b3696).(const char* genre) |
| 1289 | { |
| 1290 | int i; |
| 1291 | for (i = 0; i < GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!; ++i) { |
| 1292 | if (!local_strcasecmpcxx . . $ local_strcasecmp(5ae29d726ae57f88).(genre, genre_namescxx . . $ genre_names.[i])) { |
| 1293 | return i; |
| 1294 | } |
| 1295 | } |
| 1296 | return GENRE_NAME_COUNTcxx . . $ `external/lame/id3tag.c:98:9`!; |
| 1297 | } |
| 1298 | |
| 1299 | |
| 1300 | int |
| 1301 | id3tag_set_genrecxx . . $ id3tag_set_genre(6d18827e8c5f3b27).(lame_tcxx . . $ lame_t# gfp, const char *genre) |
| 1302 | { |
| 1303 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = gfp != 0 ? gfp->internal_flagscxx . . $ lame_global_struct#internal_flags. : 0; |
| 1304 | int ret = 0; |
| 1305 | if (gfc && genre && *genre) { |
| 1306 | int const num = lookupGenrecxx . . $ lookupGenre(5c4306d8553b3696).(genre); |
| 1307 | if (num == -1) return num; |
| 1308 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!; |
| 1309 | if (num >= 0) { |
| 1310 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..genre_id3v1cxx . . $ id3tag_spec#genre_id3v1. = num; |
| 1311 | genre = genre_namescxx . . $ genre_names.[num]; |
| 1312 | } |
| 1313 | else { |
| 1314 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..genre_id3v1cxx . . $ id3tag_spec#genre_id3v1. = GENRE_INDEX_OTHERcxx . . $ `external/lame/id3tag.c:115:9`!; |
| 1315 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..flagscxx . . $ id3tag_spec#flags. |= ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`!; |
| 1316 | } |
| 1317 | copyV1ToV2cxx . . $ copyV1ToV2(b6151b1ba424976c).(gfp, ID_GENREcxx . . $ ID_GENRE., genre); |
| 1318 | } |
| 1319 | return ret; |
| 1320 | } |
| 1321 | |
| 1322 | |
| 1323 | static size_t |
| 1324 | sizeOfNodecxx . . $ sizeOfNode(f3430c5f57b12b8c).(FrameDataNodecxx . . $ FrameDataNode# const *node) |
| 1325 | { |
| 1326 | size_t n = 0; |
| 1327 | if (node) { |
| 1328 | n = 10; /* header size */ |
| 1329 | n += 1; /* text encoding flag */ |
| 1330 | switch (node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc.) { |
| 1331 | default: |
| 1332 | case 0: |
| 1333 | if (node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 1334 | n += node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. + 1; |
| 1335 | } |
| 1336 | n += node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.; |
| 1337 | break; |
| 1338 | case 1: |
| 1339 | if (node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 1340 | n += (node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.+1) * 2; |
| 1341 | } |
| 1342 | n += node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. * 2; |
| 1343 | break; |
| 1344 | } |
| 1345 | } |
| 1346 | return n; |
| 1347 | } |
| 1348 | |
| 1349 | static size_t |
| 1350 | sizeOfCommentNodecxx . . $ sizeOfCommentNode(f3430c5f57b12b8c).(FrameDataNodecxx . . $ FrameDataNode# const *node) |
| 1351 | { |
| 1352 | size_t n = 0; |
| 1353 | if (node) { |
| 1354 | n = 10; /* header size */ |
| 1355 | n += 1; /* text encoding flag */ |
| 1356 | n += 3; /* language */ |
| 1357 | switch (node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc.) { |
| 1358 | default: |
| 1359 | case 0: |
| 1360 | n += 1 + node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.; |
| 1361 | break; |
| 1362 | case 1: |
| 1363 | n += 2 + node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. * 2; |
| 1364 | break; |
| 1365 | } |
| 1366 | switch (node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc.) { |
| 1367 | default: |
| 1368 | case 0: |
| 1369 | n += node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.; |
| 1370 | break; |
| 1371 | case 1: |
| 1372 | n += node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. * 2; |
| 1373 | break; |
| 1374 | } |
| 1375 | } |
| 1376 | return n; |
| 1377 | } |
| 1378 | |
| 1379 | static size_t |
| 1380 | sizeOfWxxxNodecxx . . $ sizeOfWxxxNode(f3430c5f57b12b8c).(FrameDataNodecxx . . $ FrameDataNode# const *node) |
| 1381 | { |
| 1382 | size_t n = 0; |
| 1383 | if (node) { |
| 1384 | n = 10; /* header size */ |
| 1385 | if (node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 1386 | n += 1; /* text encoding flag */ |
| 1387 | switch (node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc.) { |
| 1388 | default: |
| 1389 | case 0: |
| 1390 | n += 1 + node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.; |
| 1391 | break; |
| 1392 | case 1: |
| 1393 | n += 2 + node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. * 2; |
| 1394 | break; |
| 1395 | } |
| 1396 | } |
| 1397 | if (node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 1398 | switch (node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc.) { |
| 1399 | default: |
| 1400 | case 0: |
| 1401 | n += node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.; |
| 1402 | break; |
| 1403 | case 1: |
| 1404 | n += node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. - 1; /* UCS2 -> Latin1, skip BOM */ |
| 1405 | break; |
| 1406 | } |
| 1407 | } |
| 1408 | } |
| 1409 | return n; |
| 1410 | } |
| 1411 | |
| 1412 | static unsigned char * |
| 1413 | writeCharscxx . . $ writeChars(4da75829b39c7a1d).(unsigned char *frame, char const *str, size_t n) |
| 1414 | { |
| 1415 | while (n--) { |
| 1416 | *frame++ = *str++; |
| 1417 | } |
| 1418 | return frame; |
| 1419 | } |
| 1420 | |
| 1421 | static unsigned char * |
| 1422 | writeUcs2scxx . . $ writeUcs2s(78ee832bde1f4258).(unsigned char *frame, unsigned short const *str, size_t n) |
| 1423 | { |
| 1424 | if (n > 0) { |
| 1425 | unsigned short const bom = *str; |
| 1426 | while (n--) { |
| 1427 | unsigned short const c = toLittleEndiancxx . . $ toLittleEndian(ff8bc1f71bc27ad0).(bom, *str++); |
| 1428 | *frame++ = 0x00ffu & c; |
| 1429 | *frame++ = 0x00ffu & (c >> 8); |
| 1430 | } |
| 1431 | } |
| 1432 | return frame; |
| 1433 | } |
| 1434 | |
| 1435 | static unsigned char * |
| 1436 | writeLoBytescxx . . $ writeLoBytes(78ee832bde1f4258).(unsigned char *frame, unsigned short const *str, size_t n) |
| 1437 | { |
| 1438 | if (n > 0) { |
| 1439 | unsigned short const bom = *str; |
| 1440 | if (hasUcs2ByteOrderMarkercxx . . $ hasUcs2ByteOrderMarker(377f6a3136964dac).(bom)) { |
| 1441 | str++; n--; /* skip BOM */ |
| 1442 | } |
| 1443 | while (n--) { |
| 1444 | unsigned short const c = toLittleEndiancxx . . $ toLittleEndian(ff8bc1f71bc27ad0).(bom, *str++); |
| 1445 | if (c < 0x0020u || 0x00ffu < c) { |
| 1446 | *frame++ = 0x0020; /* blank */ |
| 1447 | } |
| 1448 | else { |
| 1449 | *frame++ = c; |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | return frame; |
| 1454 | } |
| 1455 | |
| 1456 | static unsigned char * |
| 1457 | set_frame_commentcxx . . $ set_frame_comment(4834806e85543c2f).(unsigned char *frame, FrameDataNodecxx . . $ FrameDataNode# const *node) |
| 1458 | { |
| 1459 | size_t const n = sizeOfCommentNodecxx . . $ sizeOfCommentNode(f3430c5f57b12b8c).(node); |
| 1460 | if (n > 10) { |
| 1461 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, node->fidcxx . . $ FrameDataNode#fid.); |
| 1462 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, (uint32_tcxx . . $ uint32_t#) (n - 10)); |
| 1463 | /* clear 2-byte header flags */ |
| 1464 | *frame++ = 0; |
| 1465 | *frame++ = 0; |
| 1466 | /* encoding descriptor byte */ |
| 1467 | *frame++ = node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. == 1 ? 1 : 0; |
| 1468 | /* 3 bytes language */ |
| 1469 | *frame++ = node->lngcxx . . $ FrameDataNode#lng.[0]; |
| 1470 | *frame++ = node->lngcxx . . $ FrameDataNode#lng.[1]; |
| 1471 | *frame++ = node->lngcxx . . $ FrameDataNode#lng.[2]; |
| 1472 | /* descriptor with zero byte(s) separator */ |
| 1473 | if (node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. != 1) { |
| 1474 | frame = writeCharscxx . . $ writeChars(4da75829b39c7a1d).(frame, node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1475 | *frame++ = 0; |
| 1476 | } |
| 1477 | else { |
| 1478 | frame = writeUcs2scxx . . $ writeUcs2s(78ee832bde1f4258).(frame, node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1479 | *frame++ = 0; |
| 1480 | *frame++ = 0; |
| 1481 | } |
| 1482 | /* comment full text */ |
| 1483 | if (node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. != 1) { |
| 1484 | frame = writeCharscxx . . $ writeChars(4da75829b39c7a1d).(frame, node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1485 | } |
| 1486 | else { |
| 1487 | frame = writeUcs2scxx . . $ writeUcs2s(78ee832bde1f4258).(frame, node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1488 | } |
| 1489 | } |
| 1490 | return frame; |
| 1491 | } |
| 1492 | |
| 1493 | static unsigned char * |
| 1494 | set_frame_custom2cxx . . $ set_frame_custom2(4834806e85543c2f).(unsigned char *frame, FrameDataNodecxx . . $ FrameDataNode# const *node) |
| 1495 | { |
| 1496 | size_t const n = sizeOfNodecxx . . $ sizeOfNode(f3430c5f57b12b8c).(node); |
| 1497 | if (n > 10) { |
| 1498 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, node->fidcxx . . $ FrameDataNode#fid.); |
| 1499 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, (unsigned long) (n - 10)); |
| 1500 | /* clear 2-byte header flags */ |
| 1501 | *frame++ = 0; |
| 1502 | *frame++ = 0; |
| 1503 | /* clear 1 encoding descriptor byte to indicate ISO-8859-1 format */ |
| 1504 | *frame++ = node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. == 1 ? 1 : 0; |
| 1505 | if (node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 1506 | if (node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. != 1) { |
| 1507 | frame = writeCharscxx . . $ writeChars(4da75829b39c7a1d).(frame, node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1508 | *frame++ = 0; |
| 1509 | } |
| 1510 | else { |
| 1511 | frame = writeUcs2scxx . . $ writeUcs2s(78ee832bde1f4258).(frame, node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1512 | *frame++ = 0; |
| 1513 | *frame++ = 0; |
| 1514 | } |
| 1515 | } |
| 1516 | if (node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. != 1) { |
| 1517 | frame = writeCharscxx . . $ writeChars(4da75829b39c7a1d).(frame, node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1518 | } |
| 1519 | else { |
| 1520 | frame = writeUcs2scxx . . $ writeUcs2s(78ee832bde1f4258).(frame, node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1521 | } |
| 1522 | } |
| 1523 | return frame; |
| 1524 | } |
| 1525 | |
| 1526 | static unsigned char * |
| 1527 | set_frame_wxxxcxx . . $ set_frame_wxxx(4834806e85543c2f).(unsigned char *frame, FrameDataNodecxx . . $ FrameDataNode# const *node) |
| 1528 | { |
| 1529 | size_t const n = sizeOfWxxxNodecxx . . $ sizeOfWxxxNode(f3430c5f57b12b8c).(node); |
| 1530 | if (n > 10) { |
| 1531 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, node->fidcxx . . $ FrameDataNode#fid.); |
| 1532 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, (unsigned long) (n - 10)); |
| 1533 | /* clear 2-byte header flags */ |
| 1534 | *frame++ = 0; |
| 1535 | *frame++ = 0; |
| 1536 | if (node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim. > 0) { |
| 1537 | /* clear 1 encoding descriptor byte to indicate ISO-8859-1 format */ |
| 1538 | *frame++ = node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. == 1 ? 1 : 0; |
| 1539 | if (node->dsccxx . . $ FrameDataNode#dsc..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. != 1) { |
| 1540 | frame = writeCharscxx . . $ writeChars(4da75829b39c7a1d).(frame, node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1541 | *frame++ = 0; |
| 1542 | } |
| 1543 | else { |
| 1544 | frame = writeUcs2scxx . . $ writeUcs2s(78ee832bde1f4258).(frame, node->dsccxx . . $ FrameDataNode#dsc..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., node->dsccxx . . $ FrameDataNode#dsc..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1545 | *frame++ = 0; |
| 1546 | *frame++ = 0; |
| 1547 | } |
| 1548 | } |
| 1549 | if (node->txtcxx . . $ FrameDataNode#txt..enccxx . . $ FrameDataNode#$anonymous_type_1#enc. != 1) { |
| 1550 | frame = writeCharscxx . . $ writeChars(4da75829b39c7a1d).(frame, node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..lcxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#l., node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1551 | } |
| 1552 | else { |
| 1553 | frame = writeLoBytescxx . . $ writeLoBytes(78ee832bde1f4258).(frame, node->txtcxx . . $ FrameDataNode#txt..ptrcxx . . $ FrameDataNode#$anonymous_type_1#ptr..ucxx . . $ FrameDataNode#$anonymous_type_1#$anonymous_type_2#u., node->txtcxx . . $ FrameDataNode#txt..dimcxx . . $ FrameDataNode#$anonymous_type_1#dim.); |
| 1554 | } |
| 1555 | } |
| 1556 | return frame; |
| 1557 | } |
| 1558 | |
| 1559 | static unsigned char * |
| 1560 | set_frame_apiccxx . . $ set_frame_apic(3d5c3cf7d671dc30).(unsigned char *frame, const char *mimetype, const unsigned char *data, size_t size) |
| 1561 | { |
| 1562 | /* ID3v2.3 standard APIC frame: |
| 1563 | * <Header for 'Attached picture', ID: "APIC"> |
| 1564 | * Text encoding $xx |
| 1565 | * MIME type <text string> $00 |
| 1566 | * Picture type $xx |
| 1567 | * Description <text string according to encoding> $00 (00) |
| 1568 | * Picture data <binary data> |
| 1569 | */ |
| 1570 | if (mimetype && data && size) { |
| 1571 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('A', 'P', 'I', 'C')); |
| 1572 | frame = set_4_byte_valuecxx . . $ set_4_byte_value(110b84462f0b6edf).(frame, (unsigned long) (4 + strlencxx . . $ strlen(751346f8406fd082).(mimetype) + size)); |
| 1573 | /* clear 2-byte header flags */ |
| 1574 | *frame++ = 0; |
| 1575 | *frame++ = 0; |
| 1576 | /* clear 1 encoding descriptor byte to indicate ISO-8859-1 format */ |
| 1577 | *frame++ = 0; |
| 1578 | /* copy mime_type */ |
| 1579 | while (*mimetype) { |
| 1580 | *frame++ = *mimetype++; |
| 1581 | } |
| 1582 | *frame++ = 0; |
| 1583 | /* set picture type to 0 */ |
| 1584 | *frame++ = 0; |
| 1585 | /* empty description field */ |
| 1586 | *frame++ = 0; |
| 1587 | /* copy the image data */ |
| 1588 | while (size--) { |
| 1589 | *frame++ = *data++; |
| 1590 | } |
| 1591 | } |
| 1592 | return frame; |
| 1593 | } |
| 1594 | |
| 1595 | int |
| 1596 | id3tag_set_fieldvaluecxx . . $ id3tag_set_fieldvalue(6d18827e8c5f3b27).(lame_tcxx . . $ lame_t# gfp, const char *fieldvalue) |
| 1597 | { |
| 1598 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1599 | return 0; |
| 1600 | } |
| 1601 | if (fieldvalue && *fieldvalue) { |
| 1602 | if (strlencxx . . $ strlen(751346f8406fd082).(fieldvalue) < 5 || fieldvalue[4] != '=') { |
| 1603 | return -1; |
| 1604 | } |
| 1605 | return id3tag_set_textinfo_latin1cxx . . $ id3tag_set_textinfo_latin1(51315ce7638df0f9).(gfp, fieldvalue, &fieldvalue[5]); |
| 1606 | } |
| 1607 | return 0; |
| 1608 | } |
| 1609 | |
| 1610 | int |
| 1611 | id3tag_set_fieldvalue_utf16cxx . . $ id3tag_set_fieldvalue_utf16(8f35b8300f3a1dcc).(lame_tcxx . . $ lame_t# gfp, const unsigned short *fieldvalue) |
| 1612 | { |
| 1613 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1614 | return 0; |
| 1615 | } |
| 1616 | if (fieldvalue && *fieldvalue) { |
| 1617 | size_t dx = hasUcs2ByteOrderMarkercxx . . $ hasUcs2ByteOrderMarker(377f6a3136964dac).(fieldvalue[0]); |
| 1618 | unsigned short const separator = fromLatin1Charcxx . . $ fromLatin1Char(b83265dd17fbb43a).(fieldvalue, '='); |
| 1619 | char fid[5] = {0,0,0,0,0}; |
| 1620 | uint32_tcxx . . $ uint32_t# const frame_id = toID3v2TagId_ucs2cxx . . $ toID3v2TagId_ucs2(ad0aaa07bfcd0593).(fieldvalue); |
| 1621 | if (local_ucs2_strlencxx . . $ local_ucs2_strlen(6fce5c29061b60f9).(fieldvalue) < (5+dx) || fieldvalue[4+dx] != separator) { |
| 1622 | return -1; |
| 1623 | } |
| 1624 | fid[0] = (frame_id >> 24) & 0x0ff; |
| 1625 | fid[1] = (frame_id >> 16) & 0x0ff; |
| 1626 | fid[2] = (frame_id >> 8) & 0x0ff; |
| 1627 | fid[3] = frame_id & 0x0ff; |
| 1628 | if (frame_id != 0) { |
| 1629 | unsigned short* txt = 0; |
| 1630 | int rc; |
| 1631 | local_ucs2_substrcxx . . $ local_ucs2_substr(ee513675e7f14bc8).(&txt, fieldvalue, dx+5, local_ucs2_strlencxx . . $ local_ucs2_strlen(6fce5c29061b60f9).(fieldvalue)); |
| 1632 | rc = id3tag_set_textinfo_utf16cxx . . $ id3tag_set_textinfo_utf16(71601b4317af08d3).(gfp, fid, txt); |
| 1633 | freecxx . . $ free(5d22bdacc48458e8).(txt); |
| 1634 | return rc; |
| 1635 | } |
| 1636 | } |
| 1637 | return -1; |
| 1638 | } |
| 1639 | |
| 1640 | extern int |
| 1641 | id3tag_set_fieldvalue_ucs2cxx . . $ id3tag_set_fieldvalue_ucs2(8f35b8300f3a1dcc).(lame_tcxx . . $ lame_t# gfp, const unsigned short *fieldvalue); |
| 1642 | |
| 1643 | int |
| 1644 | id3tag_set_fieldvalue_ucs2cxx . . $ id3tag_set_fieldvalue_ucs2(8f35b8300f3a1dcc).(lame_tcxx . . $ lame_t# gfp, const unsigned short *fieldvalue) |
| 1645 | { |
| 1646 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1647 | return 0; |
| 1648 | } |
| 1649 | return id3tag_set_fieldvalue_utf16cxx . . $ id3tag_set_fieldvalue_utf16(8f35b8300f3a1dcc).(gfp, fieldvalue); |
| 1650 | } |
| 1651 | |
| 1652 | size_t |
| 1653 | lame_get_id3v2_tagcxx . . $ lame_get_id3v2_tag(407641c14281c852).(lame_tcxx . . $ lame_t# gfp, unsigned char *buffer, size_t size) |
| 1654 | { |
| 1655 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 1656 | |
| 1657 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1658 | return 0; |
| 1659 | } |
| 1660 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 1661 | if (test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, V1_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:8:9`!)) { |
| 1662 | return 0; |
| 1663 | } |
| 1664 | #if 0 |
| 1665 | debug_tag_spec_flags(gfc, "lame_get_id3v2_tag"); |
| 1666 | #endif |
| 1667 | { |
| 1668 | int usev2 = test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, ADD_V2_FLAGcxx . . $ `external/lame/id3tag.h:7:9`! | V2_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:9:9`!); |
| 1669 | /* calculate length of four fields which may not fit in verion 1 tag */ |
| 1670 | size_t title_length = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..titlecxx . . $ id3tag_spec#title. ? strlencxx . . $ strlen(751346f8406fd082).(gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..titlecxx . . $ id3tag_spec#title.) : 0; |
| 1671 | size_t artist_length = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..artistcxx . . $ id3tag_spec#artist. ? strlencxx . . $ strlen(751346f8406fd082).(gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..artistcxx . . $ id3tag_spec#artist.) : 0; |
| 1672 | size_t album_length = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumcxx . . $ id3tag_spec#album. ? strlencxx . . $ strlen(751346f8406fd082).(gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumcxx . . $ id3tag_spec#album.) : 0; |
| 1673 | size_t comment_length = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..commentcxx . . $ id3tag_spec#comment. ? strlencxx . . $ strlen(751346f8406fd082).(gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..commentcxx . . $ id3tag_spec#comment.) : 0; |
| 1674 | /* write tag if explicitly requested or if fields overflow */ |
| 1675 | if ((title_length > 30) |
| 1676 | || (artist_length > 30) |
| 1677 | || (album_length > 30) |
| 1678 | || (comment_length > 30) |
| 1679 | || (gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..track_id3v1cxx . . $ id3tag_spec#track_id3v1. && (comment_length > 28))) { |
| 1680 | usev2 = 1; |
| 1681 | } |
| 1682 | if (usev2) { |
| 1683 | size_t tag_size; |
| 1684 | unsigned char *p; |
| 1685 | size_t adjusted_tag_size; |
| 1686 | const char *albumart_mime = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1687 | static const char *mime_jpeg = "image/jpeg"; |
| 1688 | static const char *mime_png = "image/png"; |
| 1689 | static const char *mime_gif = "image/gif"; |
| 1690 | |
| 1691 | if (gfp->num_samplescxx . . $ lame_global_struct#num_samples. != MAX_U_32_NUMcxx . . $ `external/lame/util.h:49:18`!) { |
| 1692 | id3v2AddAudioDurationcxx . . $ id3v2AddAudioDuration(404f7e20968e6842).(gfp, gfp->num_samplescxx . . $ lame_global_struct#num_samples.); |
| 1693 | } |
| 1694 | |
| 1695 | /* calulate size of tag starting with 10-byte tag header */ |
| 1696 | tag_size = 10; |
| 1697 | if (gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart. && gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_sizecxx . . $ id3tag_spec#albumart_size.) { |
| 1698 | switch (gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_mimetypecxx . . $ id3tag_spec#albumart_mimetype.) { |
| 1699 | case MIMETYPE_JPEGcxx . . $ MIMETYPE_JPEG.: |
| 1700 | albumart_mime = mime_jpeg; |
| 1701 | break; |
| 1702 | case MIMETYPE_PNGcxx . . $ MIMETYPE_PNG.: |
| 1703 | albumart_mime = mime_png; |
| 1704 | break; |
| 1705 | case MIMETYPE_GIFcxx . . $ MIMETYPE_GIF.: |
| 1706 | albumart_mime = mime_gif; |
| 1707 | break; |
| 1708 | } |
| 1709 | if (albumart_mime) { |
| 1710 | tag_size += 10 + 4 + strlencxx . . $ strlen(751346f8406fd082).(albumart_mime) + gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_sizecxx . . $ id3tag_spec#albumart_size.; |
| 1711 | } |
| 1712 | } |
| 1713 | { |
| 1714 | id3tag_speccxx . . $ id3tag_spec# *tag = &gfc->tag_speccxx . . $ lame_internal_flags#tag_spec.; |
| 1715 | if (tag->v2_headcxx . . $ id3tag_spec#v2_head. != 0) { |
| 1716 | FrameDataNodecxx . . $ FrameDataNode# *node; |
| 1717 | for (node = tag->v2_headcxx . . $ id3tag_spec#v2_head.; node != 0; node = node->nxtcxx . . $ FrameDataNode#nxt.) { |
| 1718 | if (node->fidcxx . . $ FrameDataNode#fid. == ID_COMMENTcxx . . $ ID_COMMENT. || node->fidcxx . . $ FrameDataNode#fid. == ID_USERcxx . . $ ID_USER.) { |
| 1719 | tag_size += sizeOfCommentNodecxx . . $ sizeOfCommentNode(f3430c5f57b12b8c).(node); |
| 1720 | } |
| 1721 | else if (isFrameIdMatchingcxx . . $ isFrameIdMatching(9b79fb6aee4c0440).(node->fidcxx . . $ FrameDataNode#fid., FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('W',0,0,0))) { |
| 1722 | tag_size += sizeOfWxxxNodecxx . . $ sizeOfWxxxNode(f3430c5f57b12b8c).(node); |
| 1723 | } |
| 1724 | else { |
| 1725 | tag_size += sizeOfNodecxx . . $ sizeOfNode(f3430c5f57b12b8c).(node); |
| 1726 | } |
| 1727 | } |
| 1728 | } |
| 1729 | } |
| 1730 | if (test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, PAD_V2_FLAGcxx . . $ `external/lame/id3tag.h:11:9`!)) { |
| 1731 | /* add some bytes of padding */ |
| 1732 | tag_size += gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..padding_sizecxx . . $ id3tag_spec#padding_size.; |
| 1733 | } |
| 1734 | if (size < tag_size) { |
| 1735 | return tag_size; |
| 1736 | } |
| 1737 | if (buffer == 0) { |
| 1738 | return 0; |
| 1739 | } |
| 1740 | p = buffer; |
| 1741 | /* set tag header starting with file identifier */ |
| 1742 | *p++ = 'I'; |
| 1743 | *p++ = 'D'; |
| 1744 | *p++ = '3'; |
| 1745 | /* set version number word */ |
| 1746 | *p++ = 3; |
| 1747 | *p++ = 0; |
| 1748 | /* clear flags byte */ |
| 1749 | *p++ = 0; |
| 1750 | /* calculate and set tag size = total size - header size */ |
| 1751 | adjusted_tag_size = tag_size - 10; |
| 1752 | /* encode adjusted size into four bytes where most significant |
| 1753 | * bit is clear in each byte, for 28-bit total */ |
| 1754 | *p++ = (unsigned char) ((adjusted_tag_size >> 21) & 0x7fu); |
| 1755 | *p++ = (unsigned char) ((adjusted_tag_size >> 14) & 0x7fu); |
| 1756 | *p++ = (unsigned char) ((adjusted_tag_size >> 7) & 0x7fu); |
| 1757 | *p++ = (unsigned char) (adjusted_tag_size & 0x7fu); |
| 1758 | |
| 1759 | /* |
| 1760 | * NOTE: The remainder of the tag (frames and padding, if any) |
| 1761 | * are not "unsynchronized" to prevent false MPEG audio headers |
| 1762 | * from appearing in the bitstream. Why? Well, most players |
| 1763 | * and utilities know how to skip the ID3 version 2 tag by now |
| 1764 | * even if they don't read its contents, and it's actually |
| 1765 | * very unlikely that such a false "sync" pattern would occur |
| 1766 | * in just the simple text frames added here. |
| 1767 | */ |
| 1768 | |
| 1769 | /* set each frame in tag */ |
| 1770 | { |
| 1771 | id3tag_speccxx . . $ id3tag_spec# *tag = &gfc->tag_speccxx . . $ lame_internal_flags#tag_spec.; |
| 1772 | if (tag->v2_headcxx . . $ id3tag_spec#v2_head. != 0) { |
| 1773 | FrameDataNodecxx . . $ FrameDataNode# *node; |
| 1774 | for (node = tag->v2_headcxx . . $ id3tag_spec#v2_head.; node != 0; node = node->nxtcxx . . $ FrameDataNode#nxt.) { |
| 1775 | if (node->fidcxx . . $ FrameDataNode#fid. == ID_COMMENTcxx . . $ ID_COMMENT. || node->fidcxx . . $ FrameDataNode#fid. == ID_USERcxx . . $ ID_USER.) { |
| 1776 | p = set_frame_commentcxx . . $ set_frame_comment(4834806e85543c2f).(p, node); |
| 1777 | } |
| 1778 | else if (isFrameIdMatchingcxx . . $ isFrameIdMatching(9b79fb6aee4c0440).(node->fidcxx . . $ FrameDataNode#fid.,FRAME_IDcxx . . $ `external/lame/id3tag.c:118:9`!('W',0,0,0))) { |
| 1779 | p = set_frame_wxxxcxx . . $ set_frame_wxxx(4834806e85543c2f).(p, node); |
| 1780 | } |
| 1781 | else { |
| 1782 | p = set_frame_custom2cxx . . $ set_frame_custom2(4834806e85543c2f).(p, node); |
| 1783 | } |
| 1784 | } |
| 1785 | } |
| 1786 | } |
| 1787 | if (albumart_mime) { |
| 1788 | p = set_frame_apiccxx . . $ set_frame_apic(3d5c3cf7d671dc30).(p, albumart_mime, gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumartcxx . . $ id3tag_spec#albumart., |
| 1789 | gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumart_sizecxx . . $ id3tag_spec#albumart_size.); |
| 1790 | } |
| 1791 | /* clear any padding bytes */ |
| 1792 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(p, 0, tag_size - (p - buffer)); |
| 1793 | return tag_size; |
| 1794 | } |
| 1795 | } |
| 1796 | return 0; |
| 1797 | } |
| 1798 | |
| 1799 | int |
| 1800 | id3tag_write_v2cxx . . $ id3tag_write_v2(12e50c934c2e73e2).(lame_tcxx . . $ lame_t# gfp) |
| 1801 | { |
| 1802 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc = 0; |
| 1803 | |
| 1804 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1805 | return 0; |
| 1806 | } |
| 1807 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 1808 | #if 0 |
| 1809 | debug_tag_spec_flags(gfc, "write v2"); |
| 1810 | #endif |
| 1811 | if (test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, V1_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:8:9`!)) { |
| 1812 | return 0; |
| 1813 | } |
| 1814 | if (test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!)) { |
| 1815 | unsigned char *tag = 0; |
| 1816 | size_t tag_size, n; |
| 1817 | |
| 1818 | n = lame_get_id3v2_tagcxx . . $ lame_get_id3v2_tag(407641c14281c852).(gfp, 0, 0); |
| 1819 | tag = lame_calloccxx . . $ `external/lame/machine.h:161:9`!(unsigned char, n); |
| 1820 | if (tag == 0) { |
| 1821 | return -1; |
| 1822 | } |
| 1823 | tag_size = lame_get_id3v2_tagcxx . . $ lame_get_id3v2_tag(407641c14281c852).(gfp, tag, n); |
| 1824 | if (tag_size > n) { |
| 1825 | freecxx . . $ free(5d22bdacc48458e8).(tag); |
| 1826 | return -1; |
| 1827 | } |
| 1828 | else { |
| 1829 | size_t i; |
| 1830 | /* write tag directly into bitstream at current position */ |
| 1831 | for (i = 0; i < tag_size; ++i) { |
| 1832 | add_dummy_bytecxx . . $ add_dummy_byte(7645f4bbedf0972b).(gfc, tag[i], 1); |
| 1833 | } |
| 1834 | } |
| 1835 | freecxx . . $ free(5d22bdacc48458e8).(tag); |
| 1836 | return (int) tag_size; /* ok, tag should not exceed 2GB */ |
| 1837 | } |
| 1838 | return 0; |
| 1839 | } |
| 1840 | |
| 1841 | static unsigned char * |
| 1842 | set_text_fieldcxx . . $ set_text_field(8aae49435a80a175).(unsigned char *field, const char *text, size_t size, int pad) |
| 1843 | { |
| 1844 | while (size--) { |
| 1845 | if (text && *text) { |
| 1846 | *field++ = *text++; |
| 1847 | } |
| 1848 | else { |
| 1849 | *field++ = pad; |
| 1850 | } |
| 1851 | } |
| 1852 | return field; |
| 1853 | } |
| 1854 | |
| 1855 | size_t |
| 1856 | lame_get_id3v1_tagcxx . . $ lame_get_id3v1_tag(407641c14281c852).(lame_tcxx . . $ lame_t# gfp, unsigned char *buffer, size_t size) |
| 1857 | { |
| 1858 | size_t const tag_size = 128; |
| 1859 | lame_internal_flagscxx . . $ lame_internal_flags# *gfc; |
| 1860 | |
| 1861 | if (gfp == 0) { |
| 1862 | return 0; |
| 1863 | } |
| 1864 | if (size < tag_size) { |
| 1865 | return tag_size; |
| 1866 | } |
| 1867 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 1868 | if (gfc == 0) { |
| 1869 | return 0; |
| 1870 | } |
| 1871 | if (buffer == 0) { |
| 1872 | return 0; |
| 1873 | } |
| 1874 | if (test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, V2_ONLY_FLAGcxx . . $ `external/lame/id3tag.h:9:9`!)) { |
| 1875 | return 0; |
| 1876 | } |
| 1877 | if (test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, CHANGED_FLAGcxx . . $ `external/lame/id3tag.h:6:9`!)) { |
| 1878 | unsigned char *p = buffer; |
| 1879 | int pad = test_tag_spec_flagscxx . . $ test_tag_spec_flags(3aa771da12a24ec).(gfc, SPACE_V1_FLAGcxx . . $ `external/lame/id3tag.h:10:9`!) ? ' ' : 0; |
| 1880 | char year[5]; |
| 1881 | |
| 1882 | /* set tag identifier */ |
| 1883 | *p++ = 'T'; |
| 1884 | *p++ = 'A'; |
| 1885 | *p++ = 'G'; |
| 1886 | /* set each field in tag */ |
| 1887 | p = set_text_fieldcxx . . $ set_text_field(8aae49435a80a175).(p, gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..titlecxx . . $ id3tag_spec#title., 30, pad); |
| 1888 | p = set_text_fieldcxx . . $ set_text_field(8aae49435a80a175).(p, gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..artistcxx . . $ id3tag_spec#artist., 30, pad); |
| 1889 | p = set_text_fieldcxx . . $ set_text_field(8aae49435a80a175).(p, gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..albumcxx . . $ id3tag_spec#album., 30, pad); |
| 1890 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(year, "%d", gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..yearcxx . . $ id3tag_spec#year.); |
| 1891 | p = set_text_fieldcxx . . $ set_text_field(8aae49435a80a175).(p, gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..yearcxx . . $ id3tag_spec#year. ? year : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 4, pad); |
| 1892 | /* limit comment field to 28 bytes if a track is specified */ |
| 1893 | p = set_text_fieldcxx . . $ set_text_field(8aae49435a80a175).(p, gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..commentcxx . . $ id3tag_spec#comment., gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..track_id3v1cxx . . $ id3tag_spec#track_id3v1. ? 28 : 30, pad); |
| 1894 | if (gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..track_id3v1cxx . . $ id3tag_spec#track_id3v1.) { |
| 1895 | /* clear the next byte to indicate a version 1.1 tag */ |
| 1896 | *p++ = 0; |
| 1897 | *p++ = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..track_id3v1cxx . . $ id3tag_spec#track_id3v1.; |
| 1898 | } |
| 1899 | *p++ = gfc->tag_speccxx . . $ lame_internal_flags#tag_spec..genre_id3v1cxx . . $ id3tag_spec#genre_id3v1.; |
| 1900 | return tag_size; |
| 1901 | } |
| 1902 | return 0; |
| 1903 | } |
| 1904 | |
| 1905 | int |
| 1906 | id3tag_write_v1cxx . . $ id3tag_write_v1(12e50c934c2e73e2).(lame_tcxx . . $ lame_t# gfp) |
| 1907 | { |
| 1908 | lame_internal_flagscxx . . $ lame_internal_flags#* gfc = 0; |
| 1909 | size_t i, n, m; |
| 1910 | unsigned char tag[128]; |
| 1911 | |
| 1912 | if (is_lame_internal_flags_nullcxx . . $ is_lame_internal_flags_null(12e50c934c2e73e2).(gfp)) { |
| 1913 | return 0; |
| 1914 | } |
| 1915 | gfc = gfp->internal_flagscxx . . $ lame_global_struct#internal_flags.; |
| 1916 | |
| 1917 | m = sizeof(tag); |
| 1918 | n = lame_get_id3v1_tagcxx . . $ lame_get_id3v1_tag(407641c14281c852).(gfp, tag, m); |
| 1919 | if (n > m) { |
| 1920 | return 0; |
| 1921 | } |
| 1922 | /* write tag directly into bitstream at current position */ |
| 1923 | for (i = 0; i < n; ++i) { |
| 1924 | add_dummy_bytecxx . . $ add_dummy_byte(7645f4bbedf0972b).(gfc, tag[i], 1); |
| 1925 | } |
| 1926 | return (int) n; /* ok, tag has fixed size of 128 bytes, well below 2GB */ |
| 1927 | } |