Merge branch 'main' into seek-support
This commit is contained in:
@@ -35,6 +35,8 @@ static const char *t2s[] =
|
||||
[Ttrackpeak] = "trackpeak",
|
||||
[Tgenre] = "genre",
|
||||
[Timage] = "image",
|
||||
[Tcomposer] = "composer",
|
||||
[Tcomment] = "comment",
|
||||
};
|
||||
|
||||
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);
|
||||
if(t == Timage)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ tagid3v1(Tagctx *ctx)
|
||||
if((ctx->found & 1<<Tdate) == 0 && in[93] != 0)
|
||||
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){
|
||||
snprint((char*)out, Outsz, "%d", in[126]);
|
||||
txtcb(ctx, Ttrack, "", out);
|
||||
|
||||
@@ -31,6 +31,8 @@ v2cb(Tagctx *ctx, char *k, char *v)
|
||||
txtcb(ctx, Ttrack, k-1, v);
|
||||
else if(strcmp(k, "LEN") == 0)
|
||||
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){
|
||||
for(; v[0]; v++){
|
||||
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);
|
||||
else
|
||||
return 0;
|
||||
}else if(strcmp(k-1, "COM") == 0 || strcmp(k-1, "COMM") == 0){
|
||||
txtcb(ctx, Tcomment, k-1, v);
|
||||
}else{
|
||||
txtcb(ctx, Tunknown, k-1, v);
|
||||
}
|
||||
|
||||
+5
-1
@@ -93,6 +93,10 @@ tagm4a(Tagctx *ctx)
|
||||
type = Timage;
|
||||
else if(memcmp(d, "trkn", 4) == 0)
|
||||
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){
|
||||
if(ctx->read(ctx, d, 4) != 4)
|
||||
return -1;
|
||||
@@ -133,7 +137,7 @@ tagm4a(Tagctx *ctx)
|
||||
sz -= 4;
|
||||
snprint((char*)d, ctx->bufsz, "%d", beuint(d));
|
||||
txtcb(ctx, type, "", d);
|
||||
}else if(type == Tgenre){
|
||||
}else if(type == Tgenre && dtype != 1){
|
||||
if(ctx->read(ctx, d, 2) != 2)
|
||||
return -1;
|
||||
sz -= 2;
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ tagopus(Tagctx *ctx)
|
||||
ctx->buf[sz] = 0;
|
||||
|
||||
if((v = strchr(ctx->buf, '=')) == nil)
|
||||
continue;
|
||||
return -1;
|
||||
*v++ = 0;
|
||||
cbvorbiscomment(ctx, ctx->buf, v);
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,8 +46,8 @@ tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size,
|
||||
e = s + strlen(s);
|
||||
while(e != s && (uchar)e[-1] <= ' ')
|
||||
e--;
|
||||
if (*e != 0)
|
||||
*e = 0;
|
||||
if(*e != 0)
|
||||
*e = 0;
|
||||
}
|
||||
if(*s){
|
||||
ctx->tag(ctx, type, k, s, offset, size, f);
|
||||
|
||||
@@ -21,6 +21,8 @@ enum
|
||||
Ttrackpeak,
|
||||
Tgenre,
|
||||
Timage,
|
||||
Tcomposer,
|
||||
Tcomment,
|
||||
};
|
||||
|
||||
/* Format of the audio file. */
|
||||
|
||||
+28
-23
@@ -4,33 +4,38 @@
|
||||
*/
|
||||
#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
|
||||
cbvorbiscomment(Tagctx *ctx, char *k, char *v){
|
||||
int i;
|
||||
|
||||
if(*v == 0)
|
||||
return;
|
||||
if(cistrcmp(k, "album") == 0)
|
||||
txtcb(ctx, Talbum, k, v);
|
||||
else if(cistrcmp(k, "title") == 0)
|
||||
txtcb(ctx, Ttitle, k, v);
|
||||
else if(cistrcmp(k, "artist") == 0)
|
||||
txtcb(ctx, Tartist, k, v);
|
||||
else if(cistrcmp(k, "albumartist") == 0)
|
||||
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
|
||||
for(i = 0; i < nelem(t); i++){
|
||||
if(cistrcmp(k, t[i].s) == 0){
|
||||
txtcb(ctx, t[i].type, k, v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == nelem(t))
|
||||
txtcb(ctx, Tunknown, k, v);
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -2,7 +2,7 @@
|
||||
|
||||
#define le16u(d) (u16int)((d)[0] | (d)[1]<<8)
|
||||
|
||||
static struct {
|
||||
static const struct {
|
||||
char *s;
|
||||
int type;
|
||||
}t[] = {
|
||||
@@ -12,6 +12,8 @@ static struct {
|
||||
{"INAM", Ttitle},
|
||||
{"IPRD", Talbum},
|
||||
{"ITRK", Ttrack},
|
||||
{"ICMT", Tcomment},
|
||||
{"????", Tunknown},
|
||||
};
|
||||
|
||||
int
|
||||
@@ -26,7 +28,7 @@ tagwav(Tagctx *ctx)
|
||||
|
||||
sz = 1;
|
||||
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))
|
||||
return -1;
|
||||
if(i == 0){
|
||||
@@ -66,20 +68,20 @@ tagwav(Tagctx *ctx)
|
||||
}else if(memcmp(d, "LIST", 4) == 0){
|
||||
sz = csz - 4;
|
||||
continue;
|
||||
}else if(memcmp(d, "data", 4) == 0){
|
||||
break;
|
||||
}else if(info){
|
||||
csz++;
|
||||
}else if(info && csz < (u32int)ctx->bufsz){
|
||||
for(n = 0; n < nelem(t); n++){
|
||||
if(memcmp(d, t[n].s, 4) == 0){
|
||||
if(ctx->read(ctx, d, csz) != (int)csz)
|
||||
if(memcmp(d, t[n].s, 4) == 0 || t[n].type == Tunknown){
|
||||
if(ctx->read(ctx, d+5, csz) != (int)csz)
|
||||
return -1;
|
||||
d[csz-1] = 0;
|
||||
txtcb(ctx, t[n].type, "", d);
|
||||
d[4] = 0;
|
||||
d[5+csz] = 0;
|
||||
txtcb(ctx, t[n].type, t[n].type == Tunknown ? (char*)d : "", d+5);
|
||||
csz = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(n < nelem(t))
|
||||
continue;
|
||||
}
|
||||
|
||||
if(ctx->seek(ctx, csz, 1) < 0)
|
||||
|
||||
Reference in New Issue
Block a user