annotate libvo/vo_xv.c @ 182:80a7b40f201a

*** empty log message ***
author pontscho
date Wed, 21 Mar 2001 19:10:55 +0000
parents 1fc618eba830
children dd107cd7686d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
2 /*
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
3 * vo_xv.c, X11 Xv interface
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 *
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
5 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved.
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * Hacked into mpeg2dec by
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
8 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 LIBVO_EXTERN(xv)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include <X11/extensions/XShm.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
29 #include "x11_common.h"
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
30
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
31 static vo_info_t vo_info =
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
33 "X11/Xv",
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
34 "xv",
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
35 "Gerd Knorr <kraxel@goldbach.in-berlin.de>",
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
36 ""
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 /* since it doesn't seem to be defined on some platforms */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 int XShmGetEventBase(Display*);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 /* local data */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 static unsigned char *ImageData;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 /* X11 related variables */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 static Display *mydisplay;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 static Window mywindow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 static GC mygc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 static XImage *myximage;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 static int depth, bpp, mode;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 static XWindowAttributes attribs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 #include <X11/extensions/Xv.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 #include <X11/extensions/Xvlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 // FIXME: dynamically allocate this stuff
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 static void allocate_xvimage(int);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 static unsigned int ver,rel,req,ev,err;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 static unsigned int formats, adaptors,i,xv_port,xv_format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 static XvAdaptorInfo *ai;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 static XvImageFormatValues *fo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 static XvImage *xvimage[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 #include <sys/ipc.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 #include <sys/shm.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 #include <X11/extensions/XShm.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 static int Shmem_Flag;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 static int Quiet_Flag;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 static XShmSegmentInfo Shminfo[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 static int gXErrorFlag;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 static int CompletionType = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 static uint32_t image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 static uint32_t image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 static uint32_t image_format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
77 static Window mRoot;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
78 static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
79 static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
81 /*
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
82 * connect to server, create and map window,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 * allocate colors and (shared) memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 */
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
85 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
87 int screen;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
88 char *hello = (title == NULL) ? "Xv render" : title;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
89 char *name = ":0.0";
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
90 XSizeHints hint;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
91 XVisualInfo vinfo;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
92 XEvent xev;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
94 XGCValues xgcv;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
95 XSetWindowAttributes xswa;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
96 unsigned long xswamask;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
98 image_height = height;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
99 image_width = width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
100 image_format=format;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
102 mFullscreen=fullscreen;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
103 dwidth=d_width; dheight=d_height;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
105 if(getenv("DISPLAY")) name = getenv("DISPLAY");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
107 mydisplay = XOpenDisplay(name);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
109 if (mydisplay == NULL)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
110 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
111 fprintf(stderr,"Can't open display\n");
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
112 return -1;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
113 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
115 screen = DefaultScreen(mydisplay);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
117 hint.x = 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
118 hint.y = 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
119 hint.width = image_width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
120 hint.height = image_height;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
121 if ( fullscreen )
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
122 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
123 hint.width=vo_screenwidth;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
124 hint.height=vo_screenheight;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
125 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
126 hint.flags = PPosition | PSize;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
127 XGetWindowAttributes(mydisplay, DefaultRootWindow(mydisplay), &attribs);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
128 depth=attribs.depth;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
129 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
130 XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
132 xswa.background_pixel = 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
133 xswa.border_pixel = 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
134 xswamask = CWBackPixel | CWBorderPixel;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
136 mywindow = XCreateWindow(mydisplay, RootWindow(mydisplay,screen),
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
137 hint.x, hint.y, hint.width, hint.height,
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
138 0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
140 XSelectInput(mydisplay, mywindow, StructureNotifyMask | KeyPressMask );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
141 XSetStandardProperties(mydisplay, mywindow, hello, hello, None, NULL, 0, &hint);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
142 if ( fullscreen ) vo_x11_decoration( mydisplay,mywindow,0 );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
143 XMapWindow(mydisplay, mywindow);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
144 XFlush(mydisplay);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
145 XSync(mydisplay, False);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
147 mygc = XCreateGC(mydisplay, mywindow, 0L, &xgcv);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
149 xv_port = 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
150 if (Success == XvQueryExtension(mydisplay,&ver,&rel,&req,&ev,&err))
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
151 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
152 /* check for Xvideo support */
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
153 if (Success != XvQueryAdaptors(mydisplay,DefaultRootWindow(mydisplay), &adaptors,&ai))
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
154 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
155 fprintf(stderr,"Xv: XvQueryAdaptors failed");
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
156 return -1;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
157 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
158 /* check adaptors */
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
159 for (i = 0; i < adaptors; i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
160 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
161 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask) && (xv_port == 0)) xv_port = ai[i].base_id;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
162 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
163 /* check image formats */
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
164 if (xv_port != 0)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
165 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
166 fo = XvListImageFormats(mydisplay, xv_port, (int*)&formats);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
167 xv_format=0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
168 for(i = 0; i < formats; i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
169 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
170 fprintf(stderr, "Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
172 if (fo[i].id == format)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
173 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
174 xv_format = fo[i].id;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
175 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
176 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
177 if (!xv_format) xv_port = 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
178 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
179
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
180 if (xv_port != 0)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
181 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
182 fprintf( stderr,"using Xvideo port %d for hw scaling\n",xv_port );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
183
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
184 allocate_xvimage(0);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
186 XGetGeometry( mydisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
187 drwX=0; drwY=0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
188 XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
189 fprintf( stderr,"[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
191 if ( mFullscreen )
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
192 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
193 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
194 drwcX+=drwX;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
195 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
196 drwcY+=drwY;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
197 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
198 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
199 fprintf( stderr,"[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
200 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
201 return 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
202 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
203 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
205 printf("Sorry, Xv not supported by this X11 version/driver\n");
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
206 printf("******** Try with -vo x11 or -vo sdl *********\n");
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
207 return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
210 static const vo_info_t * get_info(void)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
211 { return &vo_info; }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
213 static void allocate_xvimage(int foo)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
215 /*
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
216 * allocate XvImages. FIXME: no error checking, without
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
217 * mit-shm this will bomb...
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
218 */
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
219 xvimage[foo] = XvShmCreateImage(mydisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
221 Shminfo[foo].shmid = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
222 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
223 Shminfo[foo].readOnly = False;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
225 xvimage[foo]->data = Shminfo[foo].shmaddr;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
226 XShmAttach(mydisplay, &Shminfo[foo]);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
227 XSync(mydisplay, False);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
228 shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
229 memset(xvimage[foo]->data,128,xvimage[foo]->data_size);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
230 return;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
233 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
235 int e=vo_x11_check_events(mydisplay);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
236 if(e&VO_EVENT_RESIZE)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
237 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
238 XGetGeometry( mydisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
239 drwX=0; drwY=0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
240 XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
241 fprintf( stderr,"[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
243 if ( mFullscreen )
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
244 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
245 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
246 drwcX+=drwX;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
247 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
248 drwcY+=drwY;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
249 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
250 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
251 fprintf( stderr,"[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
252 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
253 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
256 static void flip_page(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
258 check_events();
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
259 XvShmPutImage(mydisplay, xv_port, mywindow, mygc, xvimage[0],
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
260 0, 0, image_width, image_height,
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
261 drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight),
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
262 False);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
263 XFlush(mydisplay);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
264 return;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
267 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
269 uint8_t *src;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
270 uint8_t *dst;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
271 int i;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
272
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
273 dst = xvimage[0]->data + image_width * y + x;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
274 src = image[0];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
275 if(w==stride[0] && w==image_width) memcpy(dst,src,w*h);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
276 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
277 for(i=0;i<h;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
278 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
279 memcpy(dst,src,w);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
280 src+=stride[0];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
281 dst+=image_width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
282 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
283
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
284 x/=2;y/=2;w/=2;h/=2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
286 dst = xvimage[0]->data + image_width * image_height + image_width/2 * y + x;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
287 src = image[2];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
288 if(w==stride[2] && w==image_width/2) memcpy(dst,src,w*h);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
289 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
290 for(i=0;i<h;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
291 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
292 memcpy(dst,src,w);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
293 src+=stride[2];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
294 dst+=image_width/2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
295 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
296 dst = xvimage[0]->data + image_width * image_height * 5 / 4 + image_width/2 * y + x;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
297 src = image[1];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
298 if(w==stride[1] && w==image_width/2) memcpy(dst,src,w*h);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
299 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
300 for(i=0;i<h;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
301 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
302 memcpy(dst,src,w);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
303 src+=stride[1];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
304 dst+=image_width/2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
305 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
306 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
309 static uint32_t draw_frame(uint8_t *src[])
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
311 int foo;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
313 if(xv_format==IMGFMT_YUY2)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
314 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
315 // YUY2 packed, flipped
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 #if 0
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
317 int i;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
318 unsigned short *s=(unsigned short *)src[0];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
319 unsigned short *d=(unsigned short *)xvimage[0]->data;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
320 s+=image_width*image_height;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
321 for(i=0;i<image_height;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
322 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
323 s-=image_width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
324 memcpy(d,s,image_width*2);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
325 d+=image_width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
326 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 #else
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
328 memcpy(xvimage[0]->data,src[0],image_width*image_height*2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 #endif
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
330 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
331 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
332 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
333 // YV12 planar
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
334 memcpy(xvimage[0]->data,src[0],image_width*image_height);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
335 memcpy(xvimage[0]->data+image_width*image_height,src[2],image_width*image_height/4);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
336 memcpy(xvimage[0]->data+image_width*image_height*5/4,src[1],image_width*image_height/4);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
337 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
338
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
339 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
342 static uint32_t query_format(uint32_t format)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
344 switch(format)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
345 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
346 case IMGFMT_YV12:
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
347 case IMGFMT_YUY2: return 1;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
348 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
349 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
352 static void uninit(void) { }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355