shithub: libtags

Download patch

ref: 19f590de69c3f287c128ecd6e58e4ebf9a24a24f
parent: 3fc10ff7882bee4063ee12c03d5a5e23c172f3cc
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Mon Oct 17 19:58:24 EDT 2022

libtags: opus/vorbis: make sure to get to the last frame to have the full duration

--- a/opus.c
+++ b/opus.c
@@ -83,11 +83,12 @@
 				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;
 		}
 	}
 
--- a/vorbis.c
+++ b/vorbis.c
@@ -119,11 +119,12 @@
 				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;
 		}
 	}