ref: d8a3992830fe6e04942a14c279aa9faac594dce2
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; 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; }