shithub: treason

Download patch

ref: eac7952b194921bd8792d5d35675bd7a4721c8cf
parent: 079f7c650735d150aec2a00630b7958915815095
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Jan 29 20:00:48 EST 2021

install.rc: apply sane defaults and seek patches from qwx as well

--- a/decoder_h264.c
+++ b/decoder_h264.c
@@ -46,18 +46,20 @@
 {
 	int i, firstvalid;
 
-	if(a->ctx.pLastDecPicInfo->pPreviousDecodedPictureInDpb && a->ctx.pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin){
-		a->lastgopremain = a->npics;
+	if(a->npics > 0){
+		if(a->ctx.pLastDecPicInfo->pPreviousDecodedPictureInDpb && a->ctx.pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin){
+			a->lastgopremain = a->npics;
 
-		for(i = 0; i <= a->lbufpicind; i++)
-			a->pics[i].bLastGOP = a->pics[i].iPOC > IMinInt32;
-	}else{
-		for(i = 0; i <= a->lbufpicind; i++){
-			if(a->pics[i].iPOC == a->ctx.pSliceHeader->iPicOrderCntLsb){
-				a->lastgopremain = a->npics;
-				for(i = 0; i <= a->lbufpicind; i++)
-					a->pics[i].bLastGOP = a->pics[i].iPOC > IMinInt32;
-				break;
+			for(i = 0; i <= a->lbufpicind; i++)
+				a->pics[i].bLastGOP = a->pics[i].iPOC > IMinInt32;
+		}else{
+			for(i = 0; i <= a->lbufpicind; i++){
+				if(a->pics[i].iPOC == a->ctx.pSliceHeader->iPicOrderCntLsb){
+					a->lastgopremain = a->npics;
+					for(i = 0; i <= a->lbufpicind; i++)
+						a->pics[i].bLastGOP = a->pics[i].iPOC > IMinInt32;
+					break;
+				}
 			}
 		}
 	}
@@ -65,7 +67,6 @@
 	for(i = 0; i < nelem(a->pics); i++){
 		if(a->pics[i].iPOC == IMinInt32){
 			memmove(&a->pics[i].sBufferInfo, &a->info, sizeof(a->info));
-			a->pics[i].uiDecodingTimeStamp = ts;
 			a->pics[i].iPOC = a->ctx.pSliceHeader->iPicOrderCntLsb;
 			a->pics[i].iPicBuffIdx = a->ctx.pLastDecPicInfo->pPreviousDecodedPictureInDpb->iPicBuffIdx;
 			a->pics[i].uiDecodingTimeStamp = ts;
@@ -138,7 +139,7 @@
 	}
 	if(a->minpoc > IMinInt32 && ((a->lastwritten > IMinInt32 && a->minpoc - a->lastwritten <= 1) || a->minpoc < a->ctx.pSliceHeader->iPicOrderCntLsb)){
 		a->lastwritten = a->minpoc;
-		memmove(&a->info, &a->pics[a->picind].sBufferInfo, sizeof (SBufferInfo));
+		memmove(&a->info, &a->pics[a->picind].sBufferInfo, sizeof(a->info));
 		a->data[0] = a->info.pDst[0];
 		a->data[1] = a->info.pDst[1];
 		a->data[2] = a->info.pDst[2];
@@ -212,8 +213,20 @@
 	lasttimestamp = 0;
 	start = nanosec();
 	for(res = 0, framenum = 0; res >= 0 && (res = Sread(d->s, &sf)) == 0 && sf.sz > 0; framenum++){
-		fprint(2, "%d %.*H\n", framenum, MIN(32, sf.sz), sf.buf);
+		a->ctx.iErrorCode = dsErrorFree;
+		a->ctx.iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL;
+	    a->ctx.uiTimeStamp = a->info.uiInBsTimeStamp;
+		memset(&a->info, 0, sizeof(a->info));
+		memset(a->data, 0, sizeof(a->data));
+		a->ctx.bReferenceLostAtT0Flag = false;
+		a->ctx.bCurAuContainLtrMarkSeFlag = false;
+		a->ctx.iFrameNumOfAuMarkedLtr = 0;
+		a->ctx.iFrameNum = -1;
+		a->ctx.iFeedbackTidInAu = -1;
+		a->ctx.iFeedbackNalRefIdc = -1;
 		if((res = WelsDecodeBs(&a->ctx, sf.buf, sf.sz, a->data, &a->info, nil)) != 0){
+			if(a->ctx.iErrorCode & dsOutOfMemory)
+				continue;
 			werrstr("%s on frame %llud: %.*H", err2s(res), framenum, MIN(32, sf.sz), sf.buf);
 			break;
 		}
--- a/install.rc
+++ b/install.rc
@@ -49,9 +49,16 @@
 echo downloading alienpatch and building all things opus
 test -d alienpatch || { hget https://github.com/qwx9/alienpatch/archive/master.tar.gz | tar xz && \
 	mv alienpatch-master alienpatch && \
-	for(i in opus libopusenc opusfile opus-tools) { \
+	for(i in opus libopusenc opusfile opus-tools){ \
 		cd $i; \
 		ape/patch -p0 <../alienpatch/$i || echo failed; \
+		cd ..; \
+	} && \
+	cd opus-tools && ape/patch -p0 <../alienpatch/opus-tools-defaults && \
+	                 ape/patch -p0 <../alienpatch/opus-tools-seek && \
+	cd .. && \
+	for(i in opus libopusenc opusfile opus-tools){ \
+		cd $i; \
 		mk install; \
 		cd ..; \
 	}