ref: 21f92cf520f83cee37c3e7c8b53c13a8b0179410
parent: 920df845198f6d995ddeaab586526ab1ec3b9ccc
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Jul 14 09:48:35 EDT 2021
do not use memdraw
--- a/hj264.c
+++ b/hj264.c
@@ -5,7 +5,6 @@
#include <thread.h>
#include <bio.h>
#include <draw.h>
-#include <memdraw.h>
#include <tos.h>
void npe_nsleep(uvlong ns);
@@ -357,11 +356,10 @@
{
int nthreads, fps, kbps, denoise, quality, qp;
uvlong start, end, fstart, fend;
+ char *s, tmp[61], *f[5];
int ww, hh, in, nframes;
- Memimage *im;
Img *img;
Hj264 *h;
- char *s;
/* use NPROC-1 threads by default */
nthreads = ((s = getenv("NPROC")) != nil) ? atoi(s)-1 : 1;
@@ -405,12 +403,17 @@
fmtinstall(L'ℏ', hjerror);
- memimageinit();
- if((im = readmemimage(in)) == nil)
- sysfatal("image: %r");
- ww = Dx(im->r);
- hh = Dy(im->r);
- freememimage(im);
+ tmp[60] = 0;
+ if(readn(in, tmp, 60) != 60 || tokenize(tmp, f, 5) != 5)
+ sysfatal("invalid image");
+ if(strcmp(f[0], "x8r8g8b8") != 0)
+ 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, ww, hh)) == nil)
sysfatal("hj264new: %r");