Mercurial > mplayer.hg
annotate libvo/vo_xv.c @ 4302:9f12fd5f47d0
Modified the cache option value setting/reading, so we can report
in any case the cache size value used.
author | bertrand |
---|---|
date | Tue, 22 Jan 2002 06:12:18 +0000 |
parents | a20c333d6c09 |
children | c494cc258eb8 |
rev | line source |
---|---|
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
1 |
1265 | 2 // Number of buffers _FOR_DOUBLEBUFFERING_MODE_ |
3 // Use option -double to enable double buffering! (default: single buffer) | |
4 #define NUM_BUFFERS 2 | |
1 | 5 |
182 | 6 /* |
7 * vo_xv.c, X11 Xv interface | |
1 | 8 * |
182 | 9 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. |
1 | 10 * |
11 * Hacked into mpeg2dec by | |
182 | 12 * |
1 | 13 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
14 * | |
15 * Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de> | |
1265 | 16 * fullscreen support by Pontscho |
17 * double buffering support by A'rpi | |
1 | 18 */ |
19 | |
20 #include <stdio.h> | |
21 #include <stdlib.h> | |
22 #include <string.h> | |
23 | |
24 #include "config.h" | |
25 #include "video_out.h" | |
26 #include "video_out_internal.h" | |
27 | |
28 LIBVO_EXTERN(xv) | |
29 | |
30 #include <X11/Xlib.h> | |
31 #include <X11/Xutil.h> | |
32 #include <X11/extensions/XShm.h> | |
33 #include <errno.h> | |
34 | |
31 | 35 #include "x11_common.h" |
36 | |
354 | 37 #include "fastmemcpy.h" |
616 | 38 #include "sub.h" |
2054 | 39 #include "aspect.h" |
350 | 40 |
182 | 41 static vo_info_t vo_info = |
1 | 42 { |
182 | 43 "X11/Xv", |
44 "xv", | |
45 "Gerd Knorr <kraxel@goldbach.in-berlin.de>", | |
46 "" | |
1 | 47 }; |
48 | |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
49 extern int verbose; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
50 |
1 | 51 /* since it doesn't seem to be defined on some platforms */ |
52 int XShmGetEventBase(Display*); | |
53 | |
54 /* local data */ | |
55 static unsigned char *ImageData; | |
56 | |
57 /* X11 related variables */ | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
58 //static Display *mydisplay; |
1 | 59 static Window mywindow; |
60 static GC mygc; | |
61 static XImage *myximage; | |
62 static int depth, bpp, mode; | |
63 static XWindowAttributes attribs; | |
64 | |
65 #include <X11/extensions/Xv.h> | |
66 #include <X11/extensions/Xvlib.h> | |
67 // FIXME: dynamically allocate this stuff | |
68 static void allocate_xvimage(int); | |
69 static unsigned int ver,rel,req,ev,err; | |
70 static unsigned int formats, adaptors,i,xv_port,xv_format; | |
71 static XvAdaptorInfo *ai; | |
72 static XvImageFormatValues *fo; | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
73 |
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
74 static int current_buf=0; |
1265 | 75 static int num_buffers=1; // default |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
76 static XvImage* xvimage[NUM_BUFFERS]; |
1 | 77 |
78 #include <sys/ipc.h> | |
79 #include <sys/shm.h> | |
80 #include <X11/extensions/XShm.h> | |
81 | |
82 static int Shmem_Flag; | |
83 static int Quiet_Flag; | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
84 static XShmSegmentInfo Shminfo[NUM_BUFFERS]; |
1 | 85 static int gXErrorFlag; |
86 static int CompletionType = -1; | |
87 | |
88 static uint32_t image_width; | |
89 static uint32_t image_height; | |
90 static uint32_t image_format; | |
91 | |
182 | 92 static Window mRoot; |
93 static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; | |
94 static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen; | |
1 | 95 |
1775 | 96 #ifdef HAVE_NEW_GUI |
723 | 97 static uint32_t mdwidth,mdheight; |
98 #endif | |
99 | |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
100 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
101 |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
102 static void draw_alpha_yv12(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
103 vo_draw_alpha_yv12(w,h,src,srca,stride,xvimage[current_buf]->data+image_width*y0+x0,image_width); |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
104 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
105 |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
106 static void draw_alpha_yuy2(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
107 vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[current_buf]->data+2*(image_width*y0+x0),2*image_width); |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
108 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
109 |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
110 static void draw_alpha_uyvy(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
111 vo_draw_alpha_yuy2(w,h,src,srca,stride,xvimage[current_buf]->data+2*(image_width*y0+x0)+1,2*image_width); |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
112 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
113 |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
114 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
115 } |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
116 |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
117 extern int vo_gamma_brightness; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
118 extern int vo_gamma_saturation; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
119 extern int vo_gamma_contrast; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
120 extern int vo_gamma_hue; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
121 extern int vo_gamma_red_intense; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
122 extern int vo_gamma_green_intense; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
123 extern int vo_gamma_blue_intense; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
124 |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
125 static void set_gamma_correction( unsigned int xv_port ) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
126 { |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
127 XvAttribute *attributes; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
128 int howmany; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
129 // get available attributes |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
130 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
131 for (i = 0; i < howmany && attributes; i++) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
132 { |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
133 if (attributes[i].flags & XvSettable) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
134 { |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
135 int xv_min,xv_max,xv_atomka; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
136 xv_min = attributes[i].min_value; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
137 xv_max = attributes[i].max_value; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
138 xv_atomka = XInternAtom(mDisplay, attributes[i].name, True); |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
139 // since we have SET_DEFAULTS first in our list, we can check if it's available |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
140 // then trigger it if it's ok so that the other values are at default upon query |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
141 if (xv_atomka != None) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
142 { |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
143 int port_value,port_min,port_max,port_mid; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
144 if(strcmp(attributes[i].name,"XV_BRIGHTNESS") == 0) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
145 port_value = vo_gamma_brightness; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
146 else |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
147 if(strcmp(attributes[i].name,"XV_SATURATION") == 0) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
148 port_value = vo_gamma_saturation; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
149 else |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
150 if(strcmp(attributes[i].name,"XV_CONTRAST") == 0) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
151 port_value = vo_gamma_contrast; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
152 else |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
153 if(strcmp(attributes[i].name,"XV_HUE") == 0) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
154 port_value = vo_gamma_hue; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
155 else continue; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
156 port_min = xv_min; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
157 port_max = xv_max; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
158 port_mid = (port_min + port_max) / 2; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
159 port_value = port_mid + (port_value * (port_max - port_min)) / 2000; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
160 if(verbose > 1) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
161 printf("vo_xv: set gamma %s to %i (min %i max %i mid %i)\n",attributes[i].name,port_value,port_min,port_max,port_mid); |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
162 XvSetPortAttribute(mDisplay, xv_port, xv_atomka, port_value); |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
163 } |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
164 } |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
165 } |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
166 } |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
167 |
182 | 168 /* |
169 * connect to server, create and map window, | |
1 | 170 * allocate colors and (shared) memory |
171 */ | |
844 | 172 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
1 | 173 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
174 // int screen; |
182 | 175 char *hello = (title == NULL) ? "Xv render" : title; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
176 // char *name = ":0.0"; |
182 | 177 XSizeHints hint; |
178 XVisualInfo vinfo; | |
179 XEvent xev; | |
1186
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
180 XvPortID xv_p; |
1 | 181 |
182 | 182 XGCValues xgcv; |
183 XSetWindowAttributes xswa; | |
184 unsigned long xswamask; | |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
185 XvAttribute *attributes; |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
186 int howmany, j, notyetset = 0; |
1 | 187 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
188 aspect_save_orig(width,height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
189 aspect_save_prescale(d_width,d_height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
190 |
182 | 191 image_height = height; |
192 image_width = width; | |
193 image_format=format; | |
1 | 194 |
1775 | 195 #ifdef HAVE_NEW_GUI |
196 mdwidth=width; | |
197 mdheight=height; | |
198 #endif | |
199 | |
844 | 200 mFullscreen=flags&1; |
1265 | 201 num_buffers=vo_doublebuffering?NUM_BUFFERS:1; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
202 |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
203 if (!vo_init()) return -1; |
1 | 204 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
205 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
206 |
1775 | 207 #ifdef HAVE_NEW_GUI |
723 | 208 if ( vo_window == None ) |
182 | 209 { |
723 | 210 #endif |
211 hint.x = 0; | |
212 hint.y = 0; | |
213 hint.width = d_width; | |
214 hint.height = d_height; | |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
215 aspect(&d_width,&d_height,A_NOZOOM); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
216 |
844 | 217 if ( mFullscreen ) |
723 | 218 { |
219 hint.width=vo_screenwidth; | |
220 hint.height=vo_screenheight; | |
2054 | 221 #ifdef X11_FULLSCREEN |
2031
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
222 /* this code replaces X11_FULLSCREEN hack in mplayer.c |
2054 | 223 * aspect() is available through aspect.h for all vos. |
2031
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
224 * besides zooming should only be done with -zoom, |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
225 * but I leave the old -fs behaviour so users don't get |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
226 * irritated for now (and send lots o' mails ;) ::atmos |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
227 */ |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
228 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
229 aspect(&d_width,&d_height,A_ZOOM); |
2031
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
230 #endif |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
231 |
723 | 232 } |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2055
diff
changeset
|
233 dwidth=d_width; dheight=d_height; //XXX: what are the copy vars used for? |
723 | 234 hint.flags = PPosition | PSize; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
235 XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs); |
723 | 236 depth=attribs.depth; |
237 if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24; | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
238 XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); |
723 | 239 |
240 xswa.background_pixel = 0; | |
241 xswa.border_pixel = 0; | |
242 xswamask = CWBackPixel | CWBorderPixel; | |
1 | 243 |
3830 | 244 if ( WinID>=0 ){ |
245 mywindow = WinID ? ((Window)WinID) : RootWindow(mDisplay,mScreen); | |
246 XUnmapWindow( mDisplay,mywindow ); | |
247 XChangeWindowAttributes( mDisplay,mywindow,xswamask,&xswa ); | |
248 } else | |
249 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
250 mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen), |
3830 | 251 hint.x, hint.y, hint.width, hint.height, |
252 0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa); | |
253 | |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
922
diff
changeset
|
254 vo_x11_classhint( mDisplay,mywindow,"xv" ); |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
255 vo_hidecursor(mDisplay,mywindow); |
1 | 256 |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
257 XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask ); |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
258 XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint); |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
259 if ( mFullscreen ) vo_x11_decoration( mDisplay,mywindow,0 ); |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
260 XMapWindow(mDisplay, mywindow); |
3990 | 261 #ifdef HAVE_XINERAMA |
262 vo_x11_xinerama_move(mDisplay,mywindow); | |
263 #endif | |
1775 | 264 mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv); |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
265 XFlush(mDisplay); |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
266 XSync(mDisplay, False); |
1775 | 267 #ifdef HAVE_NEW_GUI |
723 | 268 } |
269 else | |
270 { | |
271 mywindow=vo_window; | |
272 mygc=vo_gc; | |
273 } | |
274 #endif | |
1 | 275 |
182 | 276 xv_port = 0; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
277 if (Success == XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)) |
182 | 278 { |
279 /* check for Xvideo support */ | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
280 if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai)) |
182 | 281 { |
614 | 282 printf("Xv: XvQueryAdaptors failed"); |
182 | 283 return -1; |
284 } | |
285 /* check adaptors */ | |
1186
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
286 for (i = 0; i < adaptors && xv_port == 0; i++) |
182 | 287 { |
1186
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
288 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
289 for (xv_p = ai[i].base_id; xv_p < ai[i].base_id+ai[i].num_ports; ++xv_p) |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
290 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) { |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
291 xv_port = xv_p; |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
292 break; |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
293 } else { |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
294 printf("Xv: could not grab port %i\n", (int)xv_p); |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
295 } |
182 | 296 } |
297 /* check image formats */ | |
298 if (xv_port != 0) | |
299 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
300 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); |
182 | 301 xv_format=0; |
302 for(i = 0; i < formats; i++) | |
303 { | |
614 | 304 printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); |
1 | 305 |
182 | 306 if (fo[i].id == format) |
307 { | |
308 xv_format = fo[i].id; | |
309 } | |
310 } | |
311 if (!xv_format) xv_port = 0; | |
312 } | |
313 | |
314 if (xv_port != 0) | |
315 { | |
614 | 316 printf( "using Xvideo port %d for hw scaling\n",xv_port ); |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
317 |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
318 switch (xv_format){ |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
319 case IMGFMT_YV12: |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
320 case IMGFMT_I420: |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
321 case IMGFMT_IYUV: draw_alpha_fnc=draw_alpha_yv12; break; |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
322 case IMGFMT_YUY2: |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
323 case IMGFMT_YVYU: draw_alpha_fnc=draw_alpha_yuy2; break; |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
324 case IMGFMT_UYVY: draw_alpha_fnc=draw_alpha_uyvy; break; |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
325 default: draw_alpha_fnc=draw_alpha_null; |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
326 } |
182 | 327 |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
328 for(current_buf=0;current_buf<num_buffers;++current_buf) |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
329 allocate_xvimage(current_buf); |
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
330 |
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
331 current_buf=0; |
1 | 332 |
1818 | 333 #ifdef HAVE_NEW_GUI |
334 if ( vo_window != None ) | |
335 { | |
336 mFullscreen=0; | |
337 dwidth=mdwidth; dheight=mdheight; | |
338 if ( ( vo_dwidth == vo_screenwidth )&&( vo_dheight == vo_screenheight ) ) | |
339 { | |
340 mFullscreen=1; | |
341 dwidth=vo_screenwidth; | |
342 dheight=vo_screenwidth * mdheight / mdwidth; | |
343 } | |
344 } | |
345 #endif | |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
346 set_gamma_correction(xv_port); |
1818 | 347 |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
348 XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); |
182 | 349 drwX=0; drwY=0; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
350 XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); |
614 | 351 printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
1 | 352 |
3558 | 353 aspect(&dwidth,&dheight,A_NOZOOM); |
182 | 354 if ( mFullscreen ) |
355 { | |
3558 | 356 aspect(&dwidth,&dheight,A_ZOOM); |
2055
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2054
diff
changeset
|
357 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; |
182 | 358 drwcX+=drwX; |
2055
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2054
diff
changeset
|
359 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; |
182 | 360 drwcY+=drwY; |
2055
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2054
diff
changeset
|
361 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); |
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2054
diff
changeset
|
362 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); |
614 | 363 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
182 | 364 } |
1794 | 365 #ifdef HAVE_NEW_GUI |
366 if ( vo_window == None ) | |
367 #endif | |
1818 | 368 saver_off(mDisplay); // turning off screen saver |
182 | 369 return 0; |
370 } | |
371 } | |
1 | 372 |
182 | 373 printf("Sorry, Xv not supported by this X11 version/driver\n"); |
374 printf("******** Try with -vo x11 or -vo sdl *********\n"); | |
375 return 1; | |
1 | 376 } |
377 | |
182 | 378 static const vo_info_t * get_info(void) |
379 { return &vo_info; } | |
1 | 380 |
182 | 381 static void allocate_xvimage(int foo) |
1 | 382 { |
182 | 383 /* |
384 * allocate XvImages. FIXME: no error checking, without | |
385 * mit-shm this will bomb... | |
386 */ | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
387 xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]); |
1 | 388 |
182 | 389 Shminfo[foo].shmid = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777); |
390 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0); | |
391 Shminfo[foo].readOnly = False; | |
1 | 392 |
182 | 393 xvimage[foo]->data = Shminfo[foo].shmaddr; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
394 XShmAttach(mDisplay, &Shminfo[foo]); |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
395 XSync(mDisplay, False); |
182 | 396 shmctl(Shminfo[foo].shmid, IPC_RMID, 0); |
397 memset(xvimage[foo]->data,128,xvimage[foo]->data_size); | |
398 return; | |
1 | 399 } |
400 | |
1794 | 401 static void deallocate_xvimage(int foo) |
402 { | |
403 XShmDetach( mDisplay,&Shminfo[foo] ); | |
404 shmdt( Shminfo[foo].shmaddr ); | |
405 XFlush( mDisplay ); | |
406 XSync(mDisplay, False); | |
407 return; | |
408 } | |
409 | |
31 | 410 static void check_events(void) |
1 | 411 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
412 int e=vo_x11_check_events(mDisplay); |
182 | 413 if(e&VO_EVENT_RESIZE) |
414 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
415 XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); |
182 | 416 drwX=0; drwY=0; |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
417 XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); |
614 | 418 printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
1 | 419 |
1775 | 420 #ifdef HAVE_NEW_GUI |
723 | 421 if ( vo_window != None ) |
422 { | |
423 mFullscreen=0; | |
424 dwidth=mdwidth; dheight=mdheight; | |
1818 | 425 if ( ( vo_dwidth == vo_screenwidth )&&( vo_dheight == vo_screenheight ) ) |
723 | 426 { |
427 mFullscreen=1; | |
428 dwidth=vo_screenwidth; | |
429 dheight=vo_screenwidth * mdheight / mdwidth; | |
430 } | |
431 } | |
432 #endif | |
433 | |
3558 | 434 aspect(&dwidth,&dheight,A_NOZOOM); |
182 | 435 if ( mFullscreen ) |
436 { | |
3558 | 437 aspect(&dwidth,&dheight,A_ZOOM); |
182 | 438 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; |
439 drwcX+=drwX; | |
440 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; | |
441 drwcY+=drwY; | |
442 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); | |
443 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); | |
614 | 444 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
182 | 445 } |
446 } | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
447 if ( e & VO_EVENT_EXPOSE ) |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
448 { |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
449 XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf], 0, 0, image_width, image_height, drwX, drwY, 1, 1, False); |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
450 XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf], 0, 0, image_width, image_height, drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight), False); |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
451 } |
1 | 452 } |
453 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
454 static void draw_osd(void) |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
455 { vo_draw_text(image_width,image_height,draw_alpha_fnc);} |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
456 |
182 | 457 static void flip_page(void) |
1 | 458 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
459 XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf], |
182 | 460 0, 0, image_width, image_height, |
461 drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight), | |
462 False); | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
463 if (num_buffers>1){ |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
464 current_buf=(current_buf+1)%num_buffers; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
465 XFlush(mDisplay); |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
466 } else |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
467 XSync(mDisplay, False); |
182 | 468 return; |
1 | 469 } |
470 | |
247 | 471 |
472 | |
182 | 473 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) |
1 | 474 { |
182 | 475 uint8_t *src; |
476 uint8_t *dst; | |
477 int i; | |
478 | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
479 dst = xvimage[current_buf]->data + image_width * y + x; |
182 | 480 src = image[0]; |
481 if(w==stride[0] && w==image_width) memcpy(dst,src,w*h); | |
482 else | |
483 for(i=0;i<h;i++) | |
484 { | |
485 memcpy(dst,src,w); | |
486 src+=stride[0]; | |
487 dst+=image_width; | |
488 } | |
489 | |
490 x/=2;y/=2;w/=2;h/=2; | |
1 | 491 |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
492 dst = xvimage[current_buf]->data + image_width * image_height + image_width/2 * y + x; |
182 | 493 src = image[2]; |
494 if(w==stride[2] && w==image_width/2) memcpy(dst,src,w*h); | |
495 else | |
496 for(i=0;i<h;i++) | |
497 { | |
498 memcpy(dst,src,w); | |
499 src+=stride[2]; | |
500 dst+=image_width/2; | |
501 } | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
502 dst = xvimage[current_buf]->data + image_width * image_height * 5 / 4 + image_width/2 * y + x; |
182 | 503 src = image[1]; |
504 if(w==stride[1] && w==image_width/2) memcpy(dst,src,w*h); | |
505 else | |
506 for(i=0;i<h;i++) | |
507 { | |
508 memcpy(dst,src,w); | |
509 src+=stride[1]; | |
510 dst+=image_width/2; | |
511 } | |
512 return 0; | |
1 | 513 } |
514 | |
182 | 515 static uint32_t draw_frame(uint8_t *src[]) |
1 | 516 { |
182 | 517 int foo; |
1 | 518 |
408 | 519 switch (xv_format) { |
520 case IMGFMT_YUY2: | |
521 case IMGFMT_UYVY: | |
522 case IMGFMT_YVYU: | |
523 | |
524 // YUY2 packed, flipped | |
1 | 525 #if 0 |
408 | 526 int i; |
527 unsigned short *s=(unsigned short *)src[0]; | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
528 unsigned short *d=(unsigned short *)xvimage[current_buf]->data; |
408 | 529 s+=image_width*image_height; |
530 for(i=0;i<image_height;i++) { | |
531 s-=image_width; | |
532 memcpy(d,s,image_width*2); | |
533 d+=image_width; | |
534 } | |
1 | 535 #else |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
536 memcpy(xvimage[current_buf]->data,src[0],image_width*image_height*2); |
1 | 537 #endif |
408 | 538 break; |
539 | |
540 case IMGFMT_YV12: | |
541 case IMGFMT_I420: | |
542 case IMGFMT_IYUV: | |
543 | |
182 | 544 // YV12 planar |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
545 memcpy(xvimage[current_buf]->data,src[0],image_width*image_height); |
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
546 memcpy(xvimage[current_buf]->data+image_width*image_height,src[2],image_width*image_height/4); |
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
547 memcpy(xvimage[current_buf]->data+image_width*image_height*5/4,src[1],image_width*image_height/4); |
408 | 548 break; |
549 } | |
182 | 550 |
551 return 0; | |
1 | 552 } |
553 | |
182 | 554 static uint32_t query_format(uint32_t format) |
1 | 555 { |
408 | 556 |
557 // umm, this is a kludge, we need to ask the server.. (see init function above) | |
558 return 1; | |
559 /* | |
182 | 560 switch(format) |
561 { | |
562 case IMGFMT_YV12: | |
408 | 563 case IMGFMT_YUY2: |
564 return 1; | |
182 | 565 } |
566 return 0; | |
408 | 567 */ |
1 | 568 } |
569 | |
1852 | 570 static void uninit(void) |
571 { | |
572 int i; | |
1794 | 573 #ifdef HAVE_NEW_GUI |
1852 | 574 if ( vo_window == None ) |
1794 | 575 #endif |
1924 | 576 { |
1852 | 577 saver_on(mDisplay); // screen saver back on |
1924 | 578 XDestroyWindow( mDisplay,mywindow ); |
579 } | |
1852 | 580 for( i=0;i<num_buffers;i++ ) deallocate_xvimage( i ); |
322
4e69a8e2700a
Screensaver and monitor powersafe function is switched off when playing a
laaz
parents:
249
diff
changeset
|
581 } |
1 | 582 |
583 | |
584 |