~ft/libtags

19f590de69c3f287c128ecd6e58e4ebf9a24a24f — Sigrid Solveig Haflínudóttir 1 year, 11 months ago 3fc10ff
libtags: opus/vorbis: make sure to get to the last frame to have the full duration
2 files changed, 4 insertions(+), 2 deletions(-)

M opus.c
M vorbis.c
M opus.c => opus.c +2 -1
@@ 83,11 83,12 @@ tagopus(Tagctx *ctx)
				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;
				}
				if(v != nil)
					v++;
			}
			if(ctx->duration != 0)
				break;
		}
	}


M vorbis.c => vorbis.c +2 -1
@@ 119,11 119,12 @@ tagvorbis(Tagctx *ctx)
				if(v != nil && v[1] == 'g' && v[2] == 'g' && v[3] == 'S' && (v[5] & 4) == 4){ /* last page */
					uvlong g = leuint(v+6) | (uvlong)leuint(v+10)<<32;
					ctx->duration = g * 1000 / ctx->samplerate;
					return 0;
				}
				if(v != nil)
					v++;
			}
			if(ctx->duration != 0)
				break;
		}
	}