Unified · Split
| @@ -12,6 +12,7 @@ Comparison to id3lib and taglib: · 11 unmodified lines | |||
| 12 | | FLAC | yes | no | yes | | 12 | | FLAC | yes | no | yes | |
| 13 | | m4a | yes | no | yes | | 13 | | m4a | yes | no | yes | |
| 14 | | opus | yes | no | yes | | 14 | | opus | yes | no | yes | |
| 15 | | WAV | yes | no | yes | | ||
| 15 | | replay gain | yes | no | ??? | | 16 | | replay gain | yes | no | ??? | |
| 16 | | size | tiny | bloated | more bloated | | 17 | | size | tiny | bloated | more bloated | |
| 17 | | license | MIT | LGPL | LGPL/MPL | | 18 | | license | MIT | LGPL | LGPL/MPL | |
| @@ -2,8 +2,6 @@ · 1 unmodified line | |||
| 2 | #include "tagspriv.h" | 2 | #include "tagspriv.h" |
| 3 | 3 | ||
| 4 | #define beu3(d) ((d)[0]<<16 | (d)[1]<<8 | (d)[2]<<0) | 4 | #define beu3(d) ((d)[0]<<16 | (d)[1]<<8 | (d)[2]<<0) |
| 5 | #define beuint(d) (uint)((d)[0]<<24 | (d)[1]<<16 | (d)[2]<<8 | (d)[3]<<0) | ||
| 6 | #define leuint(d) (uint)((d)[3]<<24 | (d)[2]<<16 | (d)[1]<<8 | (d)[0]<<0) | ||
| 7 | 5 | ||
| 8 | int | 6 | int |
| 9 | tagflac(Tagctx *ctx) | 7 | tagflac(Tagctx *ctx) |
| @@ -12,7 +12,6 @@ · 11 unmodified lines | |||
| 12 | #include "tagspriv.h" | 12 | #include "tagspriv.h" |
| 13 | 13 | ||
| 14 | #define synchsafe(d) (uint)(((d)[0]&127)<<21 | ((d)[1]&127)<<14 | ((d)[2]&127)<<7 | ((d)[3]&127)<<0) | 14 | #define synchsafe(d) (uint)(((d)[0]&127)<<21 | ((d)[1]&127)<<14 | ((d)[2]&127)<<7 | ((d)[3]&127)<<0) |
| 15 | #define beuint(d) (uint)((d)[0]<<24 | (d)[1]<<16 | (d)[2]<<8 | (d)[3]<<0) | ||
| 16 | 15 | ||
| 17 | static int | 16 | static int |
| 18 | v2cb(Tagctx *ctx, char *k, char *v) | 17 | v2cb(Tagctx *ctx, char *k, char *v) |
| @@ -2,7 +2,6 @@ · 1 unmodified line | |||
| 2 | /* https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html */ | 2 | /* https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html */ |
| 3 | #include "tagspriv.h" | 3 | #include "tagspriv.h" |
| 4 | 4 | ||
| 5 | #define beuint(d) (uint)((d)[0]<<24 | (d)[1]<<16 | (d)[2]<<8 | (d)[3]<<0) | ||
| 6 | #define beuint16(d) (ushort)((d)[0]<<8 | (d)[1]<<0) | 5 | #define beuint16(d) (ushort)((d)[0]<<8 | (d)[1]<<0) |
| 7 | 6 | ||
| 8 | int | 7 | int |
| @@ -12,6 +12,7 @@ OFILES=\ · 11 unmodified lines | |||
| 12 | tags.$O\ | 12 | tags.$O\ |
| 13 | utf16.$O\ | 13 | utf16.$O\ |
| 14 | vorbis.$O\ | 14 | vorbis.$O\ |
| 15 | wav.$O\ | ||
| 15 | 16 | ||
| 16 | HFILES=\ | 17 | HFILES=\ |
| 17 | /sys/include/tags.h\ | 18 | /sys/include/tags.h\ |
| @@ -1,7 +1,5 @@ | |||
| 1 | #include "tagspriv.h" | 1 | #include "tagspriv.h" |
| 2 | 2 | ||
| 3 | #define leuint(d) (uint)(((uchar*)(d))[3]<<24 | ((uchar*)(d))[2]<<16 | ((uchar*)(d))[1]<<8 | ((uchar*)(d))[0]<<0) | ||
| 4 | |||
| 5 | int | 3 | int |
| 6 | tagopus(Tagctx *ctx) | 4 | tagopus(Tagctx *ctx) |
| 7 | { | 5 | { |
| @@ -14,6 +14,7 @@ extern int tagid3v2(Tagctx *ctx); · 13 unmodified lines | |||
| 14 | extern int tagid3v1(Tagctx *ctx); | 14 | extern int tagid3v1(Tagctx *ctx); |
| 15 | extern int tagm4a(Tagctx *ctx); | 15 | extern int tagm4a(Tagctx *ctx); |
| 16 | extern int tagopus(Tagctx *ctx); | 16 | extern int tagopus(Tagctx *ctx); |
| 17 | extern int tagwav(Tagctx *ctx); | ||
| 17 | 18 | ||
| 18 | static const Getter g[] = | 19 | static const Getter g[] = |
| 19 | { | 20 | { |
| @@ -23,6 +24,7 @@ static const Getter g[] = · 3 unmodified lines | |||
| 23 | {tagflac, Fflac}, | 24 | {tagflac, Fflac}, |
| 24 | {tagm4a, Fm4a}, | 25 | {tagm4a, Fm4a}, |
| 25 | {tagopus, Fopus}, | 26 | {tagopus, Fopus}, |
| 27 | {tagwav, Fwav}, | ||
| 26 | }; | 28 | }; |
| 27 | 29 | ||
| 28 | void | 30 | void |
| @@ -31,6 +31,9 @@ enum · 30 unmodified lines | |||
| 31 | Fflac, | 31 | Fflac, |
| 32 | Fm4a, | 32 | Fm4a, |
| 33 | Fopus, | 33 | Fopus, |
| 34 | Fwav, | ||
| 35 | |||
| 36 | Fmax, | ||
| 34 | }; | 37 | }; |
| 35 | 38 | ||
| 36 | /* Tag parser context. You need to set it properly before parsing an audio file using libtags. */ | 39 | /* Tag parser context. You need to set it properly before parsing an audio file using libtags. */ |
| @@ -20,6 +20,9 @@ enum · 19 unmodified lines | |||
| 20 | Numgenre = 192, | 20 | Numgenre = 192, |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | #define beuint(d) (uint)((d)[0]<<24 | (d)[1]<<16 | (d)[2]<<8 | (d)[3]<<0) | ||
| 24 | #define leuint(d) (uint)((d)[3]<<24 | (d)[2]<<16 | (d)[1]<<8 | (d)[0]<<0) | ||
| 25 | |||
| 23 | extern const char *id3genres[Numgenre]; | 26 | extern const char *id3genres[Numgenre]; |
| 24 | 27 | ||
| 25 | /* | 28 | /* |
| @@ -4,8 +4,6 @@ · 3 unmodified lines | |||
| 4 | */ | 4 | */ |
| 5 | #include "tagspriv.h" | 5 | #include "tagspriv.h" |
| 6 | 6 | ||
| 7 | #define leuint(d) (uint)(((uchar*)(d))[3]<<24 | ((uchar*)(d))[2]<<16 | ((uchar*)(d))[1]<<8 | ((uchar*)(d))[0]<<0) | ||
| 8 | |||
| 9 | void | 7 | void |
| 10 | cbvorbiscomment(Tagctx *ctx, char *k, char *v){ | 8 | cbvorbiscomment(Tagctx *ctx, char *k, char *v){ |
| 11 | if(*v == 0) | 9 | if(*v == 0) |
| @@ -0,0 +1,75 @@ | |||
| 1 | #include "tagspriv.h" | ||
| 2 | |||
| 3 | #define le16u(d) (u16int)((d)[0] | (d)[1]<<8) | ||
| 4 | |||
| 5 | int | ||
| 6 | tagwav(Tagctx *ctx) | ||
| 7 | { | ||
| 8 | uchar *d; | ||
| 9 | int i; | ||
| 10 | u32int sz, csz; | ||
| 11 | |||
| 12 | d = (uchar*)ctx->buf; | ||
| 13 | |||
| 14 | sz = 1; | ||
| 15 | for(i = 0; i < 8 && sz > 0; i++){ | ||
| 16 | if(ctx->read(ctx, d, 4+4+(i?0:4)) != 4+4+(i?0:4)) | ||
| 17 | return -1; | ||
| 18 | if(i == 0){ | ||
| 19 | if(memcmp(d, "RIFF", 4) != 0 || memcmp(d+8, "WAVE", 4) != 0) | ||
| 20 | return -1; | ||
| 21 | if((sz = beuint(d+4)) < 4) | ||
| 22 | return -1; | ||
| 23 | sz -= 4; | ||
| 24 | continue; | ||
| 25 | }else if(memcmp(d, "INFO", 4) == 0){ | ||
| 26 | ctx->seek(ctx, -4, 1); | ||
| 27 | continue; | ||
| 28 | } | ||
| 29 | |||
| 30 | sz -= 4+4; | ||
| 31 | csz = leuint(d+4); | ||
| 32 | if(csz > sz) | ||
| 33 | return -1; | ||
| 34 | sz -= csz; | ||
| 35 | |||
| 36 | if(i == 1){ | ||
| 37 | if(memcmp(d, "fmt ", 4) != 0 || csz < 16) | ||
| 38 | return -1; | ||
| 39 | if(ctx->read(ctx, d, 16) != 16) | ||
| 40 | return -1; | ||
| 41 | csz -= 16; | ||
| 42 | ctx->channels = le16u(d+2); | ||
| 43 | ctx->samplerate = leuint(d+4); | ||
| 44 | ctx->duration = sz*1000 / leuint(d+8); | ||
| 45 | }else if(memcmp(d, "LIST", 4) == 0){ | ||
| 46 | sz = csz - 4; | ||
| 47 | continue; | ||
| 48 | }else if(memcmp(d, "IART", 4) == 0){ | ||
| 49 | if(ctx->read(ctx, d, csz) != csz) | ||
| 50 | return -1; | ||
| 51 | d[csz] = 0; | ||
| 52 | txtcb(ctx, Tartist, "", d); | ||
| 53 | csz = 1; | ||
| 54 | }else if(memcmp(d, "IPRD", 4) == 0){ | ||
| 55 | if(ctx->read(ctx, d, csz) != csz) | ||
| 56 | return -1; | ||
| 57 | d[csz] = 0; | ||
| 58 | txtcb(ctx, Talbum, "", d); | ||
| 59 | csz = 1; | ||
| 60 | }else if(memcmp(d, "INAM", 4) == 0){ | ||
| 61 | if(ctx->read(ctx, d, csz) != csz) | ||
| 62 | return -1; | ||
| 63 | d[csz] = 0; | ||
| 64 | txtcb(ctx, Ttitle, "", d); | ||
| 65 | csz = 1; | ||
| 66 | }else if(memcmp(d, "data", 4) == 0){ | ||
| 67 | break; | ||
| 68 | } | ||
| 69 | |||
| 70 | if(ctx->seek(ctx, csz, 1) < 0) | ||
| 71 | return -1; | ||
| 72 | } | ||
| 73 | |||
| 74 | return i > 0 ? 0 : -1; | ||
| 75 | } | ||