shithub: treason

ref: 14a76c31ba5ca60d00a898f70d13c9db14d4e5d4
dir: /frame.c/

View raw version
#include <u.h>
#include <libc.h>
#include "frame.h"

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

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

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

	return f;
}