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