[Mplayer-cvslog] CVS: main/libvo vo_xv.c,1.67,1.68
Arpi of Ize
arpi at mplayer.dev.hu
Sun Apr 7 04:10:42 CEST 2002
Update of /cvsroot/mplayer/main/libvo
In directory mplayer:/var/tmp.root/cvs-serv6012
Modified Files:
vo_xv.c
Log Message:
initialization moved to preinit(), query_format now really checks for supported formats
Index: vo_xv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xv.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- vo_xv.c 3 Apr 2002 02:40:09 -0000 1.67
+++ vo_xv.c 7 Apr 2002 02:10:39 -0000 1.68
@@ -313,7 +313,6 @@
XSizeHints hint;
XVisualInfo vinfo;
XEvent xev;
- XvPortID xv_p;
XGCValues xgcv;
XSetWindowAttributes xswa;
@@ -341,9 +340,17 @@
#endif
flip_flag=flags&8;
num_buffers=vo_doublebuffering?NUM_BUFFERS:1;
-
- if (!vo_init()) return -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;
+
aspect_save_screenres(vo_screenwidth,vo_screenheight);
#ifdef HAVE_NEW_GUI
@@ -438,42 +445,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){
@@ -512,12 +483,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)
@@ -744,7 +709,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:
@@ -759,8 +734,8 @@
// umm, this is a kludge, we need to ask the server.. (see init function above)
return 1;
}
-
return 0;
+*/
}
@@ -769,20 +744,53 @@
int i;
if(!mDisplay) return;
saver_on(mDisplay); // screen saver back on
- for( i=0;i<num_buffers;i++ ) deallocate_xvimage( i );
+ if(vo_config_count) for( i=0;i<num_buffers;i++ ) deallocate_xvimage( i );
#ifdef HAVE_XF86VM
vo_vm_close(mDisplay);
#endif
- vo_x11_uninit(mDisplay, vo_window);
+ if(vo_config_count) vo_x11_uninit(mDisplay, vo_window);
}
static uint32_t preinit(const char *arg)
{
+ XvPortID xv_p;
if(arg)
{
printf("vo_xv: Unknown subdevice: %s\n",arg);
return ENOSYS;
}
+ if (!vo_init()) return -1;
+
+ xv_port = 0;
+ /* check for Xvideo extension */
+ if (Success != XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)){
+ printf("Sorry, Xv not supported by this X11 version/driver\n");
+ printf("******** Try with -vo x11 or -vo sdl *********\n");
+ return -1;
+ }
+
+ /* 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);
+ }
+ }
+ if(!xv_port){
+ printf("Couldn't find free Xvideo port - maybe other applications keep open it\n");
+ return -1;
+ }
+
return 0;
}
More information about the MPlayer-cvslog
mailing list