ReactOS  0.4.15-dev-1206-g731eddf
id3.h File Reference
#include "frame.h"
Include dependency graph for id3.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void init_id3 (mpg123_handle *fr)
 
void exit_id3 (mpg123_handle *fr)
 
void reset_id3 (mpg123_handle *fr)
 
void id3_link (mpg123_handle *fr)
 
int parse_new_id3 (mpg123_handle *fr, unsigned long first4bytes)
 
void id3_to_utf8 (mpg123_string *sb, unsigned char encoding, const unsigned char *source, size_t source_size, int noquiet)
 

Function Documentation

◆ exit_id3()

void exit_id3 ( mpg123_handle fr)

Definition at line 284 of file id3.c.

285 {
286  free_picture(fr);
287  free_comment(fr);
288  free_extra(fr);
289  free_text(fr);
290 }
#define free_picture(mh)
Definition: id3.c:187
#define free_comment(mh)
Definition: id3.c:184
#define free_text(mh)
Definition: id3.c:185
#define free_extra(mh)
Definition: id3.c:186

Referenced by reset_id3().

◆ id3_link()

void id3_link ( mpg123_handle fr)

Definition at line 299 of file id3.c.

300 {
301  size_t i;
302  mpg123_id3v2 *v2 = &fr->id3v2;
303  debug("linking ID3v2");
304  null_id3_links(fr);
305  for(i=0; i<v2->texts; ++i)
306  {
307  mpg123_text *entry = &v2->text[i];
308  if (!strncmp("TIT2", entry->id, 4)) v2->title = &entry->text;
309  else if(!strncmp("TALB", entry->id, 4)) v2->album = &entry->text;
310  else if(!strncmp("TPE1", entry->id, 4)) v2->artist = &entry->text;
311  else if(!strncmp("TYER", entry->id, 4)) v2->year = &entry->text;
312  else if(!strncmp("TCON", entry->id, 4)) v2->genre = &entry->text;
313  }
314  for(i=0; i<v2->comments; ++i)
315  {
316  mpg123_text *entry = &v2->comment_list[i];
317  if(entry->description.fill == 0 || entry->description.p[0] == 0)
318  v2->comment = &entry->text;
319  }
320  /* When no generic comment found, use the last non-generic one. */
321  if(v2->comment == NULL && v2->comments > 0)
322  v2->comment = &v2->comment_list[v2->comments-1].text;
323 }
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
Definition: glfuncs.h:248
static void null_id3_links(mpg123_handle *fr)
Definition: id3.c:119
smooth NULL
Definition: ftsmooth.c:416
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
uint32_t entry
Definition: isohybrid.c:63
mpg123_id3v2 id3v2
Definition: frame.h:298
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
#define debug(msg)
Definition: key_call.c:71

◆ id3_to_utf8()

void id3_to_utf8 ( mpg123_string sb,
unsigned char  encoding,
const unsigned char source,
size_t  source_size,
int  noquiet 
)

Definition at line 374 of file id3.c.

375 {
376  unsigned int bwidth;
377  if(sb)
378  sb->fill = 0;
379  debug1("encoding: %u", encoding);
380  /* A note: ID3v2.3 uses UCS-2 non-variable 16bit encoding, v2.4 uses UTF16.
381  UTF-16 uses a reserved/private range in UCS-2 to add the magic, so we just always treat it as UTF. */
382  bwidth = encoding_widths[encoding];
383  /* Hack! I've seen a stray zero byte before BOM. Is that supposed to happen? */
384  if(encoding != mpg123_id3_utf16be) /* UTF16be _can_ beging with a null byte! */
385  while(source_size > bwidth && source[0] == 0)
386  {
387  --source_size;
388  ++source;
389  debug("skipped leading zero");
390  }
391  if(source_size % bwidth)
392  {
393  /* When we need two bytes for a character, it's strange to have an uneven bytestream length. */
394  if(noquiet) warning2("Weird tag size %d for encoding %u - I will probably trim too early or something but I think the MP3 is broken.", (int)source_size, encoding);
395  source_size -= source_size % bwidth;
396  }
397  text_converters[encoding](sb, source, source_size, noquiet);
398 }
superblock * sb
Definition: btrfs.c:4220
static const unsigned int encoding_widths[4]
Definition: id3.c:115
#define warning2(s, a, b)
Definition: debug.h:85
ed encoding
Definition: write.c:2825
static const text_converter text_converters[4]
Definition: id3.c:105
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
#define debug(msg)
Definition: key_call.c:71
#define debug1(s, a)
Definition: debug.h:61

Referenced by process_picture(), and store_id3_text().

◆ init_id3()

void init_id3 ( mpg123_handle fr)

Definition at line 129 of file id3.c.

130 {
131  fr->id3v2.version = 0; /* nothing there */
132  null_id3_links(fr);
133  fr->id3v2.comments = 0;
134  fr->id3v2.comment_list = NULL;
135  fr->id3v2.texts = 0;
136  fr->id3v2.text = NULL;
137  fr->id3v2.extras = 0;
138  fr->id3v2.extra = NULL;
139  fr->id3v2.pictures = 0;
140  fr->id3v2.picture = NULL;
141 }
mpg123_text * extra
Definition: mpg123.h:1442
mpg123_text * text
Definition: mpg123.h:1440
static void null_id3_links(mpg123_handle *fr)
Definition: id3.c:119
smooth NULL
Definition: ftsmooth.c:416
unsigned char version
Definition: mpg123.h:1429
size_t texts
Definition: mpg123.h:1441
mpg123_picture * picture
Definition: mpg123.h:1444
mpg123_id3v2 id3v2
Definition: frame.h:298
size_t extras
Definition: mpg123.h:1443
size_t pictures
Definition: mpg123.h:1446
size_t comments
Definition: mpg123.h:1439
mpg123_text * comment_list
Definition: mpg123.h:1438

Referenced by reset_id3().

◆ parse_new_id3()

int parse_new_id3 ( mpg123_handle fr,
unsigned long  first4bytes 
)

Definition at line 845 of file id3.c.

846 {
847  #define UNSYNC_FLAG 128
848  #define EXTHEAD_FLAG 64 /* ID3v2.3+ */
849  #define COMPRESS_FLAG 64 /* ID3v2.2 */
850  #define EXP_FLAG 32
851  #define FOOTER_FLAG 16
852  #define EXT_UPDATE_FLAG 64 /* ID3v2.4 only: extended header update flag */
853  #define UNKNOWN_FLAGS 15 /* 00001111*/
854  unsigned char buf[6];
855  unsigned long length=0;
856  unsigned char flags = 0;
857  int ret = 1;
858  off_t ret2;
859  int storetag = 0;
860  unsigned int footlen = 0;
861 #ifndef NO_ID3V2
862  int skiptag = 0;
863 #endif
864  unsigned char major = first4bytes & 0xff;
865  debug1("ID3v2: major tag version: %i", major);
866 
867  if(major == 0xff) return 0; /* Invalid... */
868  if((ret2 = fr->rd->read_frame_body(fr, buf, 6)) < 0) /* read more header information */
869  return ret2;
870 
871  if(buf[0] == 0xff) return 0; /* Revision, will never be 0xff. */
872 
873  if(fr->p.flags & MPG123_STORE_RAW_ID3)
874  storetag = 1;
875  /* second new byte are some nice flags, if these are invalid skip the whole thing */
876  flags = buf[1];
877  debug1("ID3v2: flags 0x%08x", flags);
878  /* use 4 bytes from buf to construct 28bit uint value and return 1; return 0 if bytes are not synchsafe */
879  #define synchsafe_to_long(buf,res) \
880  ( \
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]) \
886  ,1) \
887  )
888  /* id3v2.3 does not store synchsafe frame sizes, but synchsafe tag size - doh! */
889  /* Remember: bytes_to_long() can yield ULONG_MAX on 32 bit platforms! */
890  #define bytes_to_long(buf,res) \
891  ( \
892  major == 3 ? \
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) \
898  )
899  /* for id3v2.2 only */
900  #define threebytes_to_long(buf,res) \
901  ( \
902  res = (((unsigned long) (buf)[0]) << 16) \
903  | (((unsigned long) (buf)[1]) << 8) \
904  | ((unsigned long) (buf)[2]) \
905  )
906 
907  /* length-10 or length-20 (footer present); 4 synchsafe integers == 28 bit number */
908  /* we have already read 10 bytes, so left are length or length+10 bytes belonging to tag */
909  /* Note: This is an 28 bit value in 32 bit storage, plenty of space for */
910  /* length+x for reasonable x. */
912  {
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]);
914  return 0;
915  }
916  if(flags & FOOTER_FLAG)
917  footlen = 10;
918  debug1("ID3v2: tag data length %lu", length);
919 #ifndef NO_ID3V2
920  if(VERBOSE2) fprintf(stderr,"Note: ID3v2.%i rev %i tag of %lu bytes\n", major, buf[0], length);
921  /* skip if unknown version/scary flags, parse otherwise */
922  if(fr->p.flags & MPG123_SKIP_ID3V2)
923  {
924  if(VERBOSE3)
925  fprintf(stderr, "Note: Skipping ID3v2 tag per user request.\n");
926  skiptag = 1;
927  }
928  if((flags & UNKNOWN_FLAGS) || (major > 4) || (major < 2))
929  {
930  if(NOQUIET)
931  warning2( "ID3v2: Won't parse the ID3v2 tag with major version"
932  " %u and flags 0x%xu - some extra code may be needed"
933  , major, flags );
934  skiptag = 1;
935  }
936  // Standard says that compressed tags should be ignored as there isn't an agreed
937  // compressoion scheme.
938  if(major == 2 && flags & COMPRESS_FLAG)
939  {
940  if(NOQUIET)
941  warning("ID3v2: ignoring compressed ID3v2.2 tag");
942  skiptag = 1;
943  }
944  if(length < 10)
945  {
946  if(NOQUIET)
947  warning1("ID3v2: unrealistic small tag lengh %lu, skipping", length);
948  skiptag = 1;
949  }
950  if(!skiptag)
951  storetag = 1;
952 #endif
953  if(storetag)
954  {
955  /* Stores whole tag with footer and an additonal trailing zero. */
956  if((ret2 = store_id3v2(fr, first4bytes, buf, length+footlen)) <= 0)
957  return ret2;
958  }
959 #ifndef NO_ID3V2
960  if(skiptag)
961  {
962  if(VERBOSE3)
963  fprintf(stderr, "Note: skipped tag clearing possibly existing ID3v2 data");
964  reset_id3(fr); // Old data is invalid.
965 #endif
966  if(!storetag && (ret2=fr->rd->skip_bytes(fr,length+footlen))<0)
967  ret=ret2;
968 #ifndef NO_ID3V2
969  }
970  else
971  {
972  unsigned char* tagdata = fr->id3v2_raw+10;
973  /* try to interpret that beast */
974  debug("ID3v2: analysing frames...");
975  if(length > 0)
976  {
977  unsigned char extflags = 0;
978  unsigned long tagpos = 0;
979  /* bytes of frame title and of framesize value */
980  unsigned int head_part = major > 2 ? 4 : 3;
981  unsigned int flag_part = major > 2 ? 2 : 0;
982  /* The amount of bytes that are unconditionally read for each frame: */
983  /* ID, size, flags. */
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);
986  if(flags & EXTHEAD_FLAG)
987  {
988  debug("ID3v2: extended header");
989  if(!bytes_to_long(tagdata, tagpos) || tagpos >= length)
990  {
991  ret = 0;
992  if(NOQUIET)
993  error4( "Bad (non-synchsafe/too large) tag offset from extended header:"
994  "0x%02x%02x%02x%02x"
995  , tagdata[0], tagdata[1], tagdata[2], tagdata[3] );
996  } else if(tagpos < 6)
997  {
998  ret = 0;
999  if(NOQUIET)
1000  merror("Extended header too small (%lu).", tagpos);
1001  }
1002  if(major == 3)
1003  {
1004  tagpos += 4; // The size itself is not included.
1005  if(tagpos >= length)
1006  {
1007  ret = 0;
1008  if(NOQUIET)
1009  error("Too much extended v2.3 header.");
1010  }
1011  } else if(ret) // v2.4 and at least got my 6 bytes of ext header
1012  {
1013  // Only v4 knows update frames, check for that.
1014  // Need to step back. Header is 4 bytes length, one byte flag size,
1015  // one byte flags. Flag size has to be 1!
1016  if(tagdata[4] == 1 && tagdata[5] & EXT_UPDATE_FLAG)
1017  {
1018  if(VERBOSE3)
1019  fprintf(stderr, "Note: ID3v2.4 update tag\n");
1020  extflags |= EXT_UPDATE_FLAG;
1021  }
1022  }
1023  }
1024  if(!(extflags & EXT_UPDATE_FLAG))
1025  {
1026  if(VERBOSE3)
1027  fprintf(stderr, "Note: non-update tag replacing existing ID3v2 data\n");
1028  reset_id3(fr);
1029  }
1030  if(ret > 0)
1031  {
1032  char id[5];
1033  unsigned long framesize;
1034  unsigned long fflags; /* need 16 bits, actually */
1035  id[4] = 0;
1036  fr->id3v2.version = major;
1037  /* Pos now advanced after ext head, now a frame has to follow. */
1038  /* Note: tagpos <= length, which is 28 bit integer, so both */
1039  /* far away from overflow for adding known small values. */
1040  /* I want to read at least one full header now. */
1041  while(length >= tagpos+framebegin)
1042  {
1043  int i = 0;
1044  unsigned long pos = tagpos;
1045  /* level 1,2,3 - 0 is info from lame/info tag! */
1046  /* rva tags with ascending significance, then general frames */
1047  enum frame_types tt = unknown;
1048  /* we may have entered the padding zone or any other strangeness: check if we have valid frame id characters */
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)) ) )
1052  {
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]);
1054  /* This is no hard error... let's just hope that we got something meaningful already (ret==1 in that case). */
1055  goto tagparse_cleanup; /* Need to escape two loops here. */
1056  }
1057  if(ret > 0)
1058  {
1059  /* 4 or 3 bytes id */
1060  strncpy(id, (char*) tagdata+pos, head_part);
1061  id[head_part] = 0; /* terminate for 3 or 4 bytes */
1062  pos += head_part;
1063  tagpos += head_part;
1064  /* size as 32 bits or 28 bits */
1065  if(fr->id3v2.version == 2) threebytes_to_long(tagdata+pos, framesize);
1066  else
1067  if(!bytes_to_long(tagdata+pos, framesize))
1068  {
1069  /* Just assume that up to now there was some good data. */
1070  if(NOQUIET) error1("ID3v2: non-syncsafe size of %s frame, skipping the remainder of tag", id);
1071  break;
1072  }
1073  if(VERBOSE3) fprintf(stderr, "Note: ID3v2 %s frame of size %lu\n", id, framesize);
1074  tagpos += head_part;
1075  pos += head_part;
1076  if(fr->id3v2.version > 2)
1077  {
1078  fflags = (((unsigned long) tagdata[pos]) << 8) | ((unsigned long) tagdata[pos+1]);
1079  pos += 2;
1080  tagpos += 2;
1081  }
1082  else fflags = 0;
1083 
1084  if(length - tagpos < framesize)
1085  {
1086  if(NOQUIET) error("Whoa! ID3v2 frame claims to be larger than the whole rest of the tag.");
1087  break;
1088  }
1089  tagpos += framesize; /* the important advancement in whole tag */
1090  /* for sanity, after full parsing tagpos should be == pos */
1091  /* debug4("ID3v2: found %s frame, size %lu (as bytes: 0x%08lx), flags 0x%016lx", id, framesize, framesize, fflags); */
1092  /* %0abc0000 %0h00kmnp */
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
1102  if(head_part < 4 && promote_framename(fr, id) != 0) continue;
1103 
1104  /* shall not or want not handle these */
1105  if(fflags & (BAD_FFLAGS | COMPR_FFLAG | ENCR_FFLAG))
1106  {
1107  if(NOQUIET) warning("ID3v2: skipping invalid/unsupported frame");
1108  continue;
1109  }
1110 
1111  for(i = 0; i < KNOWN_FRAMES; ++i)
1112  if(!strncmp(frame_type[i], id, 4)){ tt = i; break; }
1113 
1114  if(id[0] == 'T' && tt != extra) tt = text;
1115 
1116  if(tt != unknown)
1117  {
1118  int rva_mode = -1; /* mix / album */
1119  unsigned long realsize = framesize;
1120  unsigned char* realdata = tagdata+pos;
1121  unsigned char* unsyncbuffer = NULL;
1122  if(((flags & UNSYNC_FLAG) || (fflags & UNSYNC_FFLAG)) && framesize > 0)
1123  {
1124  unsigned long ipos = 0;
1125  unsigned long opos = 0;
1126  debug("Id3v2: going to de-unsync the frame data");
1127  /* de-unsync: FF00 -> FF; real FF00 is simply represented as FF0000 ... */
1128  /* damn, that means I have to delete bytes from withing the data block... thus need temporal storage */
1129  /* standard mandates that de-unsync should always be safe if flag is set */
1130  realdata = unsyncbuffer = malloc(framesize+1); /* will need <= bytes, plus a safety zero */
1131  if(realdata == NULL)
1132  {
1133  if(NOQUIET) error("ID3v2: unable to allocate working buffer for de-unsync");
1134  continue;
1135  }
1136  /* now going byte per byte through the data... */
1137  realdata[0] = tagdata[pos];
1138  opos = 1;
1139  for(ipos = pos+1; ipos < pos+framesize; ++ipos)
1140  {
1141  if(!((tagdata[ipos] == 0) && (tagdata[ipos-1] == 0xff)))
1142  {
1143  realdata[opos++] = tagdata[ipos];
1144  }
1145  }
1146  realsize = opos;
1147  /* Append a zero to keep strlen() safe. */
1148  realdata[realsize] = 0;
1149  debug2("ID3v2: de-unsync made %lu out of %lu bytes", realsize, framesize);
1150  }
1151  pos = 0; /* now at the beginning again... */
1152  /* Avoid reading over boundary, even if there is a */
1153  /* zero byte of padding for safety. */
1154  if(realsize) switch(tt)
1155  {
1156  case comment:
1157  case uslt:
1158  process_comment(fr, tt, realdata, realsize, comment+1, id);
1159  break;
1160  case extra: /* perhaps foobar2000's work */
1161  process_extra(fr, realdata, realsize, extra+1, id);
1162  break;
1163  case rva2: /* "the" RVA tag */
1164  {
1165  /* starts with null-terminated identification */
1166  if(VERBOSE3) fprintf(stderr, "Note: RVA2 identification \"%s\"\n", realdata);
1167  /* default: some individual value, mix mode */
1168  rva_mode = 0;
1169  if( !strncasecmp((char*)realdata, "album", 5)
1170  || !strncasecmp((char*)realdata, "audiophile", 10)
1171  || !strncasecmp((char*)realdata, "user", 4))
1172  rva_mode = 1;
1173  if(fr->rva.level[rva_mode] <= rva2+1)
1174  {
1175  pos += strlen((char*) realdata) + 1;
1176  debug2("got my pos: %zu - %zu", realsize, pos);
1177  // channel and two bytes for RVA value
1178  // pos possibly just past the safety zero, so one more than realsize
1179  if(pos > realsize || realsize-pos < 3)
1180  {
1181  if(NOQUIET)
1182  error("bad RVA2 tag (truncated?)");
1183  }
1184  else if(realdata[pos] == 1)
1185  {
1186  ++pos;
1187  /* only handle master channel */
1188  debug("ID3v2: it is for the master channel");
1189  /* two bytes adjustment, one byte for bits representing peak - n bytes, eh bits, for peak */
1190  /* 16 bit signed integer = dB * 512. Do not shift signed integers! Multiply instead.
1191  Also no implementation-defined casting. Reinterpret the pointer to signed char, then do
1192  proper casting. */
1193  fr->rva.gain[rva_mode] = (float) (
1194  ((short)((signed char*)realdata)[pos]) * 256 + (short)realdata[pos+1] ) / 512;
1195  pos += 2;
1196  if(VERBOSE3) fprintf(stderr, "Note: RVA value %fdB\n", fr->rva.gain[rva_mode]);
1197  /* heh, the peak value is represented by a number of bits - but in what manner? Skipping that part */
1198  fr->rva.peak[rva_mode] = 0;
1199  fr->rva.level[rva_mode] = rva2+1;
1200  }
1201  }
1202  }
1203  break;
1204  /* non-rva metainfo, simply store... */
1205  case text:
1206  process_text(fr, realdata, realsize, id);
1207  break;
1208  case picture:
1209  if (fr->p.flags & MPG123_PICTURE)
1210  process_picture(fr, realdata, realsize);
1211 
1212  break;
1213  default: if(NOQUIET) error1("ID3v2: unknown frame type %i", tt);
1214  }
1215  if(unsyncbuffer)
1216  free(unsyncbuffer);
1217  }
1218  #undef BAD_FFLAGS
1219  #undef PRES_TAG_FFLAG
1220  #undef PRES_FILE_FFLAG
1221  #undef READ_ONLY_FFLAG
1222  #undef GROUP_FFLAG
1223  #undef COMPR_FFLAG
1224  #undef ENCR_FFLAG
1225  #undef UNSYNC_FFLAG
1226  #undef DATLEN_FFLAG
1227  }
1228  else break;
1229  #undef KNOWN_FRAMES
1230  }
1231  } else
1232  {
1233  if(VERBOSE3)
1234  fprintf(stderr, "Note: faulty ID3v2 tag still clearing old data\n");
1235  reset_id3(fr);
1236  }
1237  } else // No new data, but still there was a tag that invalidates old data.
1238  {
1239  if(VERBOSE3)
1240  fprintf(stderr, "Note: empty ID3v2 clearing old data\n");
1241  reset_id3(fr);
1242  }
1243 tagparse_cleanup:
1244  /* Get rid of stored raw data that should not be kept. */
1245  if(!(fr->p.flags & MPG123_STORE_RAW_ID3))
1246  {
1247  free(fr->id3v2_raw);
1248  fr->id3v2_raw = NULL;
1249  fr->id3v2_size = 0;
1250  }
1251  }
1252 #endif /* NO_ID3V2 */
1253  return ret;
1254  #undef UNSYNC_FLAG
1255  #undef EXTHEAD_FLAG
1256  #undef COMPRESS_FLAG
1257  #undef EXP_FLAG
1258  #undef FOOTER_FLAG
1259  #undef EXT_UPDATE_FLAG
1260  #undef UNKOWN_FLAGS
1261 }
Definition: id3.c:95
struct mpg123_pars_struct p
Definition: frame.h:289
#define threebytes_to_long(buf, res)
#define error(str)
Definition: mkdosfs.c:1605
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define error1(s, a)
Definition: debug.h:125
size_t id3v2_size
Definition: frame.h:301
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define free
Definition: debug_ros.c:5
__kernel_off_t off_t
Definition: linux.h:201
unsigned char * id3v2_raw
Definition: frame.h:300
int store_id3v2(mpg123_handle *fr, unsigned long first4bytes, unsigned char buf[6], unsigned long length)
Definition: id3.c:794
#define bytes_to_long(buf, res)
#define debug2(s, a, b)
Definition: debug.h:62
#define FOOTER_FLAG
static void process_extra(mpg123_handle *fr, unsigned char *realdata, size_t realsize, int rva_level, char *id)
Definition: id3.c:655
Definition: id3.c:95
struct mpg123_handle_struct::@3421 rva
#define COMPR_FFLAG
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
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
Definition: glfuncs.h:248
Definition: id3.c:95
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define strncasecmp
Definition: fake.h:10
#define ENCR_FFLAG
#define VERBOSE2
smooth NULL
Definition: ftsmooth.c:416
static void process_text(mpg123_handle *fr, unsigned char *realdata, size_t realsize, char *id)
Definition: id3.c:445
static int promote_framename(mpg123_handle *fr, char *id)
Definition: id3.c:762
unsigned char version
Definition: mpg123.h:1429
#define warning2(s, a, b)
Definition: debug.h:85
#define error4(s, a, b, c, d)
Definition: debug.h:128
#define VERBOSE3
static void process_comment(mpg123_handle *fr, enum frame_types tt, unsigned char *realdata, size_t realsize, int rva_level, char *id)
Definition: id3.c:551
#define UNKNOWN_FLAGS
#define UNSYNC_FLAG
Definition: id3.c:95
Definition: id3.c:95
#define KNOWN_FRAMES
Definition: id3.c:93
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define BAD_FFLAGS
#define UNSYNC_FFLAG
void reset_id3(mpg123_handle *fr)
Definition: id3.c:292
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
Definition: id3.c:95
GLbitfield flags
Definition: glext.h:7161
#define NOQUIET
int ret
#define COMPRESS_FLAG
Definition: id3.c:95
mpg123_id3v2 id3v2
Definition: frame.h:298
static float(__cdecl *square_half_float)(float x
#define EXTHEAD_FLAG
#define major(rdev)
Definition: propsheet.cpp:916
#define long
Definition: qsort.c:33
static void process_picture(mpg123_handle *fr, unsigned char *realdata, size_t realsize)
Definition: id3.c:465
static const char frame_type[KNOWN_FRAMES][5]
Definition: id3.c:94
FILE * stderr
#define debug(msg)
Definition: key_call.c:71
#define malloc
Definition: debug_ros.c:4
struct reader * rd
Definition: frame.h:287
#define debug5(s, a, b, c, d, e)
Definition: debug.h:65
#define debug1(s, a)
Definition: debug.h:61
#define EXT_UPDATE_FLAG
#define synchsafe_to_long(buf, res)
#define warning(s)
Definition: debug.h:83
frame_types
Definition: id3.c:95
#define merror(s,...)
Definition: debug.h:122
#define warning1(s, a)
Definition: debug.h:84

◆ reset_id3()

void reset_id3 ( mpg123_handle fr)

Definition at line 292 of file id3.c.

293 {
294  exit_id3(fr);
295  init_id3(fr);
296 }
void init_id3(mpg123_handle *fr)
Definition: id3.c:129
void exit_id3(mpg123_handle *fr)
Definition: id3.c:284

Referenced by parse_new_id3().