summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>2021-09-28 01:17:10 +0000
committerSigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>2021-09-28 01:17:10 +0000
commitbd63aeb60d1c38cd04e2f64c809685814c5607d7 (patch)
tree189a393cd811bc33e3fa19bfe856ffd439ce050b /sys/src
parentdf25039bb39c180ad8fd8bdfdc105f61d16eae0e (diff)
libtags: opus: fix duration on truncated files
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/cmd/audio/libtags/opus.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/src/cmd/audio/libtags/opus.c b/sys/src/cmd/audio/libtags/opus.c
index 86c7b8249..8b0b35dff 100644
--- a/sys/src/cmd/audio/libtags/opus.c
+++ b/sys/src/cmd/audio/libtags/opus.c
@@ -8,8 +8,7 @@ tagopus(Tagctx *ctx)
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 @@ tagopus(Tagctx *ctx)
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;