Mercurial > mplayer.hg
annotate libvo/vo_sdl.c @ 580:dd0a2985304f
little fix, just to be precise
author | arpi_esp |
---|---|
date | Sun, 22 Apr 2001 17:07:57 +0000 |
parents | 256f3d32a4af |
children | 77e0094f0cce |
rev | line source |
---|---|
1 | 1 /* |
351 | 2 * vo_sdl.c |
3 * | |
579 | 4 * (was video_out_sdl.c from OMS project/mpeg2dec -> http://linuxvideo.org) |
1 | 5 * |
6 * Copyright (C) Ryan C. Gordon <icculus@lokigames.com> - April 22, 2000. | |
7 * | |
579 | 8 * Current maintainer for MPlayer project (report bugs to that address): |
9 * Felix Buenemann <atmosfear@users.sourceforge.net> | |
10 * | |
11 * This file is a video out driver using the SDL library (http://libsdl.org/), | |
580 | 12 * to be used with MPlayer [The Movie Player for Linux] project, further info |
579 | 13 * from http://mplayer.sourceforge.net. |
14 * | |
15 * Current license is not decided yet, but we're heading for GPL. | |
16 * | |
17 * -- old disclaimer -- | |
18 * | |
1 | 19 * A mpeg2dec display driver that does output through the |
20 * Simple DirectMedia Layer (SDL) library. This effectively gives us all | |
21 * sorts of output options: X11, SVGAlib, fbcon, AAlib, GGI. Win32, MacOS | |
22 * and BeOS support, too. Yay. SDL info, source, and binaries can be found | |
23 * at http://slouken.devolution.com/SDL/ | |
24 * | |
25 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
26 * | |
27 * mpeg2dec is free software; you can redistribute it and/or modify | |
28 * it under the terms of the GNU General Public License as published by | |
29 * the Free Software Foundation; either version 2, or (at your option) | |
30 * any later version. | |
31 * | |
32 * mpeg2dec is distributed in the hope that it will be useful, | |
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
35 * GNU General Public License for more details. | |
36 * | |
37 * You should have received a copy of the GNU General Public License | |
38 * along with GNU Make; see the file COPYING. If not, write to | |
579 | 39 * the Free Software Foundation. |
40 * | |
41 * -- end old disclaimer -- | |
1 | 42 * |
43 * Changes: | |
44 * Dominik Schnitzer <dominik@schnitzer.at> - November 08, 2000. | |
84 | 45 * - Added resizing support, fullscreen: changed the sdlmodes selection |
1 | 46 * routine. |
47 * - SDL bugfixes: removed the atexit(SLD_Quit), SDL_Quit now resides in | |
48 * the plugin_exit routine. | |
49 * - Commented the source :) | |
50 * - Shortcuts: for switching between Fullscreen/Windowed mode and for | |
51 * cycling between the different Fullscreen modes. | |
52 * - Small bugfixes: proper width/height of movie | |
53 * Dominik Schnitzer <dominik@schnitzer.at> - November 11, 2000. | |
54 * - Cleanup code, more comments | |
55 * - Better error handling | |
56 * Bruno Barreyra <barreyra@ufl.edu> - December 10, 2000. | |
57 * - Eliminated memcpy's for entire frames | |
579 | 58 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 11, 2001 |
84 | 59 * - Added aspect-ratio awareness for fullscreen |
579 | 60 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 11, 2001 |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
61 * - Fixed aspect-ratio awareness, did only vertical scaling (black bars above |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
62 * and below), now also does horizontal scaling (black bars left and right), |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
63 * so you get the biggest possible picture with correct aspect-ratio. |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
64 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 12, 2001 |
579 | 65 * - Minor bugfix to aspect-ratio for non-4:3-resolutions (like 1280x1024) |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
66 * - Bugfix to check_events() to reveal mouse cursor after 'q'-quit in |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
67 * fullscreen-mode |
351 | 68 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 10, 2001 |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
69 * - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
70 * bug (key had to be pressed twice to be detected) |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
71 * - Changed key-handling: 'f' cycles fullscreen/windowed, ESC/RETURN/'q' quits |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
72 * - Bugfix which avoids exit, because return is passed to sdl-output on startup, |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
73 * which caused the player to exit (keyboard-buffer problem? better solution |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
74 * recommed) |
351 | 75 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 11, 2001 |
76 * - OSD and subtitle support added | |
77 * - some minor code-changes | |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
78 * - added code to comply with new fullscreen meaning |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
79 * - changed fullscreen-mode-cycling from '+' to 'c' (interferred with audiosync |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
80 * adjustment) |
386 | 81 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 13, 2001 |
82 * - added keymapping to toggle OSD ('o' key) | |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
83 * - added some defines to modify some sdl-out internas (see comments) |
475
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
84 * |
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
85 * Felix Buenemann: further changes will be visible through cvs log, don't want |
579 | 86 * to update this all the time (CVS info on http://mplayer.sourceforge.net) |
87 * | |
88 * KNOWN BUGS: | |
89 * - Crashes with aalib (not resolved yet) | |
1 | 90 */ |
91 | |
542
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
92 /* define if you want to force Xv SDL output? */ |
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
93 #undef SDL_FORCEXV |
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
94 /* define to force software-surface (video surface stored in system memory)*/ |
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
95 #undef SDL_NOHWSURFACE |
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
96 /* define to disable usage of the xvideo extension */ |
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
97 #undef SDL_NOXV |
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
98 |
1 | 99 #include <stdio.h> |
100 #include <stdlib.h> | |
101 #include <string.h> | |
102 #include <inttypes.h> | |
103 | |
104 #include "config.h" | |
105 #include "video_out.h" | |
106 #include "video_out_internal.h" | |
107 | |
354 | 108 #include "fastmemcpy.h" |
350 | 109 |
1 | 110 LIBVO_EXTERN(sdl) |
111 | |
112 //#include "log.h" | |
113 //#define LOG if(0)printf | |
114 | |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
115 extern int verbose; |
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
116 |
1 | 117 static vo_info_t vo_info = |
118 { | |
84 | 119 "SDL YUV overlay (SDL v1.1.7+ only!)", |
1 | 120 "sdl", |
121 "Ryan C. Gordon <icculus@lokigames.com>", | |
122 "" | |
123 }; | |
124 | |
125 #include <SDL/SDL.h> | |
126 | |
127 /** Private SDL Data structure **/ | |
128 | |
129 static struct sdl_priv_s { | |
130 | |
131 /* SDL YUV surface & overlay */ | |
132 SDL_Surface *surface; | |
133 SDL_Overlay *overlay; | |
134 // SDL_Overlay *current_frame; | |
135 | |
136 /* available fullscreen modes */ | |
137 SDL_Rect **fullmodes; | |
138 | |
139 /* surface attributes for fullscreen and windowed mode */ | |
140 Uint32 sdlflags, sdlfullflags; | |
141 | |
142 /* save the windowed output extents */ | |
143 SDL_Rect windowsize; | |
144 | |
145 /* Bits per Pixel */ | |
146 Uint8 bpp; | |
147 | |
148 /* current fullscreen mode, 0 = highest available fullscreen mode */ | |
149 int fullmode; | |
150 | |
151 /* YUV ints */ | |
152 int framePlaneY, framePlaneUV; | |
153 int stridePlaneY, stridePlaneUV; | |
154 int width,height; | |
155 int format; | |
156 } sdl_priv; | |
157 | |
158 | |
351 | 159 /** libvo Plugin functions **/ |
160 | |
161 /** | |
162 * draw_alpha is used for osd and subtitle display. | |
163 * | |
164 **/ | |
165 | |
166 //void vo_draw_alpha_yv12(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); | |
167 //void vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride); | |
168 | |
169 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | |
408 | 170 struct sdl_priv_s *priv = &sdl_priv; |
171 int x,y; | |
351 | 172 |
408 | 173 switch(priv->format) { |
174 case IMGFMT_YV12: | |
175 case IMGFMT_I420: | |
176 case IMGFMT_IYUV: | |
177 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->width*y0+x0,priv->width); | |
178 break; | |
179 case IMGFMT_YUY2: | |
180 case IMGFMT_YVYU: | |
181 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0),2*priv->width); | |
182 break; | |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
183 case IMGFMT_UYVY: |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
184 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0)+1,2*priv->width); |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
185 break; |
408 | 186 } |
351 | 187 } |
1 | 188 |
189 | |
190 /** | |
191 * Take a null-terminated array of pointers, and find the last element. | |
192 * | |
193 * params : array == array of which we want to find the last element. | |
194 * returns : index of last NON-NULL element. | |
195 **/ | |
196 | |
197 static inline int findArrayEnd (SDL_Rect **array) | |
198 { | |
199 int i = 0; | |
200 while ( array[i++] ); /* keep loopin' ... */ | |
201 | |
202 /* return the index of the last array element */ | |
203 return i - 1; | |
204 } | |
205 | |
206 | |
207 /** | |
208 * Open and prepare SDL output. | |
209 * | |
210 * params : *plugin == | |
211 * *name == | |
212 * returns : 0 on success, -1 on failure | |
213 **/ | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
214 |
1 | 215 static int sdl_open (void *plugin, void *name) |
216 { | |
217 struct sdl_priv_s *priv = &sdl_priv; | |
218 const SDL_VideoInfo *vidInfo = NULL; | |
219 static int opened = 0; | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
220 |
1 | 221 if (opened) |
222 return 0; | |
223 opened = 1; | |
224 | |
225 // LOG (LOG_DEBUG, "SDL video out: Opened Plugin"); | |
351 | 226 |
227 /* does the user want SDL to try and force Xv */ | |
228 #ifdef SDL_FORCEXV | |
229 setenv("SDL_VIDEO_X11_NODIRECTCOLOR", "1", 1); | |
230 #endif | |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
231 #ifdef SDL_NOXV |
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
232 setenv("SDL_VIDEO_YUV_HWACCEL", "0", 1); |
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
233 #endif |
1 | 234 |
84 | 235 /* default to no fullscreen mode, we'll set this as soon we have the avail. modes */ |
1 | 236 priv->fullmode = -2; |
237 /* other default values */ | |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
238 #ifdef SDL_NOHWSURFACE |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
239 if(verbose) printf("SDL: using software-surface\n"); |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
240 priv->sdlflags = SDL_SWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT; |
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
241 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT; |
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
242 #else |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
243 if(verbose) printf("SDL: using hardware-surface\n"); |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
244 priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT; //SDL_HWACCEL |
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
245 priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT; //SDL_HWACCEL |
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
246 #endif |
1 | 247 priv->surface = NULL; |
248 priv->overlay = NULL; | |
249 priv->fullmodes = NULL; | |
351 | 250 priv->bpp = 0; //added atmos |
1 | 251 |
252 /* initialize the SDL Video system */ | |
253 if (SDL_Init (SDL_INIT_VIDEO)) { | |
254 // LOG (LOG_ERROR, "SDL video out: Initializing of SDL failed (SDL_Init). Please use the latest version of SDL."); | |
255 return -1; | |
256 } | |
257 | |
258 /* No Keyrepeats! */ | |
259 SDL_EnableKeyRepeat(0,0); | |
260 | |
261 /* get information about the graphics adapter */ | |
262 vidInfo = SDL_GetVideoInfo (); | |
263 | |
264 /* collect all fullscreen & hardware modes available */ | |
265 if (!(priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags))) { | |
266 | |
267 /* non hardware accelerated fullscreen modes */ | |
268 priv->sdlfullflags &= ~SDL_HWSURFACE; | |
269 priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags); | |
270 } | |
271 | |
272 /* test for normal resizeable & windowed hardware accellerated surfaces */ | |
273 if (!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) { | |
274 | |
275 /* test for NON hardware accelerated resizeable surfaces - poor you. | |
276 * That's all we have. If this fails there's nothing left. | |
277 * Theoretically there could be Fullscreenmodes left - we ignore this for now. | |
278 */ | |
279 priv->sdlflags &= ~SDL_HWSURFACE; | |
280 if ((!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) && (!priv->fullmodes)) { | |
281 // LOG (LOG_ERROR, "SDL video out: Couldn't get any acceptable SDL Mode for output. (SDL_ListModes failed)"); | |
282 return -1; | |
283 } | |
284 } | |
285 | |
286 | |
287 /* YUV overlays need at least 16-bit color depth, but the | |
288 * display might less. The SDL AAlib target says it can only do | |
289 * 8-bits, for example. So, if the display is less than 16-bits, | |
290 * we'll force the BPP to 16, and pray that SDL can emulate for us. | |
291 */ | |
292 priv->bpp = vidInfo->vfmt->BitsPerPixel; | |
293 if (priv->bpp < 16) { | |
294 /* | |
295 LOG (LOG_WARNING, "SDL video out: Your SDL display target wants to be at a color depth of (%d), but we need it to be at\ | |
296 least 16 bits, so we need to emulate 16-bit color. This is going to slow things down; you might want to\ | |
297 increase your display's color depth, if possible", priv->bpp); | |
298 */ | |
299 priv->bpp = 16; | |
300 } | |
301 | |
302 /* We dont want those in out event queue */ | |
303 SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
304 SDL_EventState(SDL_KEYDOWN, SDL_IGNORE); |
1 | 305 SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); |
306 SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE); | |
307 SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); | |
308 SDL_EventState(SDL_QUIT, SDL_IGNORE); | |
309 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); | |
310 SDL_EventState(SDL_USEREVENT, SDL_IGNORE); | |
311 | |
312 /* Success! */ | |
313 return 0; | |
314 } | |
315 | |
316 | |
317 /** | |
318 * Close SDL, Cleanups, Free Memory | |
319 * | |
320 * params : *plugin | |
321 * returns : non-zero on success, zero on error. | |
322 **/ | |
323 | |
324 static int sdl_close (void) | |
325 { | |
326 struct sdl_priv_s *priv = &sdl_priv; | |
327 | |
328 /* Cleanup YUV Overlay structure */ | |
329 if (priv->overlay) | |
330 SDL_FreeYUVOverlay(priv->overlay); | |
331 | |
332 /* Free our blitting surface */ | |
333 if (priv->surface) | |
334 SDL_FreeSurface(priv->surface); | |
335 | |
351 | 336 /* DONT attempt to free the fullscreen modes array. SDL_Quit* does this for us */ |
1 | 337 |
338 /* Cleanup SDL */ | |
351 | 339 SDL_Quit(); /* might have to be changed to quitsubsystem only, if plugins become |
340 changeable on the fly */ | |
341 | |
342 // LOG (LOG_DEBUG, "SDL video out: Closed Plugin"); | |
1 | 343 |
344 return 0; | |
345 } | |
346 | |
347 | |
348 /** | |
349 * Sets the specified fullscreen mode. | |
350 * | |
351 * params : mode == index of the desired fullscreen mode | |
352 * returns : doesn't return | |
353 **/ | |
354 | |
355 static void set_fullmode (int mode) | |
356 { | |
357 struct sdl_priv_s *priv = &sdl_priv; | |
358 SDL_Surface *newsurface = NULL; | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
359 int haspect, waspect = 0; |
1 | 360 |
361 /* if we haven't set a fullmode yet, default to the lowest res fullmode first */ | |
362 if (mode < 0) | |
363 mode = priv->fullmode = findArrayEnd(priv->fullmodes) - 1; | |
364 | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
365 /* Calculate proper aspect ratio for fullscreen |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
366 * Height smaller than expected: add horizontal black bars (haspect)*/ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
367 haspect = (priv->width * (float) ((float) priv->fullmodes[mode]->h / (float) priv->fullmodes[mode]->w) - priv->height) * (float) ((float) priv->fullmodes[mode]->w / (float) priv->width); |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
368 /* Height bigger than expected: add vertical black bars (waspect)*/ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
369 if (haspect < 0) { |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
370 haspect = 0; /* set haspect to zero because image will be scaled horizontal instead of vertical */ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
371 waspect = priv->fullmodes[mode]->w - ((float) ((float) priv->fullmodes[mode]->h / (float) priv->height) * (float) priv->width); |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
372 } |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
373 // printf ("W-Aspect: %i H-Aspect: %i\n", waspect, haspect); |
84 | 374 |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
375 /* change to given fullscreen mode and hide the mouse cursor */ |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
376 newsurface = SDL_SetVideoMode(priv->fullmodes[mode]->w - waspect, priv->fullmodes[mode]->h - haspect, priv->bpp, priv->sdlfullflags); |
1 | 377 |
378 /* if we were successfull hide the mouse cursor and save the mode */ | |
379 if (newsurface) { | |
380 priv->surface = newsurface; | |
381 SDL_ShowCursor(0); | |
382 } | |
383 } | |
384 | |
385 | |
386 /** | |
387 * Initialize an SDL surface and an SDL YUV overlay. | |
388 * | |
389 * params : width == width of video we'll be displaying. | |
390 * height == height of video we'll be displaying. | |
391 * fullscreen == want to be fullscreen? | |
392 * title == Title for window titlebar. | |
393 * returns : non-zero on success, zero on error. | |
394 **/ | |
395 | |
396 static uint32_t | |
397 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format) | |
398 //static int sdl_setup (int width, int height) | |
399 { | |
400 struct sdl_priv_s *priv = &sdl_priv; | |
357 | 401 unsigned int sdl_format; |
575
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
402 |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
403 sdl_format = format; |
1 | 404 switch(format){ |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
405 case IMGFMT_YV12: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
406 if(verbose) printf("SDL: Using 0x%X (YV12) image format\n", format); break; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
407 case IMGFMT_IYUV: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
408 if(verbose) printf("SDL: Using 0x%X (IYUV) image format\n", format); break; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
409 case IMGFMT_YUY2: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
410 if(verbose) printf("SDL: Using 0x%X (YUY2) image format\n", format); break; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
411 case IMGFMT_UYVY: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
412 if(verbose) printf("SDL: Using 0x%X (UYVY) image format\n", format); break; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
413 case IMGFMT_YVYU: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
414 if(verbose) printf("SDL: Using 0x%X (YVYU) image format\n", format); break; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
415 case IMGFMT_I420: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
416 if(verbose) printf("SDL: Using 0x%X (I420) image format\n", format); |
542
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
417 printf("SDL: Mapping I420 to IYUV\n"); |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
418 sdl_format = SDL_IYUV_OVERLAY; |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
419 break; |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
420 default: |
542
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
421 printf("SDL: Unsupported image format (0x%X)\n",format); |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
422 return -1; |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
423 } |
1 | 424 |
425 sdl_open (NULL, NULL); | |
426 | |
351 | 427 /* Set output window title */ |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
428 SDL_WM_SetCaption (".: MPlayer : F = Fullscreen/Windowed : C = Cycle Fullscreen Resolutions :.", "SDL Video Out"); |
351 | 429 |
1 | 430 /* Save the original Image size */ |
84 | 431 |
1 | 432 priv->width = width; |
433 priv->height = height; | |
434 priv->format = format; | |
435 | |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
436 /* bit 0 (0x01) means fullscreen (-fs) |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
437 * bit 1 (0x02) means mode switching (-vm) |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
438 * bit 2 (0x04) enables software scaling (-zoom) |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
439 */ |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
440 // printf("SDL: fullscreenflag is set to: %i\n", fullscreen); |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
441 // printf("SDL: Width: %i Height: %i D_Width %i D_Height: %i\n", width, height, d_width, d_height); |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
442 switch(fullscreen){ |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
443 case 0x01: |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
444 case 0x05: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
445 if(verbose) printf("SDL: setting zoomed fullscreen without modeswitching\n"); |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
446 priv->windowsize.w = d_width; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
447 priv->windowsize.h = d_height; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
448 if(priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags)) |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
449 SDL_ShowCursor(0); |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
450 break; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
451 case 0x02: |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
452 case 0x03: |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
453 priv->windowsize.w = width; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
454 priv->windowsize.h = height; |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
455 #ifdef SDL_NOXV |
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
456 if(verbose) printf("SDL: setting nonzoomed fullscreen with modeswitching\n"); |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
457 if(priv->surface = SDL_SetVideoMode (width, height, priv->bpp, priv->sdlfullflags)) |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
458 SDL_ShowCursor(0); |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
459 #else |
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
460 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); |
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
461 priv->surface=NULL; |
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
462 set_fullmode(priv->fullmode); |
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
463 #endif |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
464 break; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
465 case 0x06: |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
466 case 0x07: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
467 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
468 priv->windowsize.w = width; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
469 priv->windowsize.h = height; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
470 priv->surface=NULL; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
471 set_fullmode(priv->fullmode); |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
472 break; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
473 default: |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
474 if(verbose) printf("SDL: setting windowed mode\n"); |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
475 priv->windowsize.w = d_width; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
476 priv->windowsize.h = d_height; |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
477 priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlflags); |
1 | 478 } |
479 if(!priv->surface) return -1; // cannot SetVideoMode | |
480 | |
481 /* Initialize and create the YUV Overlay used for video out */ | |
482 if (!(priv->overlay = SDL_CreateYUVOverlay (width, height, sdl_format, priv->surface))) { | |
483 printf ("SDL video out: Couldn't create an SDL-based YUV overlay\n"); | |
484 return -1; | |
485 } | |
486 priv->framePlaneY = width * height; | |
487 priv->framePlaneUV = (width * height) >> 2; | |
488 priv->stridePlaneY = width; | |
489 priv->stridePlaneUV = width/2; | |
490 | |
491 return 0; | |
492 } | |
493 | |
494 | |
495 /** | |
496 * Draw a frame to the SDL YUV overlay. | |
497 * | |
498 * params : *src[] == the Y, U, and V planes that make up the frame. | |
499 * returns : non-zero on success, zero on error. | |
500 **/ | |
501 | |
502 //static int sdl_draw_frame (frame_t *frame) | |
503 static uint32_t draw_frame(uint8_t *src[]) | |
504 { | |
505 struct sdl_priv_s *priv = &sdl_priv; | |
506 uint8_t *dst; | |
507 | |
508 // priv->current_frame = (SDL_Overlay*) frame->private; | |
509 // SDL_UnlockYUVOverlay (priv->current_frame); | |
510 | |
511 if (SDL_LockYUVOverlay (priv->overlay)) { | |
512 // LOG (LOG_ERROR, "SDL video out: Couldn't lock SDL-based YUV overlay"); | |
513 return -1; | |
514 } | |
515 | |
516 switch(priv->format){ | |
517 case IMGFMT_YV12: | |
408 | 518 case IMGFMT_I420: |
519 case IMGFMT_IYUV: | |
1 | 520 dst = (uint8_t *) *(priv->overlay->pixels); |
521 memcpy (dst, src[0], priv->framePlaneY); | |
522 dst += priv->framePlaneY; | |
523 memcpy (dst, src[2], priv->framePlaneUV); | |
524 dst += priv->framePlaneUV; | |
525 memcpy (dst, src[1], priv->framePlaneUV); | |
526 break; | |
408 | 527 |
1 | 528 case IMGFMT_YUY2: |
408 | 529 case IMGFMT_UYVY: |
530 case IMGFMT_YVYU: | |
1 | 531 dst = (uint8_t *) *(priv->overlay->pixels); |
532 memcpy (dst, src[0], priv->width*priv->height*2); | |
533 break; | |
534 } | |
535 | |
536 SDL_UnlockYUVOverlay (priv->overlay); | |
537 return 0; | |
538 } | |
539 | |
540 | |
541 /** | |
542 * Draw a slice (16 rows of image) to the SDL YUV overlay. | |
543 * | |
544 * params : *src[] == the Y, U, and V planes that make up the slice. | |
545 * returns : non-zero on error, zero on success. | |
546 **/ | |
547 | |
548 //static uint32_t draw_slice(uint8_t *src[], uint32_t slice_num) | |
549 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
550 { | |
551 struct sdl_priv_s *priv = &sdl_priv; | |
552 uint8_t *dst; | |
553 uint8_t *src; | |
554 int i; | |
555 | |
556 //priv->current_frame = priv->overlay; | |
557 | |
558 if (SDL_LockYUVOverlay (priv->overlay)) { | |
559 // LOG (LOG_ERROR, "SDL video out: Couldn't lock SDL-based YUV overlay"); | |
560 return -1; | |
561 } | |
562 | |
563 dst = (uint8_t *) *(priv->overlay->pixels) | |
564 + (priv->stridePlaneY * y + x); | |
565 src = image[0]; | |
566 for(i=0;i<h;i++){ | |
567 memcpy(dst,src,w); | |
568 src+=stride[0]; | |
569 dst+=priv->stridePlaneY; | |
570 } | |
571 | |
572 x/=2;y/=2;w/=2;h/=2; | |
573 | |
574 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY | |
575 + (priv->stridePlaneUV * y + x); | |
576 src = image[2]; | |
577 for(i=0;i<h;i++){ | |
578 memcpy(dst,src,w); | |
579 src+=stride[2]; | |
580 dst+=priv->stridePlaneUV; | |
581 } | |
582 | |
583 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY | |
584 + priv->framePlaneUV + (priv->stridePlaneUV * y + x); | |
585 src = image[1]; | |
586 for(i=0;i<h;i++){ | |
587 memcpy(dst,src,w); | |
588 src+=stride[1]; | |
589 dst+=priv->stridePlaneUV; | |
590 } | |
591 | |
592 #if 0 | |
593 dst = (uint8_t *) *(priv->overlay->pixels) + (priv->slicePlaneY * slice_num); | |
594 memcpy (dst, src[0], priv->slicePlaneY); | |
595 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY + (priv->slicePlaneUV * slice_num); | |
596 memcpy (dst, src[2], priv->slicePlaneUV); | |
597 dst += priv->framePlaneUV; | |
598 memcpy (dst, src[1], priv->slicePlaneUV); | |
599 #endif | |
600 | |
601 SDL_UnlockYUVOverlay (priv->overlay); | |
602 | |
603 return 0; | |
604 } | |
605 | |
606 | |
607 | |
608 /** | |
609 * Checks for SDL keypress and window resize events | |
610 * | |
611 * params : none | |
612 * returns : doesn't return | |
613 **/ | |
614 | |
615 #include "../linux/keycodes.h" | |
616 extern void mplayer_put_key(int code); | |
617 | |
618 static void check_events (void) | |
619 { | |
620 struct sdl_priv_s *priv = &sdl_priv; | |
621 SDL_Event event; | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
622 SDLKey keypressed = 0; |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
623 static int firstcheck = 0; |
1 | 624 |
625 /* Poll the waiting SDL Events */ | |
626 while ( SDL_PollEvent(&event) ) { | |
627 switch (event.type) { | |
628 | |
629 /* capture window resize events */ | |
630 case SDL_VIDEORESIZE: | |
631 priv->surface = SDL_SetVideoMode(event.resize.w, event.resize.h, priv->bpp, priv->sdlflags); | |
632 | |
633 /* save video extents, to restore them after going fullscreen */ | |
634 //if(!(priv->surface->flags & SDL_FULLSCREEN)) { | |
635 priv->windowsize.w = priv->surface->w; | |
636 priv->windowsize.h = priv->surface->h; | |
637 //} | |
638 // LOG (LOG_DEBUG, "SDL video out: Window resize"); | |
639 break; | |
640 | |
641 | |
642 /* graphics mode selection shortcuts */ | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
643 case SDL_KEYUP: |
1 | 644 keypressed = event.key.keysym.sym; |
265
1d02e6f7c63a
Only small change to allow pausing of movie (p or SPACE).
atmosfear
parents:
97
diff
changeset
|
645 |
357 | 646 /* c key pressed. c cycles through available fullscreenmodes, if we have some */ |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
647 if ( ((keypressed == SDLK_c)) && (priv->fullmodes) ) { |
1 | 648 /* select next fullscreen mode */ |
649 priv->fullmode++; | |
650 if (priv->fullmode > (findArrayEnd(priv->fullmodes) - 1)) priv->fullmode = 0; | |
651 set_fullmode(priv->fullmode); | |
652 | |
653 // LOG (LOG_DEBUG, "SDL video out: Set next available fullscreen mode."); | |
654 } | |
655 | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
656 /* f key pressed toggles/exits fullscreenmode */ |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
657 else if ( keypressed == SDLK_f ) { |
265
1d02e6f7c63a
Only small change to allow pausing of movie (p or SPACE).
atmosfear
parents:
97
diff
changeset
|
658 if (priv->surface->flags & SDL_FULLSCREEN) { |
1 | 659 priv->surface = SDL_SetVideoMode(priv->windowsize.w, priv->windowsize.h, priv->bpp, priv->sdlflags); |
660 SDL_ShowCursor(1); | |
661 // LOG (LOG_DEBUG, "SDL video out: Windowed mode"); | |
662 } | |
663 else if (priv->fullmodes){ | |
664 set_fullmode(priv->fullmode); | |
665 | |
666 // LOG (LOG_DEBUG, "SDL video out: Set fullscreen mode."); | |
667 } | |
668 } | |
669 | |
670 else switch(keypressed){ | |
671 // case SDLK_q: if(!(priv->surface->flags & SDL_FULLSCREEN))mplayer_put_key('q');break; | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
672 case SDLK_RETURN: |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
673 if (!firstcheck) { firstcheck = 1; break; } |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
674 case SDLK_ESCAPE: |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
675 case SDLK_q: |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
676 SDL_ShowCursor(1); |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
677 mplayer_put_key('q'); |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
678 break; |
475
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
679 /*case SDLK_o: mplayer_put_key('o');break; |
575
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
680 case SDLK_SPACE: mplayer_put_key(' ');break; |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
681 case SDLK_p: mplayer_put_key('p');break;*/ |
1 | 682 case SDLK_UP: mplayer_put_key(KEY_UP);break; |
683 case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break; | |
684 case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break; | |
685 case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break; | |
575
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
686 case SDLK_PLUS: |
1 | 687 case SDLK_KP_PLUS: mplayer_put_key('+');break; |
688 case SDLK_MINUS: | |
575
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
689 case SDLK_KP_MINUS: mplayer_put_key('-');break; |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
690 case SDLK_ASTERISK: |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
691 case SDLK_KP_MULTIPLY: |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
692 case SDLK_w: mplayer_put_key('*');break; |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
693 case SDLK_SLASH: |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
694 case SDLK_KP_DIVIDE: |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
695 case SDLK_s: mplayer_put_key('/');break; |
475
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
696 default: |
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
697 mplayer_put_key(keypressed); |
1 | 698 } |
699 | |
700 break; | |
701 } | |
702 } | |
703 } | |
704 | |
705 | |
706 /** | |
707 * Display the surface we have written our data to and check for events. | |
708 * | |
709 * params : mode == index of the desired fullscreen mode | |
710 * returns : doesn't return | |
711 **/ | |
712 | |
713 static void flip_page (void) | |
714 { | |
715 struct sdl_priv_s *priv = &sdl_priv; | |
716 | |
351 | 717 //vo_draw_alpha_yuy2(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride) |
718 vo_draw_text(priv->width,priv->height,draw_alpha); | |
719 | |
1 | 720 /* check and react on keypresses and window resizes */ |
721 check_events(); | |
722 | |
723 /* blit to the YUV overlay */ | |
724 SDL_DisplayYUVOverlay (priv->overlay, &priv->surface->clip_rect); | |
725 | |
726 /* check if we have a double buffered surface and flip() if we do. */ | |
727 if ( priv->surface->flags & SDL_DOUBLEBUF ) | |
728 SDL_Flip(priv->surface); | |
729 | |
730 SDL_LockYUVOverlay (priv->overlay); | |
731 } | |
732 | |
733 #if 0 | |
734 static frame_t* sdl_allocate_image_buffer(int width, int height) | |
735 { | |
736 struct sdl_priv_s *priv = &sdl_priv; | |
737 frame_t *frame; | |
738 | |
739 if (!(frame = malloc (sizeof (frame_t)))) | |
740 return NULL; | |
741 | |
742 if (!(frame->private = (void*) SDL_CreateYUVOverlay (width, height, | |
743 SDL_IYUV_OVERLAY, priv->surface))) | |
744 { | |
745 // LOG (LOG_ERROR, "SDL video out: Couldn't create an SDL-based YUV overlay"); | |
746 return NULL; | |
747 } | |
748 | |
749 frame->base[0] = (uint8_t*) ((SDL_Overlay*) (frame->private))->pixels[0]; | |
750 frame->base[1] = (uint8_t*) ((SDL_Overlay*) (frame->private))->pixels[1]; | |
751 frame->base[2] = (uint8_t*) ((SDL_Overlay*) (frame->private))->pixels[2]; | |
752 | |
753 SDL_LockYUVOverlay ((SDL_Overlay*) frame->private); | |
754 return frame; | |
755 } | |
756 | |
757 static void sdl_free_image_buffer(frame_t* frame) | |
758 { | |
759 SDL_FreeYUVOverlay((SDL_Overlay*) frame->private); | |
760 free(frame); | |
761 } | |
762 #endif | |
763 | |
764 static uint32_t | |
765 query_format(uint32_t format) | |
766 { | |
767 switch(format){ | |
768 case IMGFMT_YV12: | |
408 | 769 case IMGFMT_I420: |
770 case IMGFMT_IYUV: | |
1 | 771 case IMGFMT_YUY2: |
408 | 772 case IMGFMT_UYVY: |
773 case IMGFMT_YVYU: | |
1 | 774 // case IMGFMT_RGB|24: |
775 // case IMGFMT_BGR|24: | |
776 return 1; | |
777 } | |
778 return 0; | |
779 } | |
780 | |
781 static const vo_info_t* | |
782 get_info(void) | |
783 { | |
784 return &vo_info; | |
785 } | |
786 | |
787 | |
788 static void | |
789 uninit(void) | |
790 { | |
791 sdl_close(); | |
792 } | |
793 |