Update to latest libtags

Mostly for wav fixes
custom
jacqueline 1 year ago
parent 5866513c53
commit 403bd4672c
  1. 6
      lib/libtags/examples/readtags.c
  2. 3
      lib/libtags/id3v1.c
  3. 4
      lib/libtags/id3v2.c
  4. 6
      lib/libtags/m4a.c
  5. 2
      lib/libtags/opus.c
  6. 2
      lib/libtags/tags.c
  7. 2
      lib/libtags/tags.h
  8. 51
      lib/libtags/vorbis.c
  9. 22
      lib/libtags/wav.c

@ -35,6 +35,8 @@ static const char *t2s[] =
[Ttrackpeak] = "trackpeak", [Ttrackpeak] = "trackpeak",
[Tgenre] = "genre", [Tgenre] = "genre",
[Timage] = "image", [Timage] = "image",
[Tcomposer] = "composer",
[Tcomment] = "comment",
}; };
static void static void
@ -43,7 +45,9 @@ tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagr
USED(ctx); USED(k); USED(f); USED(ctx); USED(k); USED(f);
if(t == Timage) if(t == Timage)
print("%-12s %s %d %d\n", t2s[t], v, offset, size); print("%-12s %s %d %d\n", t2s[t], v, offset, size);
else if(t != Tunknown) else if(t == Tunknown)
print("%-12s %s\n", k, v);
else
print("%-12s %s\n", t2s[t], v); print("%-12s %s\n", t2s[t], v);
} }

@ -36,6 +36,9 @@ tagid3v1(Tagctx *ctx)
if((ctx->found & 1<<Tdate) == 0 && in[93] != 0) if((ctx->found & 1<<Tdate) == 0 && in[93] != 0)
txtcb(ctx, Tdate, "", &in[93]); txtcb(ctx, Tdate, "", &in[93]);
if((ctx->found & 1<<Tcomment) == 0 && in[97] != 0)
txtcb(ctx, Tcomment, "", &in[97]);
if((ctx->found & 1<<Ttrack) == 0 && in[125] == 0 && in[126] > 0){ if((ctx->found & 1<<Ttrack) == 0 && in[125] == 0 && in[126] > 0){
snprint((char*)out, Outsz, "%d", in[126]); snprint((char*)out, Outsz, "%d", in[126]);
txtcb(ctx, Ttrack, "", out); txtcb(ctx, Ttrack, "", out);

@ -31,6 +31,8 @@ v2cb(Tagctx *ctx, char *k, char *v)
txtcb(ctx, Ttrack, k-1, v); txtcb(ctx, Ttrack, k-1, v);
else if(strcmp(k, "LEN") == 0) else if(strcmp(k, "LEN") == 0)
ctx->duration = atoi(v); ctx->duration = atoi(v);
else if(strcmp(k, "CM") == 0 || strcmp(k, "COM") == 0)
txtcb(ctx, Tcomposer, k-1, v);
else if(strcmp(k, "CO") == 0 || strcmp(k, "CON") == 0){ else if(strcmp(k, "CO") == 0 || strcmp(k, "CON") == 0){
for(; v[0]; v++){ for(; v[0]; v++){
if(v[0] == '(' && v[1] <= '9' && v[1] >= '0'){ if(v[0] == '(' && v[1] <= '9' && v[1] >= '0'){
@ -64,6 +66,8 @@ v2cb(Tagctx *ctx, char *k, char *v)
txtcb(ctx, type, k-1, v+5); txtcb(ctx, type, k-1, v+5);
else else
return 0; return 0;
}else if(strcmp(k-1, "COM") == 0 || strcmp(k-1, "COMM") == 0){
txtcb(ctx, Tcomment, k-1, v);
}else{ }else{
txtcb(ctx, Tunknown, k-1, v); txtcb(ctx, Tunknown, k-1, v);
} }

@ -93,6 +93,10 @@ tagm4a(Tagctx *ctx)
type = Timage; type = Timage;
else if(memcmp(d, "trkn", 4) == 0) else if(memcmp(d, "trkn", 4) == 0)
type = Ttrack; type = Ttrack;
else if(memcmp(d, "\251wrt", 4) == 0)
type = Tcomposer;
else if(memcmp(d, "\251cmt", 4) == 0)
type = Tcomment;
else if(memcmp(d, "mdhd", 4) == 0){ else if(memcmp(d, "mdhd", 4) == 0){
if(ctx->read(ctx, d, 4) != 4) if(ctx->read(ctx, d, 4) != 4)
return -1; return -1;
@ -133,7 +137,7 @@ tagm4a(Tagctx *ctx)
sz -= 4; sz -= 4;
snprint((char*)d, ctx->bufsz, "%d", beuint(d)); snprint((char*)d, ctx->bufsz, "%d", beuint(d));
txtcb(ctx, type, "", d); txtcb(ctx, type, "", d);
}else if(type == Tgenre){ }else if(type == Tgenre && dtype != 1){
if(ctx->read(ctx, d, 2) != 2) if(ctx->read(ctx, d, 2) != 2)
return -1; return -1;
sz -= 2; sz -= 2;

@ -63,7 +63,7 @@ tagopus(Tagctx *ctx)
ctx->buf[sz] = 0; ctx->buf[sz] = 0;
if((v = strchr(ctx->buf, '=')) == nil) if((v = strchr(ctx->buf, '=')) == nil)
continue; return -1;
*v++ = 0; *v++ = 0;
cbvorbiscomment(ctx, ctx->buf, v); cbvorbiscomment(ctx, ctx->buf, v);
} }

@ -46,7 +46,7 @@ tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size,
e = s + strlen(s); e = s + strlen(s);
while(e != s && (uchar)e[-1] <= ' ') while(e != s && (uchar)e[-1] <= ' ')
e--; e--;
if (*e != 0) if(*e != 0)
*e = 0; *e = 0;
} }
if(*s){ if(*s){

@ -21,6 +21,8 @@ enum
Ttrackpeak, Ttrackpeak,
Tgenre, Tgenre,
Timage, Timage,
Tcomposer,
Tcomment,
}; };
/* Format of the audio file. */ /* Format of the audio file. */

@ -4,33 +4,38 @@
*/ */
#include "tagspriv.h" #include "tagspriv.h"
static const struct {
char *s;
int type;
}t[] = {
{"album", Talbum},
{"title", Ttitle},
{"artist", Tartist},
{"albumartist", Talbumartist},
{"tracknumber", Ttrack},
{"date", Tdate},
{"replaygain_track_peak", Ttrackpeak},
{"replaygain_track_gain", Ttrackgain},
{"replaygain_album_peak", Talbumpeak},
{"replaygain_album_gain", Talbumgain},
{"genre", Tgenre},
{"composer", Tcomposer},
{"comment", Tcomment},
};
void void
cbvorbiscomment(Tagctx *ctx, char *k, char *v){ cbvorbiscomment(Tagctx *ctx, char *k, char *v){
int i;
if(*v == 0) if(*v == 0)
return; return;
if(cistrcmp(k, "album") == 0) for(i = 0; i < nelem(t); i++){
txtcb(ctx, Talbum, k, v); if(cistrcmp(k, t[i].s) == 0){
else if(cistrcmp(k, "title") == 0) txtcb(ctx, t[i].type, k, v);
txtcb(ctx, Ttitle, k, v); break;
else if(cistrcmp(k, "artist") == 0) }
txtcb(ctx, Tartist, k, v); }
else if(cistrcmp(k, "albumartist") == 0) if(i == nelem(t))
txtcb(ctx, Talbumartist, k, v);
else if(cistrcmp(k, "tracknumber") == 0)
txtcb(ctx, Ttrack, k, v);
else if(cistrcmp(k, "date") == 0)
txtcb(ctx, Tdate, k, v);
else if(cistrcmp(k, "replaygain_track_peak") == 0)
txtcb(ctx, Ttrackpeak, k, v);
else if(cistrcmp(k, "replaygain_track_gain") == 0)
txtcb(ctx, Ttrackgain, k, v);
else if(cistrcmp(k, "replaygain_album_peak") == 0)
txtcb(ctx, Talbumpeak, k, v);
else if(cistrcmp(k, "replaygain_album_gain") == 0)
txtcb(ctx, Talbumgain, k, v);
else if(cistrcmp(k, "genre") == 0)
txtcb(ctx, Tgenre, k, v);
else
txtcb(ctx, Tunknown, k, v); txtcb(ctx, Tunknown, k, v);
} }

@ -2,7 +2,7 @@
#define le16u(d) (u16int)((d)[0] | (d)[1]<<8) #define le16u(d) (u16int)((d)[0] | (d)[1]<<8)
static struct { static const struct {
char *s; char *s;
int type; int type;
}t[] = { }t[] = {
@ -12,6 +12,8 @@ static struct {
{"INAM", Ttitle}, {"INAM", Ttitle},
{"IPRD", Talbum}, {"IPRD", Talbum},
{"ITRK", Ttrack}, {"ITRK", Ttrack},
{"ICMT", Tcomment},
{"????", Tunknown},
}; };
int int
@ -26,7 +28,7 @@ tagwav(Tagctx *ctx)
sz = 1; sz = 1;
info = 0; info = 0;
for(i = 0; i < 8 && sz > 0; i++){ for(i = 0; sz > 0; i++){
if(ctx->read(ctx, d, 4+4+(i?0:4)) != 4+4+(i?0:4)) if(ctx->read(ctx, d, 4+4+(i?0:4)) != 4+4+(i?0:4))
return -1; return -1;
if(i == 0){ if(i == 0){
@ -66,20 +68,20 @@ tagwav(Tagctx *ctx)
}else if(memcmp(d, "LIST", 4) == 0){ }else if(memcmp(d, "LIST", 4) == 0){
sz = csz - 4; sz = csz - 4;
continue; continue;
}else if(memcmp(d, "data", 4) == 0){ }else if(info && csz < (u32int)ctx->bufsz){
break;
}else if(info){
csz++;
for(n = 0; n < nelem(t); n++){ for(n = 0; n < nelem(t); n++){
if(memcmp(d, t[n].s, 4) == 0){ if(memcmp(d, t[n].s, 4) == 0 || t[n].type == Tunknown){
if(ctx->read(ctx, d, csz) != (int)csz) if(ctx->read(ctx, d+5, csz) != (int)csz)
return -1; return -1;
d[csz-1] = 0; d[4] = 0;
txtcb(ctx, t[n].type, "", d); d[5+csz] = 0;
txtcb(ctx, t[n].type, t[n].type == Tunknown ? (char*)d : "", d+5);
csz = 0; csz = 0;
break; break;
} }
} }
if(n < nelem(t))
continue;
} }
if(ctx->seek(ctx, csz, 1) < 0) if(ctx->seek(ctx, csz, 1) < 0)

Loading…
Cancel
Save