ref: 75b18540c02b947cf11c3d93b730f6ab061f7a34
parent: 0a1bab10da12e537aab4b7ea9679d7dc54a559c8
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Nov 8 16:11:24 EST 2021
sync with 9front changes
--- a/mod.c
+++ b/mod.c
@@ -19,25 +19,28 @@
"10CH",
"16CN",
"32CN",
+ nil,
};
int
tagmod(Tagctx *ctx)
{
- uchar d[20+4], o[20*UTFmax+1];
+ uchar d[20], o[20*2+1];
int i;
- if(ctx->read(ctx, d, 20) != 20)
- return -1;
if(ctx->seek(ctx, 1080, 0) != 1080)
return -1;
- if(ctx->read(ctx, d+20, 4) != 4)
+ if(ctx->read(ctx, d, 4) != 4)
return -1;
- for(i = 0; i < nelem(variants); i++){
- if(memcmp(d+20, variants[i], 4) == 0)
+ for(i = 0; ; i++){
+ if(variants[i] == nil)
+ return -1;
+ if(memcmp(d, variants[i], 4) == 0)
break;
}
- if(i >= nelem(variants))
+ if(ctx->seek(ctx, 0, 0) != 0)
+ return -1;
+ if(ctx->read(ctx, d, 20) != 20)
return -1;
if(iso88591toutf8(o, sizeof(o), d, 20) > 0)
txtcb(ctx, Ttitle, "", o);
--- a/opus.c
+++ b/opus.c
@@ -8,8 +8,7 @@
int sz, numtags, i, npages;
d = (uchar*)ctx->buf;
- /* need to find vorbis frame with type=3 */
- for(npages = 0; npages < 2; npages++){ /* vorbis comment is the second header */
+ for(npages = 0; npages < 2; npages++){
int nsegs;
if(ctx->read(ctx, d, 27) != 27)
return -1;
@@ -76,7 +75,7 @@
break;
for(; v != nil && v < ctx->buf+sz;){
v = memchr(v, 'O', ctx->buf+sz - v - 14);
- if(v != nil && v[1] == 'g' && v[2] == 'g' && v[3] == 'S' && (v[5] & 4) == 4){ /* last page */
+ if(v != nil && v[1] == 'g' && v[2] == 'g' && v[3] == 'S'){
uvlong g = leuint(v+6) | (uvlong)leuint(v+10)<<32;
ctx->duration = g * 1000 / 48000; /* granule positions are always 48KHz */
return 0;
--- a/tags.c
+++ b/tags.c
@@ -69,9 +69,8 @@
for(i = 0; i < nelem(g); i++){
ctx->num = 0;
if(g[i].f(ctx) == 0){
- if(ctx->num > 0)
- res = 0;
ctx->format = g[i].format;
+ res = 0;
}
ctx->seek(ctx, 0, 0);
}
--- a/tagspriv.h
+++ b/tagspriv.h
@@ -4,6 +4,7 @@
#include <string.h>
#include <stdlib.h>
#include <strings.h>
+#include <stdint.h>
#define snprint snprintf
#define cistrcmp strcasecmp
#define cistrncmp strncasecmp
@@ -10,8 +11,10 @@
#define nil NULL
#define UTFmax 4
#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
-typedef unsigned char uchar;
-typedef unsigned long long uvlong;
+typedef uint8_t uchar;
+typedef uint16_t u16int;
+typedef uint32_t u32int;
+typedef uint64_t uvlong;
#else
#include <u.h>
#include <libc.h>
--- a/wav.c
+++ b/wav.c
@@ -1,6 +1,6 @@
#include "tagspriv.h"
-#define le16u(d) ((d)[0] | (d)[1]<<8)
+#define le16u(d) (u16int)((d)[0] | (d)[1]<<8)
static struct {
char *s;
@@ -17,10 +17,10 @@
int
tagwav(Tagctx *ctx)
{
+ uchar *d;
int i, n, info;
+ u32int csz;
uvlong sz;
- uchar *d;
- uint csz;
d = (uchar*)ctx->buf;
@@ -69,7 +69,7 @@
csz++;
for(n = 0; n < nelem(t); n++){
if(memcmp(d, t[n].s, 4) == 0){
- if((uint)ctx->read(ctx, d, csz) != csz)
+ if(ctx->read(ctx, d, csz) != csz)
return -1;
d[csz-1] = 0;
txtcb(ctx, t[n].type, "", d);