mp3utils.c: very minor clean-up. SDL-1.2
authorOzkan Sezer
Sun, 22 Dec 2019 01:56:31 +0300
branchSDL-1.2
changeset 11100d4f21a5b678
parent 1104 d9a665f67ce0
child 1124 a606a79a3b9f
mp3utils.c: very minor clean-up.
mp3utils.c
     1.1 --- a/mp3utils.c	Fri Dec 20 15:55:00 2019 +0300
     1.2 +++ b/mp3utils.c	Sun Dec 22 01:56:31 2019 +0300
     1.3 @@ -40,12 +40,12 @@
     1.4  
     1.5  int MP3_RWseek(struct mp3file_t *fil, int offset, int whence) {
     1.6      int ret;
     1.7 -    switch (whence) { /* assumes a legal whence value */
     1.8 +    switch (whence) {
     1.9      case RW_SEEK_CUR:
    1.10          offset += fil->pos;
    1.11          break;
    1.12      case RW_SEEK_END:
    1.13 -        offset = fil->length + offset;
    1.14 +        offset += fil->length;
    1.15          break;
    1.16      }
    1.17      if (offset < 0) return -1;
    1.18 @@ -60,16 +60,14 @@
    1.19  
    1.20  /*************************** TAG HANDLING: ******************************/
    1.21  
    1.22 -static __inline__ SDL_bool is_id3v1(const unsigned char *data, int length)
    1.23 -{
    1.24 +static __inline__ SDL_bool is_id3v1(const unsigned char *data, int length) {
    1.25      /* http://id3.org/ID3v1 :  3 bytes "TAG" identifier and 125 bytes tag data */
    1.26      if (length < 3 || SDL_memcmp(data,"TAG",3) != 0) {
    1.27          return SDL_FALSE;
    1.28      }
    1.29      return SDL_TRUE;
    1.30  }
    1.31 -static SDL_bool is_id3v2(const unsigned char *data, int length)
    1.32 -{
    1.33 +static SDL_bool is_id3v2(const unsigned char *data, int length) {
    1.34      /* ID3v2 header is 10 bytes:  http://id3.org/id3v2.4.0-structure */
    1.35      /* bytes 0-2: "ID3" identifier */
    1.36      if (length < 10 || SDL_memcmp(data,"ID3",3) != 0) {
    1.37 @@ -87,8 +85,7 @@
    1.38      }
    1.39      return SDL_TRUE;
    1.40  }
    1.41 -static int get_id3v2_len(const unsigned char *data, int length)
    1.42 -{
    1.43 +static int get_id3v2_len(const unsigned char *data, int length) {
    1.44      /* size is a 'synchsafe' integer (see above) */
    1.45      int size = (int)((data[6]<<21) + (data[7]<<14) + (data[8]<<7) + data[9]);
    1.46      size += 10; /* header size */
    1.47 @@ -104,8 +101,7 @@
    1.48      }
    1.49      return size;
    1.50  }
    1.51 -static SDL_bool is_apetag(const unsigned char *data, int length)
    1.52 -{
    1.53 +static SDL_bool is_apetag(const unsigned char *data, int length) {
    1.54     /* http://wiki.hydrogenaud.io/index.php?title=APEv2_specification
    1.55      * Header/footer is 32 bytes: bytes 0-7 ident, bytes 8-11 version,
    1.56      * bytes 12-17 size. bytes 24-31 are reserved: must be all zeroes. */
    1.57 @@ -124,8 +120,7 @@
    1.58      }
    1.59      return SDL_TRUE;
    1.60  }
    1.61 -static int get_ape_len(const unsigned char *data)
    1.62 -{
    1.63 +static int get_ape_len(const unsigned char *data) {
    1.64      Uint32 flags, version;
    1.65      int size = (int)((data[15]<<24) | (data[14]<<16) | (data[13]<<8) | data[12]);
    1.66      version = (Uint32)((data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8]);
    1.67 @@ -163,7 +158,7 @@
    1.68      if (length != 6) return 0;
    1.69      return SDL_strtol((const char *)data, NULL, 10) + 15;
    1.70  }
    1.71 -static SDL_bool verify_lyrics3v2(const unsigned char *data, int length) {
    1.72 +static __inline__ SDL_bool verify_lyrics3v2(const unsigned char *data, int length) {
    1.73      if (length < 11) return SDL_FALSE;
    1.74      if (SDL_memcmp(data,"LYRICSBEGIN",11) == 0) return SDL_TRUE;
    1.75      return SDL_FALSE;
    1.76 @@ -335,7 +330,7 @@
    1.77              if (len >= fil->length) return -1;
    1.78              if (len < 15) return -1;
    1.79              MP3_RWseek(fil, -len, RW_SEEK_END);
    1.80 -            if (MP3_RWread(fil, buf, 1, 11)!= 11)
    1.81 +            if (MP3_RWread(fil, buf, 1, 11) != 11)
    1.82                  return -1;
    1.83              if (!verify_lyrics3v2(buf, 11)) return -1;
    1.84              fil->length -= len;
    1.85 @@ -361,6 +356,9 @@
    1.86      /* MP3 standard has no metadata format, so everyone invented
    1.87       * their own thing, even with extensions, until ID3v2 became
    1.88       * dominant: Hence the impossible mess here.
    1.89 +     *
    1.90 +     * Note: I don't yet care about freaky broken mp3 files with
    1.91 +     * double tags. -- O.S.
    1.92       */
    1.93  
    1.94      readsize = MP3_RWread(fil, buf, 1, 128);