ref: a59ebb695f6e50298e8361fd3d40fd6cf0996ba8
dir: /frame.c/
#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; }