Mercurial > mplayer.hg
annotate libvo/vo_xv.c @ 4324:09f15844c960
don't render UV planes if interleaved (also add support later)
author | alex |
---|---|
date | Wed, 23 Jan 2002 19:32:52 +0000 |
parents | bfcf2517876b |
children | aac822b8a630 |
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; |
4317 | 121 extern int vo_gamma_red_intensity; |
122 extern int vo_gamma_green_intensity; | |
123 extern int vo_gamma_blue_intensity; | |
4296
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; |
4307 | 128 int howmany, xv_min,xv_max,xv_atomka; |
129 static int was_reset = 0; | |
130 /* get available attributes */ | |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
131 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany); |
4307 | 132 /* first pass try reset */ |
133 if(!was_reset) | |
134 for (i = 0; i < howmany && attributes; i++) | |
135 { | |
136 if (attributes[i].flags & XvSettable && !strcmp(attributes[i].name,"XV_SET_DEFAULTS" | |
137 )) | |
138 { | |
139 was_reset = 1; | |
140 if(verbose > 1) printf("vo_xv: reset gamma correction\n"); | |
141 xv_atomka = XInternAtom(mDisplay, attributes[i].name, True); | |
142 XvSetPortAttribute(mDisplay, xv_port, xv_atomka, attributes[i].max_value); | |
143 } | |
144 } | |
145 /* for safety purposes */ | |
146 if(!was_reset) return; | |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
147 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
|
148 { |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
149 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
|
150 { |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
151 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
|
152 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
|
153 xv_atomka = XInternAtom(mDisplay, attributes[i].name, True); |
4307 | 154 /* since we have SET_DEFAULTS first in our list, we can check if it's available |
155 then trigger it if it's ok so that the other values are at default upon query */ | |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
156 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
|
157 { |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 else |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
162 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
|
163 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
|
164 else |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
165 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
|
166 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
|
167 else |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
168 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
|
169 port_value = vo_gamma_hue; |
4320
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
170 else |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
171 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */ |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
172 if(strcmp(attributes[i].name,"XV_RED_INTENSITY") == 0) |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
173 port_value = vo_gamma_red_intensity; |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
174 else |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
175 if(strcmp(attributes[i].name,"XV_GREEN_INTENSITY") == 0) |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
176 port_value = vo_gamma_green_intensity; |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
177 else |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
178 if(strcmp(attributes[i].name,"XV_BLUE_INTENSITY") == 0) |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
179 port_value = vo_gamma_blue_intensity; |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
180 else continue; |
4320
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
181 /* means that user has untouched this parameter since |
bfcf2517876b
RGB independed correction for GATOS's radeon_video driver!
nick
parents:
4317
diff
changeset
|
182 NVidia driver has default == min for XV_HUE but not mid */ |
4307 | 183 if(!port_value) continue; |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
184 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
|
185 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
|
186 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
|
187 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
|
188 if(verbose > 1) |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
189 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
|
190 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
|
191 } |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
192 } |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
193 } |
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
194 } |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
195 |
182 | 196 /* |
197 * connect to server, create and map window, | |
1 | 198 * allocate colors and (shared) memory |
199 */ | |
844 | 200 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 | 201 { |
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 // int screen; |
182 | 203 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
|
204 // char *name = ":0.0"; |
182 | 205 XSizeHints hint; |
206 XVisualInfo vinfo; | |
207 XEvent xev; | |
1186
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
208 XvPortID xv_p; |
1 | 209 |
182 | 210 XGCValues xgcv; |
211 XSetWindowAttributes xswa; | |
212 unsigned long xswamask; | |
1 | 213 |
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
|
214 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
|
215 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
|
216 |
182 | 217 image_height = height; |
218 image_width = width; | |
219 image_format=format; | |
1 | 220 |
1775 | 221 #ifdef HAVE_NEW_GUI |
222 mdwidth=width; | |
223 mdheight=height; | |
224 #endif | |
225 | |
844 | 226 mFullscreen=flags&1; |
1265 | 227 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
|
228 |
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
229 if (!vo_init()) return -1; |
1 | 230 |
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
|
231 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
|
232 |
1775 | 233 #ifdef HAVE_NEW_GUI |
723 | 234 if ( vo_window == None ) |
182 | 235 { |
723 | 236 #endif |
237 hint.x = 0; | |
238 hint.y = 0; | |
239 hint.width = d_width; | |
240 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
|
241 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
|
242 |
844 | 243 if ( mFullscreen ) |
723 | 244 { |
245 hint.width=vo_screenwidth; | |
246 hint.height=vo_screenheight; | |
2054 | 247 #ifdef X11_FULLSCREEN |
2031
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
248 /* this code replaces X11_FULLSCREEN hack in mplayer.c |
2054 | 249 * 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
|
250 * 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
|
251 * 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
|
252 * 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
|
253 */ |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
254 |
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
|
255 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
|
256 #endif |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1924
diff
changeset
|
257 |
723 | 258 } |
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
|
259 dwidth=d_width; dheight=d_height; //XXX: what are the copy vars used for? |
723 | 260 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
|
261 XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs); |
723 | 262 depth=attribs.depth; |
263 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
|
264 XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); |
723 | 265 |
266 xswa.background_pixel = 0; | |
267 xswa.border_pixel = 0; | |
268 xswamask = CWBackPixel | CWBorderPixel; | |
1 | 269 |
3830 | 270 if ( WinID>=0 ){ |
271 mywindow = WinID ? ((Window)WinID) : RootWindow(mDisplay,mScreen); | |
272 XUnmapWindow( mDisplay,mywindow ); | |
273 XChangeWindowAttributes( mDisplay,mywindow,xswamask,&xswa ); | |
274 } else | |
275 | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
276 mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen), |
3830 | 277 hint.x, hint.y, hint.width, hint.height, |
278 0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa); | |
279 | |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
922
diff
changeset
|
280 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
|
281 vo_hidecursor(mDisplay,mywindow); |
1 | 282 |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
283 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
|
284 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
|
285 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
|
286 XMapWindow(mDisplay, mywindow); |
3990 | 287 #ifdef HAVE_XINERAMA |
288 vo_x11_xinerama_move(mDisplay,mywindow); | |
289 #endif | |
1775 | 290 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
|
291 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
|
292 XSync(mDisplay, False); |
1775 | 293 #ifdef HAVE_NEW_GUI |
723 | 294 } |
295 else | |
296 { | |
297 mywindow=vo_window; | |
298 mygc=vo_gc; | |
299 } | |
300 #endif | |
1 | 301 |
182 | 302 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
|
303 if (Success == XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)) |
182 | 304 { |
305 /* 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
|
306 if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai)) |
182 | 307 { |
614 | 308 printf("Xv: XvQueryAdaptors failed"); |
182 | 309 return -1; |
310 } | |
311 /* check adaptors */ | |
1186
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
312 for (i = 0; i < adaptors && xv_port == 0; i++) |
182 | 313 { |
1186
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
314 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
|
315 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
|
316 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
|
317 xv_port = xv_p; |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
318 break; |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
319 } else { |
beb0ee0f3a25
Xv port locking patch by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi_esp
parents:
1137
diff
changeset
|
320 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
|
321 } |
182 | 322 } |
323 /* check image formats */ | |
324 if (xv_port != 0) | |
325 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
326 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); |
182 | 327 xv_format=0; |
328 for(i = 0; i < formats; i++) | |
329 { | |
614 | 330 printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); |
1 | 331 |
182 | 332 if (fo[i].id == format) |
333 { | |
334 xv_format = fo[i].id; | |
335 } | |
336 } | |
337 if (!xv_format) xv_port = 0; | |
338 } | |
339 | |
340 if (xv_port != 0) | |
341 { | |
614 | 342 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
|
343 |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
344 switch (xv_format){ |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
345 case IMGFMT_YV12: |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
346 case IMGFMT_I420: |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
347 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
|
348 case IMGFMT_YUY2: |
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
349 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
|
350 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
|
351 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
|
352 } |
182 | 353 |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
354 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
|
355 allocate_xvimage(current_buf); |
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
356 |
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
357 current_buf=0; |
1 | 358 |
1818 | 359 #ifdef HAVE_NEW_GUI |
360 if ( vo_window != None ) | |
361 { | |
362 mFullscreen=0; | |
363 dwidth=mdwidth; dheight=mdheight; | |
364 if ( ( vo_dwidth == vo_screenwidth )&&( vo_dheight == vo_screenheight ) ) | |
365 { | |
366 mFullscreen=1; | |
367 dwidth=vo_screenwidth; | |
368 dheight=vo_screenwidth * mdheight / mdwidth; | |
369 } | |
370 } | |
371 #endif | |
4296
a20c333d6c09
Gamma correction (based on patch of P«”sztor Szil«”rd <silicon@falcon.sch.bme.hu>)
nick
parents:
3990
diff
changeset
|
372 set_gamma_correction(xv_port); |
1818 | 373 |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
374 XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); |
182 | 375 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
|
376 XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); |
614 | 377 printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
1 | 378 |
3558 | 379 aspect(&dwidth,&dheight,A_NOZOOM); |
182 | 380 if ( mFullscreen ) |
381 { | |
3558 | 382 aspect(&dwidth,&dheight,A_ZOOM); |
2055
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2054
diff
changeset
|
383 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; |
182 | 384 drwcX+=drwX; |
2055
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2054
diff
changeset
|
385 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; |
182 | 386 drwcY+=drwY; |
2055
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2054
diff
changeset
|
387 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
|
388 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); |
614 | 389 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
182 | 390 } |
4316 | 391 saver_off(mDisplay); // turning off screen saver |
182 | 392 return 0; |
393 } | |
394 } | |
1 | 395 |
182 | 396 printf("Sorry, Xv not supported by this X11 version/driver\n"); |
397 printf("******** Try with -vo x11 or -vo sdl *********\n"); | |
398 return 1; | |
1 | 399 } |
400 | |
182 | 401 static const vo_info_t * get_info(void) |
402 { return &vo_info; } | |
1 | 403 |
182 | 404 static void allocate_xvimage(int foo) |
1 | 405 { |
182 | 406 /* |
407 * allocate XvImages. FIXME: no error checking, without | |
408 * mit-shm this will bomb... | |
409 */ | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
410 xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]); |
1 | 411 |
182 | 412 Shminfo[foo].shmid = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777); |
413 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0); | |
414 Shminfo[foo].readOnly = False; | |
1 | 415 |
182 | 416 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
|
417 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
|
418 XSync(mDisplay, False); |
182 | 419 shmctl(Shminfo[foo].shmid, IPC_RMID, 0); |
420 memset(xvimage[foo]->data,128,xvimage[foo]->data_size); | |
421 return; | |
1 | 422 } |
423 | |
1794 | 424 static void deallocate_xvimage(int foo) |
425 { | |
426 XShmDetach( mDisplay,&Shminfo[foo] ); | |
427 shmdt( Shminfo[foo].shmaddr ); | |
428 XFlush( mDisplay ); | |
429 XSync(mDisplay, False); | |
430 return; | |
431 } | |
432 | |
31 | 433 static void check_events(void) |
1 | 434 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
435 int e=vo_x11_check_events(mDisplay); |
182 | 436 if(e&VO_EVENT_RESIZE) |
437 { | |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
438 XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); |
182 | 439 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
|
440 XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); |
614 | 441 printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
1 | 442 |
1775 | 443 #ifdef HAVE_NEW_GUI |
723 | 444 if ( vo_window != None ) |
445 { | |
446 mFullscreen=0; | |
447 dwidth=mdwidth; dheight=mdheight; | |
1818 | 448 if ( ( vo_dwidth == vo_screenwidth )&&( vo_dheight == vo_screenheight ) ) |
723 | 449 { |
450 mFullscreen=1; | |
451 dwidth=vo_screenwidth; | |
452 dheight=vo_screenwidth * mdheight / mdwidth; | |
453 } | |
454 } | |
455 #endif | |
456 | |
3558 | 457 aspect(&dwidth,&dheight,A_NOZOOM); |
182 | 458 if ( mFullscreen ) |
459 { | |
3558 | 460 aspect(&dwidth,&dheight,A_ZOOM); |
182 | 461 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; |
462 drwcX+=drwX; | |
463 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; | |
464 drwcY+=drwY; | |
465 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); | |
466 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); | |
614 | 467 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
182 | 468 } |
469 } | |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
470 if ( e & VO_EVENT_EXPOSE ) |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
471 { |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
472 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
|
473 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
|
474 } |
1 | 475 } |
476 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
477 static void draw_osd(void) |
1647
22480104ddfd
added draw_alpha_XXXX functions, draw_alpha_func<=correct one in init
atlka
parents:
1501
diff
changeset
|
478 { 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
|
479 |
182 | 480 static void flip_page(void) |
1 | 481 { |
922
db06ae8967eb
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.
lgb
parents:
844
diff
changeset
|
482 XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf], |
182 | 483 0, 0, image_width, image_height, |
484 drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight), | |
485 False); | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
486 if (num_buffers>1){ |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
487 current_buf=(current_buf+1)%num_buffers; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
488 XFlush(mDisplay); |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
489 } else |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1265
diff
changeset
|
490 XSync(mDisplay, False); |
182 | 491 return; |
1 | 492 } |
493 | |
247 | 494 |
495 | |
182 | 496 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) |
1 | 497 { |
182 | 498 uint8_t *src; |
499 uint8_t *dst; | |
500 int i; | |
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 * y + x; |
182 | 503 src = image[0]; |
504 if(w==stride[0] && w==image_width) memcpy(dst,src,w*h); | |
505 else | |
506 for(i=0;i<h;i++) | |
507 { | |
508 memcpy(dst,src,w); | |
509 src+=stride[0]; | |
510 dst+=image_width; | |
511 } | |
512 | |
513 x/=2;y/=2;w/=2;h/=2; | |
1 | 514 |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
515 dst = xvimage[current_buf]->data + image_width * image_height + image_width/2 * y + x; |
182 | 516 src = image[2]; |
517 if(w==stride[2] && w==image_width/2) memcpy(dst,src,w*h); | |
518 else | |
519 for(i=0;i<h;i++) | |
520 { | |
521 memcpy(dst,src,w); | |
522 src+=stride[2]; | |
523 dst+=image_width/2; | |
524 } | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
525 dst = xvimage[current_buf]->data + image_width * image_height * 5 / 4 + image_width/2 * y + x; |
182 | 526 src = image[1]; |
527 if(w==stride[1] && w==image_width/2) memcpy(dst,src,w*h); | |
528 else | |
529 for(i=0;i<h;i++) | |
530 { | |
531 memcpy(dst,src,w); | |
532 src+=stride[1]; | |
533 dst+=image_width/2; | |
534 } | |
535 return 0; | |
1 | 536 } |
537 | |
182 | 538 static uint32_t draw_frame(uint8_t *src[]) |
1 | 539 { |
182 | 540 int foo; |
1 | 541 |
408 | 542 switch (xv_format) { |
543 case IMGFMT_YUY2: | |
544 case IMGFMT_UYVY: | |
545 case IMGFMT_YVYU: | |
546 | |
547 // YUY2 packed, flipped | |
1 | 548 #if 0 |
408 | 549 int i; |
550 unsigned short *s=(unsigned short *)src[0]; | |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
551 unsigned short *d=(unsigned short *)xvimage[current_buf]->data; |
408 | 552 s+=image_width*image_height; |
553 for(i=0;i<image_height;i++) { | |
554 s-=image_width; | |
555 memcpy(d,s,image_width*2); | |
556 d+=image_width; | |
557 } | |
1 | 558 #else |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
559 memcpy(xvimage[current_buf]->data,src[0],image_width*image_height*2); |
1 | 560 #endif |
408 | 561 break; |
562 | |
563 case IMGFMT_YV12: | |
564 case IMGFMT_I420: | |
565 case IMGFMT_IYUV: | |
566 | |
182 | 567 // YV12 planar |
676
428755f858f7
multi buffering added (modify NUM_BUFFERS in the source)
arpi_esp
parents:
616
diff
changeset
|
568 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
|
569 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
|
570 memcpy(xvimage[current_buf]->data+image_width*image_height*5/4,src[1],image_width*image_height/4); |
408 | 571 break; |
572 } | |
182 | 573 |
574 return 0; | |
1 | 575 } |
576 | |
182 | 577 static uint32_t query_format(uint32_t format) |
1 | 578 { |
408 | 579 |
580 // umm, this is a kludge, we need to ask the server.. (see init function above) | |
581 return 1; | |
582 /* | |
182 | 583 switch(format) |
584 { | |
585 case IMGFMT_YV12: | |
408 | 586 case IMGFMT_YUY2: |
587 return 1; | |
182 | 588 } |
589 return 0; | |
408 | 590 */ |
1 | 591 } |
592 | |
1852 | 593 static void uninit(void) |
594 { | |
595 int i; | |
4316 | 596 saver_on(mDisplay); // screen saver back on |
1794 | 597 #ifdef HAVE_NEW_GUI |
1852 | 598 if ( vo_window == None ) |
1794 | 599 #endif |
1924 | 600 { |
601 XDestroyWindow( mDisplay,mywindow ); | |
602 } | |
1852 | 603 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
|
604 } |
1 | 605 |
606 | |
607 |