shithub: mcfs

Download patch

ref: a1fa64c53babf67c3cfcbabe0729324a40c7b4a4
parent: 015be736a83adbb73a140a536d70f97625dc5053
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Feb 5 11:58:05 EST 2021

oggpacket: allow Theora

--- a/ogg.c
+++ b/ogg.c
@@ -37,7 +37,7 @@
 	h[25] = 0;
 
 	for(ntot = ip = 0; ip < np; ip++){
-		n = 1 + (p[ip].sz > 0 ? (p[ip].sz-1)/255 : 0);
+		n = 1 + (p[ip].sz > 0 ? p[ip].sz/255 : 0);
 		if(27+ntot+n >= nelem(h)){
 			werrstr("frame is too large");
 			return -1;
@@ -44,9 +44,9 @@
 		}
 		for(i = 0, psz = p[ip].sz; i < n; i++){
 			h[27+ntot+i] = min(255, psz);
-			psz -= h[27+ntot+i];
 			if(psz == 0)
 				break;
+			psz -= h[27+ntot+i];
 		}
 		ntot += n;
 	}
@@ -91,7 +91,7 @@
 
 		/* id/codec setup header always goes first */
 		if(ctx->codec.priv.sz > 0){ /* if we have codec setup data, write it */
-			if(ctx->fmt == FmtVorbis){
+			if(ctx->fmt == FmtVorbis || ctx->fmt == FmtTheora){
 				i = *d++;
 				dsz--;
 				for(nsg = 0, total = 0; i > 0 && dsz > 0; total += sgszs[nsg], nsg++){
@@ -103,7 +103,7 @@
 					}while(*d++ == 0xff);
 				}
 				if(total > dsz){
-					werrstr("vorbis setup data out of bounds");
+					werrstr("setup data out of bounds");
 					goto err;
 				}
 				for(i = 0; i < nsg && dsz > 0; d += sgszs[i], dsz -= sgszs[i], i++){