shithub: hj264

Download patch

ref: b3f24a5c7b7b248c6cd8da6f4bd0b314b3660720
parent: 2c3bae25d0922b660786b9ba7e2a981a6d0badb8
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Aug 8 11:45:12 EDT 2021

allow non-multiple-of-16 sizes (fixes cropping too) since we're allocating frame stuff properly anyway

--- a/hj264.c
+++ b/hj264.c
@@ -155,8 +155,6 @@
 	Hj264 *h;
 
 	nthreads = clp(nthreads, 1, H264E_MAX_THREADS);
-	/* YUV logic requires alignment, allow height to be different (pad it) */
-	hh = ((hh-1) | 15) + 1;
 
 	memset(&cp, 0, sizeof(cp));
 	cp.num_layers = 1;
@@ -173,9 +171,9 @@
 		return nil;
 	}
 
-	/* FIXME not padding width yet, so it still has to be multiple of 16 */
-	/* once we do that, put this line to where "hh" is aligned */
+	/* YUV logic requires alignment */
 	ww = ((ww-1) | 15) + 1;
+	hh = ((hh-1) | 15) + 1;
 
 	szyuv = ww*hh*3/2;
 	if((h = calloc(1, sizeof(*h) + Align+szyuv + Align+szpersist + Align+szscratch)) == nil)
@@ -426,10 +424,6 @@
 		sysfatal("only x8r8g8b8 is supported");
 	ww = atoi(f[3]) - atoi(f[1]);
 	hh = atoi(f[4]) - atoi(f[2]);
-	if(ww & 15)
-		sysfatal("frame width has to be multiple of 16");
-	if(ww < 16 || hh < 16)
-		sysfatal("frame too small: %dx%d", ww, hh);
 
 	if((h = hj264new(nthreads, denoise, kbps, gop, ww, hh)) == nil)
 		sysfatal("hj264new: %r");
--- a/minih264e.h
+++ b/minih264e.h
@@ -11037,6 +11037,7 @@
     {
         return H264E_STATUS_SIZE_NOT_MULTIPLE_2; // frame size must be multiple of 2
     }
+/*
     if (((par->width | par->height) & 15) && !par->const_input_flag)
     {
         // if input buffer reused as scratch (par->const_input_flag == 0)
@@ -11043,6 +11044,7 @@
         // frame size must be multiple of 16
         return H264E_STATUS_SIZE_NOT_MULTIPLE_16;
     }
+*/
     return H264E_STATUS_SUCCESS;
 };