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