847 #define UNSYNC_FLAG 128 848 #define EXTHEAD_FLAG 64 849 #define COMPRESS_FLAG 64 851 #define FOOTER_FLAG 16 852 #define EXT_UPDATE_FLAG 64 853 #define UNKNOWN_FLAGS 15 854 unsigned char buf[6];
856 unsigned char flags = 0;
860 unsigned int footlen = 0;
864 unsigned char major = first4bytes & 0xff;
867 if(
major == 0xff)
return 0;
868 if((ret2 = fr->
rd->read_frame_body(fr,
buf, 6)) < 0)
871 if(
buf[0] == 0xff)
return 0;
879 #define synchsafe_to_long(buf,res) \ 881 (((buf)[0]|(buf)[1]|(buf)[2]|(buf)[3]) & 0x80) ? 0 : \ 882 (res = (((unsigned long) (buf)[0]) << 21) \ 883 | (((unsigned long) (buf)[1]) << 14) \ 884 | (((unsigned long) (buf)[2]) << 7) \ 885 | ((unsigned long) (buf)[3]) \ 890 #define bytes_to_long(buf,res) \ 893 (res = (((unsigned long) (buf)[0]) << 24) \ 894 | (((unsigned long) (buf)[1]) << 16) \ 895 | (((unsigned long) (buf)[2]) << 8) \ 896 | ((unsigned long) (buf)[3]) \ 897 ,1) : synchsafe_to_long(buf,res) \ 900 #define threebytes_to_long(buf,res) \ 902 res = (((unsigned long) (buf)[0]) << 16) \ 903 | (((unsigned long) (buf)[1]) << 8) \ 904 | ((unsigned long) (buf)[2]) \ 913 if(
NOQUIET)
error4(
"Bad tag length (not synchsafe): 0x%02x%02x%02x%02x; You got a bad ID3 tag here.",
buf[2],
buf[3],
buf[4],
buf[5]);
925 fprintf(
stderr,
"Note: Skipping ID3v2 tag per user request.\n");
931 warning2(
"ID3v2: Won't parse the ID3v2 tag with major version" 932 " %u and flags 0x%xu - some extra code may be needed" 941 warning(
"ID3v2: ignoring compressed ID3v2.2 tag");
947 warning1(
"ID3v2: unrealistic small tag lengh %lu, skipping",
length);
963 fprintf(
stderr,
"Note: skipped tag clearing possibly existing ID3v2 data");
966 if(!storetag && (ret2=fr->
rd->skip_bytes(fr,
length+footlen))<0)
972 unsigned char* tagdata = fr->
id3v2_raw+10;
974 debug(
"ID3v2: analysing frames...");
977 unsigned char extflags = 0;
978 unsigned long tagpos = 0;
980 unsigned int head_part =
major > 2 ? 4 : 3;
981 unsigned int flag_part =
major > 2 ? 2 : 0;
984 unsigned int framebegin = head_part+head_part+flag_part;
985 debug1(
"ID3v2: have read at all %lu bytes for the tag now", (
unsigned long)
length+6);
988 debug(
"ID3v2: extended header");
993 error4(
"Bad (non-synchsafe/too large) tag offset from extended header:" 995 , tagdata[0], tagdata[1], tagdata[2], tagdata[3] );
996 }
else if(tagpos < 6)
1000 merror(
"Extended header too small (%lu).", tagpos);
1009 error(
"Too much extended v2.3 header.");
1027 fprintf(
stderr,
"Note: non-update tag replacing existing ID3v2 data\n");
1033 unsigned long framesize;
1034 unsigned long fflags;
1041 while(
length >= tagpos+framebegin)
1044 unsigned long pos = tagpos;
1049 for(
i=0;
i< head_part; ++
i)
1050 if( !( ((tagdata[tagpos+
i] > 47) && (tagdata[tagpos+
i] < 58))
1051 || ((tagdata[tagpos+
i] > 64) && (tagdata[tagpos+
i] < 91)) ) )
1053 debug5(
"ID3v2: real tag data apparently ended after %lu bytes with 0x%02x%02x%02x%02x", tagpos, tagdata[tagpos], tagdata[tagpos+1], tagdata[tagpos+2], tagdata[tagpos+3]);
1055 goto tagparse_cleanup;
1063 tagpos += head_part;
1070 if(
NOQUIET)
error1(
"ID3v2: non-syncsafe size of %s frame, skipping the remainder of tag",
id);
1074 tagpos += head_part;
1078 fflags = (((
unsigned long) tagdata[
pos]) << 8) | ((
unsigned long) tagdata[
pos+1]);
1084 if(
length - tagpos < framesize)
1086 if(
NOQUIET)
error(
"Whoa! ID3v2 frame claims to be larger than the whole rest of the tag.");
1089 tagpos += framesize;
1093 #define BAD_FFLAGS (unsigned long) 36784 1094 #define PRES_TAG_FFLAG 16384 1095 #define PRES_FILE_FFLAG 8192 1096 #define READ_ONLY_FFLAG 4096 1097 #define GROUP_FFLAG 64 1098 #define COMPR_FFLAG 8 1099 #define ENCR_FFLAG 4 1100 #define UNSYNC_FFLAG 2 1101 #define DATLEN_FFLAG 1 1107 if(
NOQUIET)
warning(
"ID3v2: skipping invalid/unsupported frame");
1114 if(
id[0] ==
'T' && tt !=
extra) tt =
text;
1119 unsigned long realsize = framesize;
1120 unsigned char* realdata = tagdata+
pos;
1121 unsigned char* unsyncbuffer =
NULL;
1124 unsigned long ipos = 0;
1125 unsigned long opos = 0;
1126 debug(
"Id3v2: going to de-unsync the frame data");
1130 realdata = unsyncbuffer =
malloc(framesize+1);
1131 if(realdata ==
NULL)
1133 if(
NOQUIET)
error(
"ID3v2: unable to allocate working buffer for de-unsync");
1137 realdata[0] = tagdata[
pos];
1139 for(ipos =
pos+1; ipos <
pos+framesize; ++ipos)
1141 if(!((tagdata[ipos] == 0) && (tagdata[ipos-1] == 0xff)))
1143 realdata[opos++] = tagdata[ipos];
1148 realdata[realsize] = 0;
1149 debug2(
"ID3v2: de-unsync made %lu out of %lu bytes", realsize, framesize);
1154 if(realsize)
switch(tt)
1170 || !
strncasecmp((
char*)realdata,
"audiophile", 10)
1173 if(fr->
rva.level[rva_mode] <=
rva2+1)
1176 debug2(
"got my pos: %zu - %zu", realsize,
pos);
1179 if(
pos > realsize || realsize-
pos < 3)
1182 error(
"bad RVA2 tag (truncated?)");
1184 else if(realdata[
pos] == 1)
1188 debug(
"ID3v2: it is for the master channel");
1194 ((
short)((
signed char*)realdata)[
pos]) * 256 + (
short)realdata[
pos+1] ) / 512;
1198 fr->
rva.peak[rva_mode] = 0;
1199 fr->
rva.level[rva_mode] =
rva2+1;
1213 default:
if(
NOQUIET)
error1(
"ID3v2: unknown frame type %i", tt);
1219 #undef PRES_TAG_FFLAG 1220 #undef PRES_FILE_FFLAG 1221 #undef READ_ONLY_FFLAG 1234 fprintf(
stderr,
"Note: faulty ID3v2 tag still clearing old data\n");
1256 #undef COMPRESS_FLAG 1259 #undef EXT_UPDATE_FLAG
struct mpg123_pars_struct p
#define threebytes_to_long(buf, res)
ACPI_SIZE strlen(const char *String)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
unsigned char * id3v2_raw
int store_id3v2(mpg123_handle *fr, unsigned long first4bytes, unsigned char buf[6], unsigned long length)
struct mpg123_handle_struct::@3400 rva
#define bytes_to_long(buf, res)
static void process_extra(mpg123_handle *fr, unsigned char *realdata, size_t realsize, int rva_level, char *id)
GLenum GLuint GLenum GLsizei const GLchar * buf
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
GLenum GLuint GLenum GLsizei length
static void process_text(mpg123_handle *fr, unsigned char *realdata, size_t realsize, char *id)
static int promote_framename(mpg123_handle *fr, char *id)
#define warning2(s, a, b)
#define error4(s, a, b, c, d)
static void process_comment(mpg123_handle *fr, enum frame_types tt, unsigned char *realdata, size_t realsize, int rva_level, char *id)
void reset_id3(mpg123_handle *fr)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static float(__cdecl *square_half_float)(float x
static void process_picture(mpg123_handle *fr, unsigned char *realdata, size_t realsize)
static const char frame_type[KNOWN_FRAMES][5]
#define debug5(s, a, b, c, d, e)
#define synchsafe_to_long(buf, res)