~ft/treason

ref: c1156352ba4eceae2ec875fd06fc94c38c92271f treason/frame.c -rw-r--r-- 644 bytes
c1156352 — Sigrid Solveig Haflínudóttir info: mixed up dispdelay and yuv→rgb, fix it 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <u.h>
#include <libc.h>
#include "frame.h"

Frame *
newframe(int w, int h, u8int *yuv[3], int ystride, int uvstride)
{
	Frame *f;

	assert(w > 2 && h > 2);
	assert(ystride > 2 && uvstride > 2);
	assert(yuv[0] != nil && yuv[1] != nil && yuv[2] != nil);

	if((f = malloc(sizeof(*f) + (ystride+uvstride)*h)) == nil)
		return nil;

	f->w = w;
	f->h = h;
	f->ystride = ystride;
	f->uvstride = uvstride;
	f->yuv[0] = f->data;
	f->yuv[1] = f->yuv[0] + ystride*h;
	f->yuv[2] = f->yuv[1] + uvstride*h/2;
	memmove(f->yuv[0], yuv[0], ystride*h);
	memmove(f->yuv[1], yuv[1], uvstride*h/2);
	memmove(f->yuv[2], yuv[2], uvstride*h/2);

	return f;
}