672 #define UNSYNC_FLAG 128 673 #define EXTHEAD_FLAG 64 675 #define FOOTER_FLAG 16 676 #define UNKNOWN_FLAGS 15 677 unsigned char buf[6];
679 unsigned char flags = 0;
685 unsigned char major = first4bytes & 0xff;
687 if(
major == 0xff)
return 0;
688 if((ret2 = fr->
rd->read_frame_body(fr,
buf, 6)) < 0)
691 if(
buf[0] == 0xff)
return 0;
697 #define synchsafe_to_long(buf,res) \ 699 (((buf)[0]|(buf)[1]|(buf)[2]|(buf)[3]) & 0x80) ? 0 : \ 700 (res = (((unsigned long) (buf)[0]) << 21) \ 701 | (((unsigned long) (buf)[1]) << 14) \ 702 | (((unsigned long) (buf)[2]) << 7) \ 703 | ((unsigned long) (buf)[3]) \ 708 #define bytes_to_long(buf,res) \ 711 (res = (((unsigned long) (buf)[0]) << 24) \ 712 | (((unsigned long) (buf)[1]) << 16) \ 713 | (((unsigned long) (buf)[2]) << 8) \ 714 | ((unsigned long) (buf)[3]) \ 715 ,1) : synchsafe_to_long(buf,res) \ 718 #define threebytes_to_long(buf,res) \ 720 res = (((unsigned long) (buf)[0]) << 16) \ 721 | (((unsigned long) (buf)[1]) << 8) \ 722 | ((unsigned long) (buf)[2]) \ 731 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]);
741 fprintf(
stderr,
"Note: Skipping ID3v2 tag per user request.\n");
747 warning2(
"ID3v2: Won't parse the ID3v2 tag with major version" 748 " %u and flags 0x%xu - some extra code may be needed" 755 warning1(
"ID3v2: unrealistic small tag lengh %lu, skipping",
length);
761 if((ret2 = fr->
rd->skip_bytes(fr,
length)) < 0)
767 unsigned char* tagdata =
NULL;
772 debug(
"ID3v2: analysing frames...");
773 if((ret2 = fr->
rd->read_frame_body(fr,tagdata,
length)) > 0)
775 unsigned long tagpos = 0;
781 unsigned int framebegin = head_part+head_part+flag_part;
782 debug1(
"ID3v2: have read at all %lu bytes for the tag now", (
unsigned long)
length+6);
787 debug(
"ID3v2: skipping extended header");
792 error4(
"Bad (non-synchsafe/too large) tag offset:" 794 , tagdata[0], tagdata[1], tagdata[2], tagdata[3] );
800 unsigned long framesize;
801 unsigned long fflags;
807 while(
length >= tagpos+framebegin)
810 unsigned long pos = tagpos;
815 for(
i=0;
i< head_part; ++
i)
816 if( !( ((tagdata[tagpos+
i] > 47) && (tagdata[tagpos+
i] < 58))
817 || ((tagdata[tagpos+
i] > 64) && (tagdata[tagpos+
i] < 91)) ) )
819 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]);
821 goto tagparse_cleanup;
836 if(
NOQUIET)
error1(
"ID3v2: non-syncsafe size of %s frame, skipping the remainder of tag",
id);
844 fflags = (((
unsigned long) tagdata[
pos]) << 8) | ((
unsigned long) tagdata[
pos+1]);
850 if(
length - tagpos < framesize)
852 if(
NOQUIET)
error(
"Whoa! ID3v2 frame claims to be larger than the whole rest of the tag.");
859 #define BAD_FFLAGS (unsigned long) 36784 860 #define PRES_TAG_FFLAG 16384 861 #define PRES_FILE_FFLAG 8192 862 #define READ_ONLY_FFLAG 4096 863 #define GROUP_FFLAG 64 864 #define COMPR_FFLAG 8 866 #define UNSYNC_FFLAG 2 867 #define DATLEN_FFLAG 1 880 if(
id[0] ==
'T' && tt !=
extra) tt =
text;
885 unsigned long realsize = framesize;
886 unsigned char* realdata = tagdata+
pos;
887 unsigned char* unsyncbuffer =
NULL;
890 unsigned long ipos = 0;
891 unsigned long opos = 0;
892 debug(
"Id3v2: going to de-unsync the frame data");
896 realdata = unsyncbuffer =
malloc(framesize+1);
899 if(
NOQUIET)
error(
"ID3v2: unable to allocate working buffer for de-unsync");
903 realdata[0] = tagdata[
pos];
905 for(ipos =
pos+1; ipos <
pos+framesize; ++ipos)
907 if(!((tagdata[ipos] == 0) && (tagdata[ipos-1] == 0xff)))
909 realdata[opos++] = tagdata[ipos];
914 realdata[realsize] = 0;
915 debug2(
"ID3v2: de-unsync made %lu out of %lu bytes", realsize, framesize);
920 if(realsize)
switch(tt)
939 if(fr->
rva.level[rva_mode] <=
rva2+1)
944 if(
pos > realsize || realsize-
pos < 3)
947 error(
"bad RVA2 tag (truncated?)");
949 else if(realdata[
pos] == 1)
953 debug(
"ID3v2: it is for the master channel");
959 ((
short)((
signed char*)realdata)[
pos]) * 256 + (
short)realdata[
pos+1] ) / 512;
963 fr->
rva.peak[rva_mode] = 0;
964 fr->
rva.level[rva_mode] =
rva2+1;
978 default:
if(
NOQUIET)
error1(
"ID3v2: unknown frame type %i", tt);
984 #undef PRES_TAG_FFLAG 985 #undef PRES_FILE_FFLAG 986 #undef READ_ONLY_FFLAG 1009 if(
NOQUIET)
error1(
"ID3v2: Arrg! Unable to allocate %lu bytes for interpreting ID3v2 data - trying to skip instead.",
length);
1010 if((ret2 = fr->
rd->skip_bytes(fr,
length)) < 0)
ret = ret2;
struct mpg123_pars_struct p
#define threebytes_to_long(buf, res)
ACPI_SIZE strlen(const char *String)
GLenum GLuint GLenum GLsizei const GLchar * buf
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
#define bytes_to_long(buf, res)
static void process_extra(mpg123_handle *fr, unsigned char *realdata, size_t realsize, int rva_level, char *id)
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
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)
GLenum GLuint GLenum GLsizei length
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
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)
struct mpg123_handle_struct::@3323 rva
#define synchsafe_to_long(buf, res)