# HG changeset patch # User arpi # Date 1018145439 0 # Node ID 1e90dd889c34159f8df69415035474a2b5504535 # Parent 53ce50ac2ce2c6d7238e298ffd8912930f7a0ce2 initialization moved to preinit(), query_format now really checks for supported formats diff -r 53ce50ac2ce2 -r 1e90dd889c34 libvo/vo_xv.c --- a/libvo/vo_xv.c Sat Apr 06 22:46:20 2002 +0000 +++ b/libvo/vo_xv.c Sun Apr 07 02:10:39 2002 +0000 @@ -314,7 +314,6 @@ XSizeHints hint; XVisualInfo vinfo; XEvent xev; - XvPortID xv_p; XGCValues xgcv; XSetWindowAttributes xswa; @@ -342,9 +341,17 @@ #endif flip_flag=flags&8; num_buffers=vo_doublebuffering?NUM_BUFFERS:1; + + /* check image formats */ + fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); + xv_format=0; + if(format==IMGFMT_BGR24) format=IMGFMT_YV12; + for(i = 0; i < formats; i++){ + printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); + if (fo[i].id == format) xv_format = fo[i].id; + } + if (!xv_format) return -1; - if (!vo_init()) return -1; - aspect_save_screenres(vo_screenwidth,vo_screenheight); #ifdef HAVE_NEW_GUI @@ -439,42 +446,6 @@ } #endif - xv_port = 0; - if (Success == XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)) - { - /* check for Xvideo support */ - if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai)) - { - printf("Xv: XvQueryAdaptors failed"); - return -1; - } - /* check adaptors */ - for (i = 0; i < adaptors && xv_port == 0; i++) - { - if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) - for (xv_p = ai[i].base_id; xv_p < ai[i].base_id+ai[i].num_ports; ++xv_p) - if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) { - xv_port = xv_p; - break; - } else { - printf("Xv: could not grab port %i\n", (int)xv_p); - } - } - /* check image formats */ - if (xv_port != 0) - { - fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); - xv_format=0; - if(format==IMGFMT_BGR24) format=IMGFMT_YV12; - for(i = 0; i < formats; i++){ - printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); - if (fo[i].id == format) xv_format = fo[i].id; - } - if (!xv_format) xv_port = 0; - } - - if (xv_port != 0) - { printf( "using Xvideo port %d for hw scaling\n",xv_port ); switch (xv_format){ @@ -513,12 +484,6 @@ } saver_off(mDisplay); // turning off screen saver return 0; - } - } - - printf("Sorry, Xv not supported by this X11 version/driver\n"); - printf("******** Try with -vo x11 or -vo sdl *********\n"); - return 1; } static const vo_info_t * get_info(void) @@ -745,7 +710,17 @@ static uint32_t query_format(uint32_t format) { + int flag=1; + /* check image formats */ + fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); + if(format==IMGFMT_BGR24){ format=IMGFMT_YV12;flag|=2;} // conversion! + for(i = 0; i < formats; i++){ +// printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); + if (fo[i].id == format) return flag; //xv_format = fo[i].id; + } + return 0; +/* switch(format){ case IMGFMT_YUY2: case IMGFMT_UYVY: @@ -760,8 +735,8 @@ // umm, this is a kludge, we need to ask the server.. (see init function above) return 1; } - return 0; +*/ } @@ -770,20 +745,53 @@ int i; if(!mDisplay) return; saver_on(mDisplay); // screen saver back on - for( i=0;i