ref: d5d560ff367f111e0fd62664e9473643d2afbaff
dir: /src/av19.c/
#include "dav1d.h" #include "tools/input/input.h" #include <draw.h> #include <memdraw.h> #include <keyboard.h> int mainstacksize = 512*1024; static uchar *buf; static int nfr; static int dav1d_loadimage(Image **oim, Dav1dPicture *p) { Image *im; int w, h; w = p->p.w; h = p->p.h; if(*oim == nil){ *oim = allocimage(display, Rect(0,0,w,h), RGB24, 0, 0); buf = malloc(w * h * 3); } im = *oim; /* FIXME convert YUV → RGB24 */ USED(im); return 0; } static int info(void *, char *) { print("frames: %d\n", nfr); return 0; } void threadmain(int argc, char **argv) { Dav1dSettings av1s; Dav1dContext *c; Dav1dPicture *p; Dav1dData data; DemuxerContext *dc; unsigned fps[2], timebase[2], total; int res; if(argc != 2) sysfatal("usage"); if(input_open(&dc, "ivf", argv[1], fps, &total, timebase) < 0) sysfatal("input_open"); if(input_read(dc, &data) < 0) sysfatal("input_read"); dav1d_default_settings(&av1s); av1s.n_frame_threads = 1; // FIXME threads av1s.n_tile_threads = 1; // FIXME threads if(dav1d_open(&c, &av1s) != 0) sysfatal("dav1d_open"); threadnotify(info, 1); nfr = 0; do{ res = dav1d_send_data(c, &data); if(res < 0 && res != DAV1D_ERR(EAGAIN)) sysfatal("dav1d_send_data: %d", res); else{ p = calloc(1, sizeof(*p)); if((res = dav1d_get_picture(c, p)) < 0){ if(res != DAV1D_ERR(EAGAIN)) sysfatal("dav1d_get_picture"); }else{ dav1d_picture_unref(p); free(p); nfr++; } } }while(data.sz > 0 || input_read(dc, &data) == 0); if(data.sz > 0) dav1d_data_unref(&data); /* get more pics here? */ threadexitsall(nil); }