CVS: main/libvo2 draw.c,NONE,1.1 libvo2.h,NONE,1.1 vo_sample.c,NONE,1.1
Update of /cvsroot/mplayer/main/libvo2 In directory mplayerhq:/var/tmp.root/cvs-serv20534 Added Files: draw.c libvo2.h vo_sample.c Log Message: API design --- NEW FILE --- // draw_slice / draw_frame implementation #include "libvo2.h" static vo2_surface_t* vo2_surface=NULL; // field: 0=frame 1=top_field 2=bottom_field void draw_slice_start(int field){ // setup surface surface=vo->get_surface(0); } void draw_slice(void* img[3],int stride[3],int w,int h,int x,int y){ } void draw_frame(void* img,int stride,int w,int h){ // do it: surface=vo->get_surface(0); if(stride==w && stride==surface->stride[0]){ memcpy(surface->img[0],img,w*h); return; } // fallback: draw_slice_start(); draw_slice(&img,&stride,w,h,0,0); } --- NEW FILE --- typedef struct { int w,h; // dimension of the surface int x,y; // position of the image (for draw_frame/draw_slice) void* img[3]; // pointer to frame/planes int stride[3]; // strides (bytes per line) for frame/planes int format; // RGB / BGR / YUV_PACKED / YUV_PLANAR int bpp; // bits per pixel (15/16/24/32) or YUV fourcc } vo2_surface_t; --- NEW FILE --- #include "libvo2.h" static int current_surface=0; static vo2_surface_t surface[2]; // open hardware/lib, get capabilities // this function will be called first, before any other control() or start() calls // return: 1=success 0=failed static int init(){ return 1; } // control (get/set/query) device parameters // for example: query supported pixel formats, en/disable double buffering, // query hw/sw scaling capabilities, switch window/fullscreen, // get best matching resolution for a given image size etc... static int control(int cmd, void* param){ return -1; } // start drawing (set video mode, allocate image buffers etc.) // w,h: requested surface size (actual size may be larger!!!) // format: IMGFMT_* requested surface pixel format // buffering: 0 - single temporary frame buffer (for draw_* stuff) // 1 - single static buffer (for win32 direct rendering) // 2 - 2 static + 1 temp buffer (for mpeg direct rendering) // flags: various things, like fullscreen, sw/hw zoom and vidmode change // return: 1=success 0=fail (fail if pixel format or buffering not supported) static int start(int w,int h,int format,int buffering,int flags){ // open window / switch vidmode, set up surfaces etc... return 1; } static int stop(){ // stop rendering, close device return 1; } // get destination surface (for direct rendering or generic draw_ functions) // num: number of frame. 0 = temporary frame - can be dropped/modified // 1-2 = static frames - should not be modified // Note: mpeg will use 0,1,2 frames for B,Pf,Pb (or fallback to 0-only) // win32 will use only 0 static vo2_surface_t* get_surface(int num){ return &surface[current_surface]; } static void flip_image(int num){ // we can assume that num is valid (get_surface(num) will return non-NULL) // let's show surface[num] if(double_buffering) current_surface=current_surface^1; // swap buffers } _______________________________________________ Mplayer-cvslog mailing list Mplayer-cvslog@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
participants (1)
-
Arpi of Ize