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