annotate libvo/vo_xv.c @ 324:720c640332c8

Szebb es jobb screensaver-kikapcsolo resz xmga, xv, x11 support (sdl comming soon)
author laaz
date Tue, 10 Apr 2001 00:00:04 +0000
parents 4e69a8e2700a
children f6b5c2dbc88e
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 }
322
4e69a8e2700a Screensaver and monitor powersafe function is switched off when playing a
laaz
parents: 249
diff changeset
201
324
720c640332c8 Szebb es jobb screensaver-kikapcsolo resz
laaz
parents: 322
diff changeset
202 saver_off(mydisplay); // turning off screen saver
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
203 return 0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
204 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
205 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
207 printf("Sorry, Xv not supported by this X11 version/driver\n");
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
208 printf("******** Try with -vo x11 or -vo sdl *********\n");
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
209 return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
212 static const vo_info_t * get_info(void)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
213 { return &vo_info; }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
215 static void allocate_xvimage(int foo)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
217 /*
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
218 * allocate XvImages. FIXME: no error checking, without
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
219 * mit-shm this will bomb...
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
220 */
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
221 xvimage[foo] = XvShmCreateImage(mydisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
223 Shminfo[foo].shmid = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
224 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
225 Shminfo[foo].readOnly = False;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
227 xvimage[foo]->data = Shminfo[foo].shmaddr;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
228 XShmAttach(mydisplay, &Shminfo[foo]);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
229 XSync(mydisplay, False);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
230 shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
231 memset(xvimage[foo]->data,128,xvimage[foo]->data_size);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
232 return;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
235 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
237 int e=vo_x11_check_events(mydisplay);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
238 if(e&VO_EVENT_RESIZE)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
239 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
240 XGetGeometry( mydisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
241 drwX=0; drwY=0;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
242 XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
243 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
244
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
245 if ( mFullscreen )
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
246 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
247 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
248 drwcX+=drwX;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
249 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
250 drwcY+=drwY;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
251 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
252 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
253 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
254 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
255 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257
247
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
258
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
259 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
260 int x,y;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
261
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
262 if (xv_format==IMGFMT_YV12){
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
263
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
264 for(y=0;y<h;y++){
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
265 uint8_t *dst = xvimage[0]->data + image_width * (y+y0) + x0;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
266 for(x=0;x<w;x++){
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
267 // dst[x]=(dst[x]*srca[x]+src[x]*(srca[x]^255))>>8;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
268 if(srca[x])
249
2dadc379a934 OSD/SUB image quality & speed improvement
arpi_esp
parents: 247
diff changeset
269 // dst[x]=(dst[x]*(srca[x]^255)+src[x]*(srca[x]))>>8;
2dadc379a934 OSD/SUB image quality & speed improvement
arpi_esp
parents: 247
diff changeset
270 dst[x]=((dst[x]*srca[x])>>8)+src[x];
247
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
271 }
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
272 src+=stride;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
273 srca+=stride;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
274 }
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
275
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
276 } else {
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
277
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
278 for(y=0;y<h;y++){
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
279 uint8_t *dst = xvimage[0]->data + 2*(image_width * (y+y0) + x0);
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
280 for(x=0;x<w;x++){
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
281 // dst[x]=(dst[x]*srca[x]+src[x]*(srca[x]^255))>>8;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
282 if(srca[x])
249
2dadc379a934 OSD/SUB image quality & speed improvement
arpi_esp
parents: 247
diff changeset
283 // dst[2*x]=(dst[2*x]*(srca[x]^255)+src[x]*(srca[x]))>>8;
2dadc379a934 OSD/SUB image quality & speed improvement
arpi_esp
parents: 247
diff changeset
284 dst[2*x]=((dst[2*x]*srca[x])>>8)+src[x];
247
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
285 }
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
286 src+=stride;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
287 srca+=stride;
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
288 }
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
289
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
290 }
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
291
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
292 }
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
293
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
294 static void flip_page(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 {
247
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
296 vo_draw_text(image_width,image_height,draw_alpha);
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
297 check_events();
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
298 XvShmPutImage(mydisplay, xv_port, mywindow, mygc, xvimage[0],
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
299 0, 0, image_width, image_height,
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
300 drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight),
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
301 False);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
302 XFlush(mydisplay);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
303 return;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305
247
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
306
dd107cd7686d OSD/SUB support
arpi_esp
parents: 182
diff changeset
307
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
308 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
309 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
310 uint8_t *src;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
311 uint8_t *dst;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
312 int i;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
313
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
314 dst = xvimage[0]->data + image_width * y + x;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
315 src = image[0];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
316 if(w==stride[0] && w==image_width) memcpy(dst,src,w*h);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
317 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
318 for(i=0;i<h;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
319 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
320 memcpy(dst,src,w);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
321 src+=stride[0];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
322 dst+=image_width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
323 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
324
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
325 x/=2;y/=2;w/=2;h/=2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
327 dst = xvimage[0]->data + image_width * image_height + image_width/2 * y + x;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
328 src = image[2];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
329 if(w==stride[2] && w==image_width/2) memcpy(dst,src,w*h);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
330 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
331 for(i=0;i<h;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
332 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
333 memcpy(dst,src,w);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
334 src+=stride[2];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
335 dst+=image_width/2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
336 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
337 dst = xvimage[0]->data + image_width * image_height * 5 / 4 + image_width/2 * y + x;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
338 src = image[1];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
339 if(w==stride[1] && w==image_width/2) memcpy(dst,src,w*h);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
340 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
341 for(i=0;i<h;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
342 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
343 memcpy(dst,src,w);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
344 src+=stride[1];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
345 dst+=image_width/2;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
346 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
347 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
350 static uint32_t draw_frame(uint8_t *src[])
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
352 int foo;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
354 if(xv_format==IMGFMT_YUY2)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
355 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
356 // YUY2 packed, flipped
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 #if 0
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
358 int i;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
359 unsigned short *s=(unsigned short *)src[0];
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
360 unsigned short *d=(unsigned short *)xvimage[0]->data;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
361 s+=image_width*image_height;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
362 for(i=0;i<image_height;i++)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
363 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
364 s-=image_width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
365 memcpy(d,s,image_width*2);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
366 d+=image_width;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
367 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 #else
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
369 memcpy(xvimage[0]->data,src[0],image_width*image_height*2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 #endif
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
371 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
372 else
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
373 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
374 // YV12 planar
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
375 memcpy(xvimage[0]->data,src[0],image_width*image_height);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
376 memcpy(xvimage[0]->data+image_width*image_height,src[2],image_width*image_height/4);
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
377 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
378 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
379
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
380 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
383 static uint32_t query_format(uint32_t format)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 {
182
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
385 switch(format)
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
386 {
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
387 case IMGFMT_YV12:
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
388 case IMGFMT_YUY2: return 1;
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
389 }
80a7b40f201a *** empty log message ***
pontscho
parents: 31
diff changeset
390 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392
322
4e69a8e2700a Screensaver and monitor powersafe function is switched off when playing a
laaz
parents: 249
diff changeset
393 static void uninit(void) {
324
720c640332c8 Szebb es jobb screensaver-kikapcsolo resz
laaz
parents: 322
diff changeset
394 saver_on(mydisplay); // screen saver back on
322
4e69a8e2700a Screensaver and monitor powersafe function is switched off when playing a
laaz
parents: 249
diff changeset
395 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398