Mercurial > mplayer.hg
annotate libvo/vo_sdl.c @ 8698:739ecaea201b
fix compilation on solaris
author | attila |
---|---|
date | Wed, 01 Jan 2003 15:55:49 +0000 |
parents | a8128852c18d |
children | cecb561fcb21 |
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 * | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
8 * Copyright (C) Felix Buenemann <atmosfear@users.sourceforge.net> - 2001 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
9 * |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
10 * (for extensive code enhancements) |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
11 * |
579 | 12 * Current maintainer for MPlayer project (report bugs to that address): |
13 * Felix Buenemann <atmosfear@users.sourceforge.net> | |
14 * | |
15 * This file is a video out driver using the SDL library (http://libsdl.org/), | |
580 | 16 * to be used with MPlayer [The Movie Player for Linux] project, further info |
579 | 17 * from http://mplayer.sourceforge.net. |
18 * | |
19 * Current license is not decided yet, but we're heading for GPL. | |
20 * | |
21 * -- old disclaimer -- | |
22 * | |
1 | 23 * A mpeg2dec display driver that does output through the |
24 * Simple DirectMedia Layer (SDL) library. This effectively gives us all | |
25 * sorts of output options: X11, SVGAlib, fbcon, AAlib, GGI. Win32, MacOS | |
26 * and BeOS support, too. Yay. SDL info, source, and binaries can be found | |
27 * at http://slouken.devolution.com/SDL/ | |
28 * | |
29 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
30 * | |
31 * mpeg2dec is free software; you can redistribute it and/or modify | |
32 * it under the terms of the GNU General Public License as published by | |
33 * the Free Software Foundation; either version 2, or (at your option) | |
34 * any later version. | |
35 * | |
36 * mpeg2dec is distributed in the hope that it will be useful, | |
37 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
39 * GNU General Public License for more details. | |
40 * | |
41 * You should have received a copy of the GNU General Public License | |
42 * along with GNU Make; see the file COPYING. If not, write to | |
579 | 43 * the Free Software Foundation. |
44 * | |
45 * -- end old disclaimer -- | |
1 | 46 * |
47 * Changes: | |
48 * Dominik Schnitzer <dominik@schnitzer.at> - November 08, 2000. | |
84 | 49 * - Added resizing support, fullscreen: changed the sdlmodes selection |
1 | 50 * routine. |
51 * - SDL bugfixes: removed the atexit(SLD_Quit), SDL_Quit now resides in | |
52 * the plugin_exit routine. | |
53 * - Commented the source :) | |
54 * - Shortcuts: for switching between Fullscreen/Windowed mode and for | |
55 * cycling between the different Fullscreen modes. | |
56 * - Small bugfixes: proper width/height of movie | |
57 * Dominik Schnitzer <dominik@schnitzer.at> - November 11, 2000. | |
58 * - Cleanup code, more comments | |
59 * - Better error handling | |
60 * Bruno Barreyra <barreyra@ufl.edu> - December 10, 2000. | |
61 * - Eliminated memcpy's for entire frames | |
579 | 62 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 11, 2001 |
84 | 63 * - Added aspect-ratio awareness for fullscreen |
579 | 64 * 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
|
65 * - 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
|
66 * 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
|
67 * 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
|
68 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 12, 2001 |
579 | 69 * - 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
|
70 * - 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
|
71 * fullscreen-mode |
351 | 72 * 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
|
73 * - 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
|
74 * 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
|
75 * - 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
|
76 * - 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
|
77 * 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
|
78 * recommed) |
351 | 79 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 11, 2001 |
80 * - OSD and subtitle support added | |
81 * - some minor code-changes | |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
82 * - added code to comply with new fullscreen meaning |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
83 * - changed fullscreen-mode-cycling from '+' to 'c' (interferred with audiosync |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
84 * adjustment) |
386 | 85 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 13, 2001 |
86 * - 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
|
87 * - 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
|
88 * |
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
89 * Felix Buenemann: further changes will be visible through cvs log, don't want |
579 | 90 * to update this all the time (CVS info on http://mplayer.sourceforge.net) |
91 * | |
1 | 92 */ |
93 | |
542
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 |
1197 | 97 /* define to enable surface locks, this might be needed on SMP machines */ |
98 #undef SDL_ENABLE_LOCKS | |
99 | |
705
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
100 //#define BUGGY_SDL //defined by configure |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
101 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
102 /* MONITOR_ASPECT MUST BE FLOAT */ |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
103 #define MONITOR_ASPECT 4.0/3.0 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
104 |
1 | 105 #include <stdio.h> |
106 #include <stdlib.h> | |
107 #include <string.h> | |
108 #include <inttypes.h> | |
109 | |
1100
7829676dc4ef
Ooops, wrong path to config.h - now you may enjoy code that was never before used =)
atmosfear
parents:
1080
diff
changeset
|
110 #include "../config.h" |
1 | 111 #include "video_out.h" |
112 #include "video_out_internal.h" | |
113 | |
354 | 114 #include "fastmemcpy.h" |
616 | 115 #include "sub.h" |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
1710
diff
changeset
|
116 #include "aspect.h" |
5894
af9efcb80244
Use new style query_formats flags. Fixes bug with flip.
ksorim
parents:
5834
diff
changeset
|
117 #include "libmpcodecs/vfcap.h" |
350 | 118 |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
119 #ifdef HAVE_X11 |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
120 #include <X11/Xlib.h> |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
121 #include "x11_common.h" |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
122 #endif |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
123 |
4590
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
124 #include "../input/input.h" |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
125 #include "../input/mouse.h" |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
126 |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
127 extern int verbose; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
128 int sdl_noxv; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
129 int sdl_forcexv; |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
130 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8123
diff
changeset
|
131 static vo_info_t info = |
1 | 132 { |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
133 "SDL YUV/RGB/BGR renderer (SDL v1.1.7+ only!)", |
1 | 134 "sdl", |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
135 "Ryan C. Gordon <icculus@lokigames.com>, Felix Buenemann <atmosfear@users.sourceforge.net>", |
1 | 136 "" |
137 }; | |
138 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8123
diff
changeset
|
139 LIBVO_EXTERN(sdl) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8123
diff
changeset
|
140 |
1238 | 141 #include <SDL.h> |
3609
c9876f5f4ac5
better fullscreen-mode selection, patch by dunno :)
atmos4
parents:
2249
diff
changeset
|
142 //#include <SDL/SDL_syswm.h> |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
143 |
6956
0380dfad2db9
HPUX porting fixes - patch by Gansser, Martin <MGansser@rand.de>
arpi
parents:
6440
diff
changeset
|
144 #if defined(HPUX) || defined(sun) && defined(__svr4__) |
0380dfad2db9
HPUX porting fixes - patch by Gansser, Martin <MGansser@rand.de>
arpi
parents:
6440
diff
changeset
|
145 /* setenv is missing on solaris and HPUX */ |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
146 static void setenv(const char *name, const char *val, int _xx) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
147 { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
148 int len = strlen(name) + strlen(val) + 2; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
149 char *env = malloc(len); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
150 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
151 if (env != NULL) { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
152 strcpy(env, name); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
153 strcat(env, "="); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
154 strcat(env, val); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
155 putenv(env); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
156 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
157 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
158 #endif |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
159 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
973
diff
changeset
|
160 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
161 #define FS 0x01 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
162 #define VM 0x02 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
163 #define ZOOM 0x04 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
164 #define FLIP 0x08 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
165 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
166 #ifdef SDL_ENABLE_LOCKS |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
167 #define SDL_OVR_LOCK(x) if (SDL_LockYUVOverlay (priv->overlay)) { \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
168 if(verbose) printf("SDL: Couldn't lock YUV overlay\n"); \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
169 return x; \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
170 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
171 #define SDL_OVR_UNLOCK SDL_UnlockYUVOverlay (priv->overlay); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
172 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
173 #define SDL_SRF_LOCK(srf, x) if(SDL_MUSTLOCK(srf)) { \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
174 if(SDL_LockSurface (srf)) { \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
175 if(verbose) printf("SDL: Couldn't lock RGB surface\n"); \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
176 return x; \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
177 } \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
178 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
179 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
180 #define SDL_SRF_UNLOCK(srf) if(SDL_MUSTLOCK(srf)) \ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
181 SDL_UnlockSurface (srf); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
182 #else |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
183 #define SDL_OVR_LOCK(x) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
184 #define SDL_OVR_UNLOCK |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
185 #define SDL_SRF_LOCK(srf, x) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
186 #define SDL_SRF_UNLOCK(srf) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
187 #endif |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
188 |
1 | 189 /** Private SDL Data structure **/ |
190 | |
191 static struct sdl_priv_s { | |
192 | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
193 /* output driver used by sdl */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
194 char driver[8]; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
195 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
196 /* SDL display surface */ |
1 | 197 SDL_Surface *surface; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
198 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
199 /* SDL RGB surface */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
200 SDL_Surface *rgbsurface; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
201 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
202 /* SDL YUV overlay */ |
1 | 203 SDL_Overlay *overlay; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
204 |
1 | 205 /* available fullscreen modes */ |
206 SDL_Rect **fullmodes; | |
207 | |
208 /* surface attributes for fullscreen and windowed mode */ | |
209 Uint32 sdlflags, sdlfullflags; | |
210 | |
211 /* save the windowed output extents */ | |
212 SDL_Rect windowsize; | |
213 | |
214 /* Bits per Pixel */ | |
215 Uint8 bpp; | |
216 | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
217 /* RGB or YUV? */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
218 Uint8 mode; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
219 #define YUV 0 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
220 #define RGB 1 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
221 #define BGR 2 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
222 |
1219
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
223 /* use direct blitting to surface */ |
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
224 int dblit; |
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
225 |
1 | 226 /* current fullscreen mode, 0 = highest available fullscreen mode */ |
227 int fullmode; | |
228 | |
229 /* YUV ints */ | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
230 int framePlaneY, framePlaneUV, framePlaneYUY; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
231 int stridePlaneY, stridePlaneUV, stridePlaneYUY; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
232 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
233 /* RGB ints */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
234 int framePlaneRGB; |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
235 int stridePlaneRGB; |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
236 |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
237 /* Flip image */ |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
238 int flip; |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
239 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
240 /* fullscreen behaviour; see init */ |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
241 int fulltype; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
242 |
951 | 243 /* is X running (0/1) */ |
244 int X; | |
245 | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
246 /* X11 Resolution */ |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
247 int XWidth, XHeight; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
248 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
249 /* original image dimensions */ |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
250 int width, height; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
251 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
252 /* destination dimensions */ |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
253 int dstwidth, dstheight; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
254 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
255 /* Draw image at coordinate y on the SDL surfaces */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
256 int y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
257 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
258 /* The image is displayed between those y coordinates in priv->surface */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
259 int y_screen_top, y_screen_bottom; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
260 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
261 /* 1 if the OSD has changed otherwise 0 */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
262 int osd_has_changed; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
263 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
264 /* source image format (YUV/RGB/...) */ |
5058 | 265 uint32_t format; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
266 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
267 /* dirty_off_frame[0] contains a bounding box around the osd contents drawn above the image |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
268 dirty_off_frame[1] is the corresponding thing for OSD contents drawn below the image |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
269 */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
270 SDL_Rect dirty_off_frame[2]; |
1 | 271 } sdl_priv; |
272 | |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
273 static void erase_area_4(int x_start, int width, int height, int pitch, uint32_t color, uint8_t* pixels); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
274 static void erase_area_1(int x_start, int width, int height, int pitch, uint8_t color, uint8_t* pixels); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
275 static int setup_surfaces(void); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
276 static void set_video_mode(int width, int height, int bpp, uint32_t sdlflags); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
277 static void erase_rectangle(int x, int y, int w, int h); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
278 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
279 /* Expand 'rect' to contain the rectangle specified by x, y, w and h */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
280 static void expand_rect(SDL_Rect* rect, int x, int y, int w, int h) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
281 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
282 if(rect->x < 0 || rect->y < 0) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
283 rect->x = x; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
284 rect->y = y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
285 rect->w = w; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
286 rect->h = h; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
287 return; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
288 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
289 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
290 if(rect->x > x) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
291 rect->x = x; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
292 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
293 if(rect->y > y) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
294 rect->y = y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
295 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
296 if(rect->x + rect->w < x + w) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
297 rect->w = x + w - rect->x; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
298 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
299 if(rect->y + rect->h < y + h) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
300 rect->h = y + h - rect->y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
301 } |
1 | 302 |
351 | 303 /** libvo Plugin functions **/ |
304 | |
305 /** | |
306 * draw_alpha is used for osd and subtitle display. | |
307 * | |
308 **/ | |
309 | |
310 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | |
408 | 311 struct sdl_priv_s *priv = &sdl_priv; |
351 | 312 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
313 if(priv->osd_has_changed) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
314 /* OSD did change. Store a bounding box of everything drawn into the OSD */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
315 if(priv->y >= y0) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
316 /* Make sure we don't mark part of the frame area dirty */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
317 if(h + y0 > priv->y) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
318 expand_rect(&priv->dirty_off_frame[0], x0, y0, w, priv->y - y0); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
319 else |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
320 expand_rect(&priv->dirty_off_frame[0], x0, y0, w, h); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
321 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
322 else if(priv->y + priv->height <= y0 + h) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
323 /* Make sure we don't mark part of the frame area dirty */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
324 if(y0 < priv->y + priv->height) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
325 expand_rect(&priv->dirty_off_frame[1], x0, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
326 priv->y + priv->height, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
327 w, h - ((priv->y + priv->height) - y0)); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
328 else |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
329 expand_rect(&priv->dirty_off_frame[1], x0, y0, w, h); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
330 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
331 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
332 else { /* OSD contents didn't change only draw parts that was erased by the frame */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
333 if(priv->y >= y0) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
334 src = src + (priv->y - y0) * stride; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
335 srca = srca + (priv->y - y0) * stride; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
336 h -= priv->y - y0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
337 y0 = priv->y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
338 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
339 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
340 if(priv->y + priv->height <= y0 + h) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
341 h = priv->y + priv->height - y0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
342 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
343 if(h <= 0) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
344 return; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
345 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
346 |
408 | 347 switch(priv->format) { |
348 case IMGFMT_YV12: | |
349 case IMGFMT_I420: | |
350 case IMGFMT_IYUV: | |
5260 | 351 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); |
408 | 352 break; |
353 case IMGFMT_YUY2: | |
5260 | 354 case IMGFMT_YVYU: |
355 x0 *= 2; | |
356 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); | |
408 | 357 break; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
358 case IMGFMT_UYVY: |
5260 | 359 x0 *= 2; |
360 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->overlay->pitches[0]*y0+x0,priv->overlay->pitches[0]); | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
361 break; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
362 |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
363 default: |
5260 | 364 if(priv->dblit) { |
365 x0 *= priv->surface->format->BytesPerPixel; | |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
366 switch(priv->format) { |
823
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
367 case IMGFMT_RGB15: |
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
368 case IMGFMT_BGR15: |
5260 | 369 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); |
823
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
370 break; |
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
371 case IMGFMT_RGB16: |
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
372 case IMGFMT_BGR16: |
5260 | 373 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); |
823
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
374 break; |
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
375 case IMGFMT_RGB24: |
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
376 case IMGFMT_BGR24: |
5260 | 377 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); |
823
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
378 break; |
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
379 case IMGFMT_RGB32: |
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
380 case IMGFMT_BGR32: |
5260 | 381 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+y0*priv->surface->pitch+x0,priv->surface->pitch); |
823
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
382 break; |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
383 } |
5260 | 384 } |
385 else { | |
386 x0 *= priv->rgbsurface->format->BytesPerPixel; | |
387 switch(priv->format) { | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
388 case IMGFMT_RGB15: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
389 case IMGFMT_BGR15: |
5260 | 390 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
391 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
392 case IMGFMT_RGB16: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
393 case IMGFMT_BGR16: |
5260 | 394 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
395 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
396 case IMGFMT_RGB24: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
397 case IMGFMT_BGR24: |
5260 | 398 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
399 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
400 case IMGFMT_RGB32: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
401 case IMGFMT_BGR32: |
5260 | 402 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+y0*priv->rgbsurface->pitch+x0,priv->rgbsurface->pitch); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
403 break; |
5260 | 404 } |
405 } | |
406 | |
408 | 407 } |
351 | 408 } |
1 | 409 |
410 | |
411 /** | |
412 * Take a null-terminated array of pointers, and find the last element. | |
413 * | |
414 * params : array == array of which we want to find the last element. | |
415 * returns : index of last NON-NULL element. | |
416 **/ | |
417 | |
418 static inline int findArrayEnd (SDL_Rect **array) | |
419 { | |
420 int i = 0; | |
421 while ( array[i++] ); /* keep loopin' ... */ | |
422 | |
423 /* return the index of the last array element */ | |
424 return i - 1; | |
425 } | |
426 | |
427 | |
428 /** | |
429 * Open and prepare SDL output. | |
430 * | |
431 * params : *plugin == | |
432 * *name == | |
433 * returns : 0 on success, -1 on failure | |
434 **/ | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
435 |
1 | 436 static int sdl_open (void *plugin, void *name) |
437 { | |
438 struct sdl_priv_s *priv = &sdl_priv; | |
439 const SDL_VideoInfo *vidInfo = NULL; | |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
440 /*static int opened = 0; |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
441 |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
442 if (opened) |
1 | 443 return 0; |
4528
bd2324553533
Fix multifile playback (sdl was not fully reinitialized).
atmos4
parents:
4433
diff
changeset
|
444 opened = 1;*/ |
1 | 445 |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
446 if(verbose > 2) printf("SDL: Opening Plugin\n"); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
447 |
1188 | 448 if(vo_subdevice) setenv("SDL_VIDEODRIVER", vo_subdevice, 1); |
351 | 449 |
450 /* does the user want SDL to try and force Xv */ | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
451 if(sdl_forcexv) setenv("SDL_VIDEO_X11_NODIRECTCOLOR", "1", 1); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
452 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
453 /* does the user want to disable Xv and use software scaling instead */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
454 if(sdl_noxv) setenv("SDL_VIDEO_YUV_HWACCEL", "0", 1); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
455 |
1 | 456 |
84 | 457 /* default to no fullscreen mode, we'll set this as soon we have the avail. modes */ |
5240 | 458 priv->fullmode = -2; |
459 | |
460 priv->fullmodes = NULL; | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
461 priv->bpp = 0; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
462 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
463 /* initialize the SDL Video system */ |
5240 | 464 if (!SDL_WasInit(SDL_INIT_VIDEO)) { |
465 if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)) { | |
466 printf("SDL: Initializing of SDL failed: %s.\n", SDL_GetError()); | |
467 return -1; | |
468 } | |
469 } | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
470 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
471 SDL_VideoDriverName(priv->driver, 8); |
1080 | 472 printf("SDL: Using driver: %s\n", priv->driver); |
1 | 473 /* other default values */ |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
474 #ifdef SDL_NOHWSURFACE |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
475 if(verbose) printf("SDL: using software-surface\n"); |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
476 priv->sdlflags = SDL_SWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_ANYFORMAT; |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
477 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_ANYFORMAT; |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
478 #else |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
479 /*if((strcmp(priv->driver, "dga") == 0) && (priv->mode)) { |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
480 if(verbose) printf("SDL: using software-surface\n"); |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
481 priv->sdlflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT; |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
482 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
483 } |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
484 else { */ |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
485 if(verbose) printf("SDL: using hardware-surface\n"); |
1219
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
486 priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL/*|SDL_ANYFORMAT*/; |
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
487 priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_HWACCEL/*|SDL_ANYFORMAT*/; |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
488 //} |
394
f4fb35ef4c06
- added some defines to modify some sdl-out internas (see comments)
atmosfear
parents:
386
diff
changeset
|
489 #endif |
1 | 490 |
7111 | 491 if (vo_doublebuffering) |
492 priv->sdlflags |= SDL_DOUBLEBUF; | |
493 | |
703
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
494 /* Setup Keyrepeats (500/30 are defaults) */ |
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
495 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/); |
1 | 496 |
497 /* get information about the graphics adapter */ | |
498 vidInfo = SDL_GetVideoInfo (); | |
499 | |
500 /* collect all fullscreen & hardware modes available */ | |
501 if (!(priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags))) { | |
502 | |
503 /* non hardware accelerated fullscreen modes */ | |
504 priv->sdlfullflags &= ~SDL_HWSURFACE; | |
505 priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags); | |
506 } | |
507 | |
508 /* test for normal resizeable & windowed hardware accellerated surfaces */ | |
509 if (!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) { | |
510 | |
511 /* test for NON hardware accelerated resizeable surfaces - poor you. | |
512 * That's all we have. If this fails there's nothing left. | |
513 * Theoretically there could be Fullscreenmodes left - we ignore this for now. | |
514 */ | |
515 priv->sdlflags &= ~SDL_HWSURFACE; | |
516 if ((!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) && (!priv->fullmodes)) { | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
517 printf("SDL: Couldn't get any acceptable SDL Mode for output.\n"); |
1 | 518 return -1; |
519 } | |
520 } | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
521 |
1 | 522 |
523 /* YUV overlays need at least 16-bit color depth, but the | |
524 * display might less. The SDL AAlib target says it can only do | |
525 * 8-bits, for example. So, if the display is less than 16-bits, | |
526 * we'll force the BPP to 16, and pray that SDL can emulate for us. | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
527 */ |
1 | 528 priv->bpp = vidInfo->vfmt->BitsPerPixel; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
529 if (priv->mode == YUV && priv->bpp < 16) { |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
530 |
5240 | 531 if(verbose) printf("SDL: Your SDL display target wants to be at a color " |
532 "depth of (%d), but we need it to be at least 16 " | |
533 "bits, so we need to emulate 16-bit color. This is " | |
534 "going to slow things down; you might want to " | |
535 "increase your display's color depth, if possible.\n", | |
536 priv->bpp); | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
537 |
1 | 538 priv->bpp = 16; |
539 } | |
540 | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
541 /* We don't want those in our event queue. |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
542 * We use SDL_KEYUP cause SDL_KEYDOWN seems to cause problems |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
543 * with keys need to be pressed twice, to be recognized. |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
544 */ |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
545 #ifndef BUGGY_SDL |
770
0e549c933515
Got rid of aalib crashing workaround with SDL1.2.1+
atmosfear
parents:
705
diff
changeset
|
546 SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); |
1 | 547 SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); |
1710 | 548 // SDL_EventState(SDL_QUIT, SDL_IGNORE); |
1 | 549 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); |
770
0e549c933515
Got rid of aalib crashing workaround with SDL1.2.1+
atmosfear
parents:
705
diff
changeset
|
550 SDL_EventState(SDL_USEREVENT, SDL_IGNORE); |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
551 #endif |
1 | 552 |
553 /* Success! */ | |
554 return 0; | |
555 } | |
556 | |
557 | |
558 /** | |
559 * Close SDL, Cleanups, Free Memory | |
560 * | |
561 * params : *plugin | |
562 * returns : non-zero on success, zero on error. | |
563 **/ | |
564 | |
565 static int sdl_close (void) | |
566 { | |
567 struct sdl_priv_s *priv = &sdl_priv; | |
568 | |
569 /* Cleanup YUV Overlay structure */ | |
570 if (priv->overlay) | |
571 SDL_FreeYUVOverlay(priv->overlay); | |
572 | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
573 /* Free RGB Surface */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
574 if (priv->rgbsurface) |
1126 | 575 SDL_FreeSurface(priv->rgbsurface); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
576 |
1 | 577 /* Free our blitting surface */ |
578 if (priv->surface) | |
579 SDL_FreeSurface(priv->surface); | |
580 | |
351 | 581 /* DONT attempt to free the fullscreen modes array. SDL_Quit* does this for us */ |
1 | 582 |
583 /* Cleanup SDL */ | |
5240 | 584 if(SDL_WasInit(SDL_INIT_VIDEO)) |
585 SDL_QuitSubSystem(SDL_INIT_VIDEO); | |
351 | 586 |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
587 if(verbose > 2) printf("SDL: Closed Plugin\n"); |
1 | 588 |
589 return 0; | |
590 } | |
591 | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
592 /** |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
593 * Do aspect ratio calculations |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
594 * |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
595 * params : srcw == sourcewidth |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
596 * srch == sourceheight |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
597 * dstw == destinationwidth |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
598 * dsth == destinationheight |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
599 * |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
600 * returns : SDL_Rect structure with new x and y, w and h |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
601 **/ |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
602 |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
1710
diff
changeset
|
603 #if 0 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
604 static SDL_Rect aspect(int srcw, int srch, int dstw, int dsth) { |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
605 SDL_Rect newres; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
606 if(verbose > 1) printf("SDL Aspect: src: %ix%i dst: %ix%i\n", srcw, srch, dstw, dsth); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
607 newres.h = ((float)dstw / (float)srcw * (float)srch) * ((float)dsth/((float)dstw/(MONITOR_ASPECT))); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
608 if(newres.h > dsth) { |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
609 newres.w = ((float)dsth / (float)newres.h) * dstw; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
610 newres.h = dsth; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
611 newres.x = (dstw - newres.w) / 2; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
612 newres.y = 0; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
613 } |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
614 else { |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
615 newres.w = dstw; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
616 newres.x = 0; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
617 newres.y = (dsth - newres.h) / 2; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
618 } |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
619 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
620 if(verbose) printf("SDL Aspect-Destinationres: %ix%i (x: %i, y: %i)\n", newres.w, newres.h, newres.x, newres.y); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
621 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
622 return newres; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
623 } |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
1710
diff
changeset
|
624 #endif |
1 | 625 |
626 /** | |
627 * Sets the specified fullscreen mode. | |
628 * | |
629 * params : mode == index of the desired fullscreen mode | |
630 * returns : doesn't return | |
631 **/ | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
632 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
633 #if 0 |
1 | 634 static void set_fullmode (int mode) |
635 { | |
636 struct sdl_priv_s *priv = &sdl_priv; | |
637 SDL_Surface *newsurface = NULL; | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
638 int haspect, waspect = 0; |
1 | 639 |
640 /* if we haven't set a fullmode yet, default to the lowest res fullmode first */ | |
641 if (mode < 0) | |
642 mode = priv->fullmode = findArrayEnd(priv->fullmodes) - 1; | |
643 | |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
644 /* Calculate proper aspect ratio for fullscreen |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
645 * 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
|
646 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
|
647 /* 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
|
648 if (haspect < 0) { |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
649 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
|
650 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
|
651 } |
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
652 // printf ("W-Aspect: %i H-Aspect: %i\n", waspect, haspect); |
84 | 653 |
97
cab74dfde6dd
Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents:
84
diff
changeset
|
654 /* 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
|
655 newsurface = SDL_SetVideoMode(priv->fullmodes[mode]->w - waspect, priv->fullmodes[mode]->h - haspect, priv->bpp, priv->sdlfullflags); |
1 | 656 |
657 /* if we were successfull hide the mouse cursor and save the mode */ | |
658 if (newsurface) { | |
1126 | 659 if (priv->surface) |
660 SDL_FreeSurface(priv->surface); | |
1 | 661 priv->surface = newsurface; |
662 SDL_ShowCursor(0); | |
663 } | |
664 } | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
665 #endif |
1 | 666 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
667 /* Set video mode. Not fullscreen */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
668 static void set_video_mode(int width, int height, int bpp, uint32_t sdlflags) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
669 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
670 struct sdl_priv_s *priv = &sdl_priv; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
671 SDL_Surface* newsurface; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
672 |
8149 | 673 if(priv->rgbsurface) |
674 SDL_FreeSurface(priv->rgbsurface); | |
675 else if(priv->overlay) | |
676 SDL_FreeYUVOverlay(priv->overlay); | |
677 | |
678 priv->rgbsurface = NULL; | |
679 priv->overlay = NULL; | |
680 | |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
681 newsurface = SDL_SetVideoMode(width, height, bpp, sdlflags); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
682 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
683 if(newsurface) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
684 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
685 /* priv->surface will be NULL the first time this function is called. */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
686 if(priv->surface) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
687 SDL_FreeSurface(priv->surface); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
688 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
689 priv->surface = newsurface; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
690 priv->dstwidth = width; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
691 priv->dstheight = height; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
692 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
693 setup_surfaces(); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
694 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
695 else |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
696 printf("set_video_mode: SDL_SetVideoMode failed: %s\n", SDL_GetError()); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
697 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
698 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
699 static void set_fullmode (int mode) { |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
700 struct sdl_priv_s *priv = &sdl_priv; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
701 SDL_Surface *newsurface = NULL; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
702 int screen_surface_w, screen_surface_h; |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
703 |
8149 | 704 if(priv->rgbsurface) |
705 SDL_FreeSurface(priv->rgbsurface); | |
706 else if(priv->overlay) | |
707 SDL_FreeYUVOverlay(priv->overlay); | |
708 | |
709 priv->rgbsurface = NULL; | |
710 priv->overlay = NULL; | |
711 | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
712 /* if we haven't set a fullmode yet, default to the lowest res fullmode first */ |
3609
c9876f5f4ac5
better fullscreen-mode selection, patch by dunno :)
atmos4
parents:
2249
diff
changeset
|
713 /* But select a mode where the full video enter */ |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
714 if(priv->X && priv->fulltype & FS) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
715 screen_surface_w = priv->XWidth; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
716 screen_surface_h = priv->XHeight; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
717 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
718 else if (mode < 0) { |
8054 | 719 int i,j,imax; |
3609
c9876f5f4ac5
better fullscreen-mode selection, patch by dunno :)
atmos4
parents:
2249
diff
changeset
|
720 mode = 0; // Default to the biggest mode avaible |
8054 | 721 if (verbose) for(i=0;priv->fullmodes[i];++i) |
722 printf("SDL Mode: %d: %d x %d\n", i, priv->fullmodes[i]->w, priv->fullmodes[i]->h); | |
3609
c9876f5f4ac5
better fullscreen-mode selection, patch by dunno :)
atmos4
parents:
2249
diff
changeset
|
723 for(i = findArrayEnd(priv->fullmodes) - 1; i >=0; i--) { |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
724 if( (priv->fullmodes[i]->w >= priv->dstwidth) && |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
725 (priv->fullmodes[i]->h >= priv->dstheight) ) { |
8054 | 726 imax = i; |
727 for (j = findArrayEnd(priv->fullmodes) - 1; j >=0; j--) { | |
728 if (priv->fullmodes[j]->w > priv->fullmodes[imax]->w | |
729 && priv->fullmodes[j]->h == priv->fullmodes[imax]->h) | |
730 imax = j; | |
731 } | |
732 mode = imax; | |
733 break; | |
734 } | |
3609
c9876f5f4ac5
better fullscreen-mode selection, patch by dunno :)
atmos4
parents:
2249
diff
changeset
|
735 } |
8054 | 736 if (verbose) printf("SET SDL Mode: %d: %d x %d\n", mode, priv->fullmodes[mode]->w, priv->fullmodes[mode]->h); |
3609
c9876f5f4ac5
better fullscreen-mode selection, patch by dunno :)
atmos4
parents:
2249
diff
changeset
|
737 priv->fullmode = mode; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
738 screen_surface_h = priv->fullmodes[mode]->h; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
739 screen_surface_w = priv->fullmodes[mode]->w; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
740 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
741 else { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
742 screen_surface_h = priv->fullmodes[mode]->h; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
743 screen_surface_w = priv->fullmodes[mode]->w; |
3609
c9876f5f4ac5
better fullscreen-mode selection, patch by dunno :)
atmos4
parents:
2249
diff
changeset
|
744 } |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
745 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
746 aspect_save_screenres(screen_surface_w, screen_surface_h); |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
747 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
748 /* calculate new video size/aspect */ |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
749 if(priv->mode == YUV) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
750 if(priv->fulltype&FS) |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
751 aspect_save_screenres(priv->XWidth, priv->XHeight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
752 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
753 aspect(&priv->dstwidth, &priv->dstheight, A_ZOOM); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
754 } |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
755 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
756 /* try to change to given fullscreenmode */ |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
757 newsurface = SDL_SetVideoMode(priv->dstwidth, screen_surface_h, priv->bpp, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
758 priv->sdlfullflags); |
7201
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
759 |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
760 /* |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
761 * In Mac OS X (and possibly others?) SDL_SetVideoMode() appears to |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
762 * destroy the datastructure previously retrived, so we need to |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
763 * re-assign it. The comment in sdl_close() seems to imply that we |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
764 * should not free() anything. |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
765 */ |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
766 #ifdef SYS_DARWIN |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
767 { |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
768 const SDL_VideoInfo *vidInfo = NULL; |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
769 vidInfo = SDL_GetVideoInfo (); |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
770 |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
771 /* collect all fullscreen & hardware modes available */ |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
772 if (!(priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags))) { |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
773 |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
774 /* non hardware accelerated fullscreen modes */ |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
775 priv->sdlfullflags &= ~SDL_HWSURFACE; |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
776 priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags); |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
777 } |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
778 } |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
779 #endif |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
780 |
22beff6edf75
Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp.
atmos4
parents:
7124
diff
changeset
|
781 |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
782 |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
783 /* if creation of new surface was successfull, save it and hide mouse cursor */ |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
784 if(newsurface) { |
1126 | 785 if (priv->surface) |
786 SDL_FreeSurface(priv->surface); | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
787 priv->surface = newsurface; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
788 SDL_ShowCursor(0); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
789 SDL_SRF_LOCK(priv->surface, -1) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
790 SDL_FillRect(priv->surface, NULL, 0); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
791 SDL_SRF_UNLOCK(priv->surface) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
792 setup_surfaces(); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
793 } |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
794 else |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
795 printf("set_fullmode: SDL_SetVideoMode failed: %s\n", SDL_GetError()); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
796 } |
1126 | 797 |
1 | 798 |
799 /** | |
800 * Initialize an SDL surface and an SDL YUV overlay. | |
801 * | |
802 * params : width == width of video we'll be displaying. | |
803 * height == height of video we'll be displaying. | |
804 * fullscreen == want to be fullscreen? | |
805 * title == Title for window titlebar. | |
806 * returns : non-zero on success, zero on error. | |
807 **/ | |
808 | |
809 static uint32_t | |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
7111
diff
changeset
|
810 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
1 | 811 //static int sdl_setup (int width, int height) |
812 { | |
813 struct sdl_priv_s *priv = &sdl_priv; | |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
814 #ifdef HAVE_X11 |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
815 static Display *XDisplay; |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
816 static int XScreen; |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
817 #endif |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
818 |
5239
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
819 switch(format){ |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
820 case IMGFMT_I420: |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
821 printf("SDL: Mapping I420 to IYUV\n"); |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
822 format = SDL_IYUV_OVERLAY; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
823 case IMGFMT_YV12: |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
824 case IMGFMT_IYUV: |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
825 case IMGFMT_YUY2: |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
826 case IMGFMT_UYVY: |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
827 case IMGFMT_YVYU: |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
828 priv->mode = YUV; |
5239
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
829 break; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
830 case IMGFMT_BGR15: |
5239
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
831 case IMGFMT_BGR16: |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
832 case IMGFMT_BGR24: |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
833 case IMGFMT_BGR32: |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
834 priv->mode = BGR; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
835 break; |
5239
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
836 case IMGFMT_RGB15: |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
837 case IMGFMT_RGB16: |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
838 case IMGFMT_RGB24: |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
839 case IMGFMT_RGB32: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
840 priv->mode = RGB; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
841 break; |
451
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
842 default: |
542
7eaec864e3d2
doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents:
475
diff
changeset
|
843 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
|
844 return -1; |
e27a365b0303
fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents:
448
diff
changeset
|
845 } |
5239
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
846 |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
847 if(verbose) printf("SDL: Using 0x%X (%s) image format\n", format, |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
848 vo_format_name(format)); |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
849 |
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
850 if(priv->mode != YUV) { |
1219
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
851 priv->sdlflags |= SDL_ANYFORMAT; |
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
852 priv->sdlfullflags |= SDL_ANYFORMAT; |
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
853 } |
1 | 854 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
855 /* SDL can only scale YUV data */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
856 if(priv->mode == RGB || priv->mode == BGR) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
857 d_width = width; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
858 d_height = height; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
859 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
860 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
861 aspect_save_orig(width,height); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
862 aspect_save_prescale(d_width ? d_width : width, d_height ? d_height : height); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
863 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
864 /* Save the original Image size */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
865 priv->X = 0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
866 priv->width = width; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
867 priv->height = height; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
868 priv->dstwidth = d_width ? d_width : width; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
869 priv->dstheight = d_height ? d_height : height; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
870 |
5239
fe6b890f68f2
Fix crash when playing multiple files. The bug was triggered when the first file
ksorim
parents:
5238
diff
changeset
|
871 priv->format = format; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
872 |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
873 #ifdef HAVE_X11 |
5267
e5f57c576c48
Fixes crash which occured when it wasn't possible to connect to the display
ksorim
parents:
5260
diff
changeset
|
874 XDisplay = XOpenDisplay(NULL); |
e5f57c576c48
Fixes crash which occured when it wasn't possible to connect to the display
ksorim
parents:
5260
diff
changeset
|
875 if(XDisplay) { |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
876 if(verbose) printf("SDL: deactivating XScreensaver/DPMS\n"); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
877 XScreen = DefaultScreen(XDisplay); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
878 priv->XWidth = DisplayWidth(XDisplay, XScreen); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
879 priv->XHeight = DisplayHeight(XDisplay, XScreen); |
951 | 880 priv->X = 1; |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
881 if(verbose) printf("SDL: X11 Resolution %ix%i\n", priv->XWidth, priv->XHeight); |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
882 saver_off(XDisplay); |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
883 XCloseDisplay(XDisplay); |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
884 } |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
885 #endif |
1080 | 886 if (sdl_open(NULL, NULL) != 0) |
887 return -1; | |
1 | 888 |
351 | 889 /* Set output window title */ |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
1710
diff
changeset
|
890 SDL_WM_SetCaption (".: MPlayer : F = Fullscreen/Windowed : C = Cycle Fullscreen Resolutions :.", title); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
891 //SDL_WM_SetCaption (title, title); |
351 | 892 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
893 if(priv->X) { |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
894 aspect_save_screenres(priv->XWidth,priv->XHeight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
895 aspect(&priv->dstwidth,&priv->dstheight,A_NOZOOM); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
896 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
897 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
898 priv->windowsize.w = priv->dstwidth; |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
899 priv->windowsize.h = priv->dstheight; |
1 | 900 |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
901 /* bit 0 (0x01) means fullscreen (-fs) |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
902 * bit 1 (0x02) means mode switching (-vm) |
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
903 * bit 2 (0x04) enables software scaling (-zoom) |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
904 * bit 3 (0x08) enables flipping (-flip) |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
905 */ |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
906 // printf("SDL: flags are set to: %i\n", flags); |
355
70833462dee9
- added code to comply with new fullscreen meaning
atmosfear
parents:
354
diff
changeset
|
907 // printf("SDL: Width: %i Height: %i D_Width %i D_Height: %i\n", width, height, d_width, d_height); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
908 if(flags&FLIP) { |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
909 if(verbose) printf("SDL: using flipped video (only with RGB/BGR/packed YUV)\n"); |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
910 priv->flip = 1; |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
911 } |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
912 if(flags&FS) { |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
913 if(verbose) printf("SDL: setting zoomed fullscreen without modeswitching\n"); |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
914 printf("SDL: Info - please use -vm or -zoom to switch to best resolution.\n"); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
915 priv->fulltype = FS; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
916 set_fullmode(priv->fullmode); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
917 /*if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags))) |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
918 SDL_ShowCursor(0);*/ |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
919 } else |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
920 if(flags&VM) { |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
921 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
922 priv->fulltype = VM; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
923 set_fullmode(priv->fullmode); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
924 /*if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags))) |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
925 SDL_ShowCursor(0);*/ |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
926 } else |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
927 if(flags&ZOOM) { |
543
ee0010d0ca81
Changed some code so it only kicks in when XV is disable.
atmosfear
parents:
542
diff
changeset
|
928 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
929 priv->fulltype = ZOOM; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
930 set_fullmode(priv->fullmode); |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
931 } |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
932 else { |
4925 | 933 if((strcmp(priv->driver, "x11") == 0) |
934 ||(strcmp(priv->driver, "windib") == 0) | |
935 ||(strcmp(priv->driver, "directx") == 0) | |
8246
a8128852c18d
Add Quartz (OS X GUI) to SDL window-capable list, patch by Tomas Hurka <tom at hukatronic.cz>
atmos4
parents:
8149
diff
changeset
|
936 ||(strcmp(priv->driver, "Quartz") == 0) |
4925 | 937 ||((strcmp(priv->driver, "aalib") == 0) |
938 && priv->X)) { | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
939 if(verbose) printf("SDL: setting windowed mode\n"); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
940 set_video_mode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags); |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
941 } |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
942 else { |
951 | 943 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); |
944 priv->fulltype = ZOOM; | |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
945 set_fullmode(priv->fullmode); |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
946 } |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
947 } |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
948 |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
949 if(!priv->surface) { // cannot SetVideoMode |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
950 printf("SDL: failed to set video mode: %s\n", SDL_GetError()); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
951 return -1; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
952 } |
1 | 953 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
954 return 0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
955 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
956 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
957 /* Free priv->rgbsurface or priv->overlay if they are != NULL. |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
958 * Setup priv->rgbsurface or priv->overlay depending on source format. |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
959 * The size of the created surface or overlay depends on the size of |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
960 * priv->surface, priv->width, priv->height, priv->dstwidth and priv->dstheight. |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
961 */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
962 static int setup_surfaces(void) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
963 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
964 struct sdl_priv_s *priv = &sdl_priv; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
965 float v_scale = ((float) priv->dstheight) / priv->height; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
966 int surfwidth, surfheight; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
967 |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
968 surfwidth = priv->width; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
969 surfheight = priv->height + (priv->surface->h - priv->dstheight) / v_scale; |
5358 | 970 surfheight&= ~1; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
971 /* Place the image in the middle of the screen */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
972 priv->y = (surfheight - priv->height) / 2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
973 priv->y_screen_top = priv->y * v_scale; |
5313 | 974 priv->y_screen_bottom = priv->y_screen_top + priv->dstheight; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
975 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
976 priv->dirty_off_frame[0].x = -1; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
977 priv->dirty_off_frame[0].y = -1; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
978 priv->dirty_off_frame[1].x = -1; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
979 priv->dirty_off_frame[1].y = -1; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
980 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
981 /* Make sure the entire screen is updated */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
982 vo_osd_changed(1); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
983 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
984 if(priv->rgbsurface) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
985 SDL_FreeSurface(priv->rgbsurface); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
986 else if(priv->overlay) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
987 SDL_FreeYUVOverlay(priv->overlay); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
988 |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
989 priv->rgbsurface = NULL; |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
990 priv->overlay = NULL; |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
991 |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
992 if(priv->mode != YUV && (priv->format&0xFF) == priv->bpp) { |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
993 if(strcmp(priv->driver, "x11") == 0) { |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
994 priv->dblit = 1; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
995 priv->framePlaneRGB = priv->width * priv->height * priv->surface->format->BytesPerPixel; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
996 priv->stridePlaneRGB = priv->width * priv->surface->format->BytesPerPixel; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
997 erase_rectangle(0, 0, priv->surface->w, priv->surface->h); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
998 return 0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
999 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1000 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1001 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1002 switch(priv->format) { |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1003 /* Initialize and create the RGB Surface used for video out in BGR/RGB mode */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1004 //SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1005 // SDL_SWSURFACE,SDL_HWSURFACE,SDL_SRCCOLORKEY, priv->flags? guess: exchange Rmask and Bmask for BGR<->RGB |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1006 // 32 bit: a:ff000000 r:ff000 g:ff00 b:ff |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1007 // 24 bit: r:ff0000 g:ff00 b:ff |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1008 // 16 bit: r:1111100000000000b g:0000011111100000b b:0000000000011111b |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1009 // 15 bit: r:111110000000000b g:000001111100000b b:000000000011111b |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1010 // FIXME: colorkey detect based on bpp, FIXME static bpp value, FIXME alpha value correct? |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1011 case IMGFMT_RGB15: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1012 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 15, 31, 992, 31744, 0); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1013 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1014 case IMGFMT_BGR15: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1015 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 15, 31744, 992, 31, 0); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1016 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1017 case IMGFMT_RGB16: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1018 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 16, 31, 2016, 63488, 0); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1019 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1020 case IMGFMT_BGR16: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1021 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 16, 63488, 2016, 31, 0); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1022 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1023 case IMGFMT_RGB24: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1024 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1025 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1026 case IMGFMT_BGR24: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1027 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 24, 0xFF0000, 0x00FF00, 0x0000FF, 0); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1028 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1029 case IMGFMT_RGB32: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1030 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0/*0xFF000000*/); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1031 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1032 case IMGFMT_BGR32: |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1033 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0/*0xFF000000*/); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1034 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1035 default: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1036 /* Initialize and create the YUV Overlay used for video out */ |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1037 if (!(priv->overlay = SDL_CreateYUVOverlay (surfwidth, surfheight, priv->format, priv->surface))) { |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1038 printf ("SDL: Couldn't create a YUV overlay: %s\n", SDL_GetError()); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1039 return -1; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1040 } |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1041 priv->framePlaneY = priv->width * priv->height; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1042 priv->framePlaneUV = (priv->width * priv->height) >> 2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1043 priv->framePlaneYUY = priv->width * priv->height * 2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1044 priv->stridePlaneY = priv->width; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1045 priv->stridePlaneUV = priv->width/2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1046 priv->stridePlaneYUY = priv->width * 2; |
1 | 1047 } |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1048 |
5238
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1049 if(priv->mode != YUV) { |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1050 if(!priv->rgbsurface) { |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1051 printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError()); |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1052 return -1; |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1053 } |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1054 |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1055 priv->dblit = 0; |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1056 |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1057 if((priv->format&0xFF) != priv->bpp) |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1058 printf("SDL: using depth/colorspace conversion, this will slow things" |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1059 "down (%ibpp -> %ibpp).\n", priv->format&0xFF, priv->bpp); |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1060 |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1061 priv->framePlaneRGB = priv->width * priv->height * priv->rgbsurface->format->BytesPerPixel; |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1062 priv->stridePlaneRGB = priv->width * priv->rgbsurface->format->BytesPerPixel; |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1063 } |
182fc3f585e8
Fix crash when SDL had to do rgb -> rgb conversion. Removed some code
ksorim
parents:
5058
diff
changeset
|
1064 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1065 erase_rectangle(0, 0, surfwidth, surfheight); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1066 |
1 | 1067 return 0; |
1068 } | |
1069 | |
1070 | |
1071 /** | |
1072 * Draw a frame to the SDL YUV overlay. | |
1073 * | |
1074 * params : *src[] == the Y, U, and V planes that make up the frame. | |
1075 * returns : non-zero on success, zero on error. | |
1076 **/ | |
1077 | |
1078 //static int sdl_draw_frame (frame_t *frame) | |
1079 static uint32_t draw_frame(uint8_t *src[]) | |
1080 { | |
1081 struct sdl_priv_s *priv = &sdl_priv; | |
1082 uint8_t *dst; | |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1083 int i; |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1084 uint8_t *mysrc = src[0]; |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
1710
diff
changeset
|
1085 |
5313 | 1086 switch(priv->format){ |
1 | 1087 case IMGFMT_YUY2: |
408 | 1088 case IMGFMT_UYVY: |
1089 case IMGFMT_YVYU: | |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1090 SDL_OVR_LOCK(-1) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1091 dst = (uint8_t *) *(priv->overlay->pixels) + priv->overlay->pitches[0]*priv->y; |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1092 if(priv->flip) { |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1093 mysrc+=priv->framePlaneYUY; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1094 for(i = 0; i < priv->height; i++) { |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1095 mysrc-=priv->stridePlaneYUY; |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1096 memcpy (dst, mysrc, priv->stridePlaneYUY); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1097 dst+=priv->overlay->pitches[0]; |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1098 } |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1099 } |
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1100 else memcpy (dst, src[0], priv->framePlaneYUY); |
1197 | 1101 SDL_OVR_UNLOCK |
1 | 1102 break; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1103 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1104 case IMGFMT_RGB15: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1105 case IMGFMT_BGR15: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1106 case IMGFMT_RGB16: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1107 case IMGFMT_BGR16: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1108 case IMGFMT_RGB24: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1109 case IMGFMT_BGR24: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1110 case IMGFMT_RGB32: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1111 case IMGFMT_BGR32: |
1219
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
1112 if(priv->dblit) { |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1113 SDL_SRF_LOCK(priv->surface, -1) |
7692 | 1114 dst = (uint8_t *) priv->surface->pixels + priv->y*priv->surface->pitch; |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1115 if(priv->flip) { |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1116 mysrc+=priv->framePlaneRGB; |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1117 for(i = 0; i < priv->height; i++) { |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1118 mysrc-=priv->stridePlaneRGB; |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1119 memcpy (dst, mysrc, priv->stridePlaneRGB); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1120 dst += priv->surface->pitch; |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1121 } |
823
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
1122 } |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1123 else memcpy (dst, src[0], priv->framePlaneRGB); |
1197 | 1124 SDL_SRF_UNLOCK(priv->surface) |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1125 } else { |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1126 SDL_SRF_LOCK(priv->rgbsurface, -1) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1127 dst = (uint8_t *) priv->rgbsurface->pixels + priv->y*priv->rgbsurface->pitch; |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1128 if(priv->flip) { |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1129 mysrc+=priv->framePlaneRGB; |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1130 for(i = 0; i < priv->height; i++) { |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1131 mysrc-=priv->stridePlaneRGB; |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1132 memcpy (dst, mysrc, priv->stridePlaneRGB); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1133 dst += priv->rgbsurface->pitch; |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1134 } |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1135 } |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1136 else memcpy (dst, src[0], priv->framePlaneRGB); |
1197 | 1137 SDL_SRF_UNLOCK(priv->rgbsurface) |
823
e09c92ca4c45
Added ability to use direct surface blitting for BGR modes.
atmosfear
parents:
784
diff
changeset
|
1138 } |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1139 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1140 |
1 | 1141 } |
1142 | |
1143 return 0; | |
1144 } | |
1145 | |
1146 | |
1147 /** | |
1148 * Draw a slice (16 rows of image) to the SDL YUV overlay. | |
1149 * | |
1150 * params : *src[] == the Y, U, and V planes that make up the slice. | |
1151 * returns : non-zero on error, zero on success. | |
1152 **/ | |
1153 | |
1154 //static uint32_t draw_slice(uint8_t *src[], uint32_t slice_num) | |
1155 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
1156 { | |
1157 struct sdl_priv_s *priv = &sdl_priv; | |
1158 uint8_t *dst; | |
1159 | |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1160 SDL_OVR_LOCK(-1) |
1 | 1161 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1162 y += priv->y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1163 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1164 dst = priv->overlay->pixels[0] + priv->overlay->pitches[0]*y + x; |
7692 | 1165 memcpy_pic(dst, image[0], w, h, priv->overlay->pitches[0], stride[0]); |
1166 x/=2;y/=2;w/=2;h/=2; | |
1 | 1167 |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1168 switch(priv->format) { |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1169 case IMGFMT_YV12: |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1170 dst = priv->overlay->pixels[2] + priv->overlay->pitches[2]*y + x; |
7692 | 1171 memcpy_pic(dst, image[1], w, h, priv->overlay->pitches[2], stride[1]); |
1172 | |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1173 dst = priv->overlay->pixels[1] + priv->overlay->pitches[1]*y + x; |
7692 | 1174 memcpy_pic(dst, image[2], w, h, priv->overlay->pitches[1], stride[2]); |
1175 | |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1176 break; |
7692 | 1177 case IMGFMT_I420: |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1178 case IMGFMT_IYUV: |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1179 dst = priv->overlay->pixels[1] + priv->overlay->pitches[1]*y + x; |
7692 | 1180 memcpy_pic(dst, image[1], w, h, priv->overlay->pitches[1], stride[1]); |
1 | 1181 |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1182 dst = priv->overlay->pixels[2] + priv->overlay->pitches[2]*y + x; |
7692 | 1183 memcpy_pic(dst, image[2], w, h, priv->overlay->pitches[2], stride[2]); |
1184 | |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1185 break; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1186 default: |
7692 | 1187 printf("SDL: unsupported image format in draw_slice, contact MPlayer developers!\n"); |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1188 } |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1189 |
1197 | 1190 SDL_OVR_UNLOCK |
1 | 1191 |
1192 return 0; | |
1193 } | |
1194 | |
1195 | |
1196 | |
1197 /** | |
1198 * Checks for SDL keypress and window resize events | |
1199 * | |
1200 * params : none | |
1201 * returns : doesn't return | |
1202 **/ | |
1203 | |
1204 #include "../linux/keycodes.h" | |
1205 extern void mplayer_put_key(int code); | |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1206 |
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1207 #define shift_key (event.key.keysym.mod==(KMOD_LSHIFT||KMOD_RSHIFT)) |
1 | 1208 static void check_events (void) |
1209 { | |
1210 struct sdl_priv_s *priv = &sdl_priv; | |
1211 SDL_Event event; | |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
1212 SDLKey keypressed = 0; |
1 | 1213 |
1214 /* Poll the waiting SDL Events */ | |
1215 while ( SDL_PollEvent(&event) ) { | |
1216 switch (event.type) { | |
1217 | |
1218 /* capture window resize events */ | |
1219 case SDL_VIDEORESIZE: | |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1220 if(!priv->dblit) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1221 set_video_mode(event.resize.w, event.resize.h, priv->bpp, priv->sdlflags); |
1 | 1222 |
1223 /* save video extents, to restore them after going fullscreen */ | |
1224 //if(!(priv->surface->flags & SDL_FULLSCREEN)) { | |
1225 priv->windowsize.w = priv->surface->w; | |
1226 priv->windowsize.h = priv->surface->h; | |
1227 //} | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1228 if(verbose > 2) printf("SDL: Window resize\n"); |
1 | 1229 break; |
1230 | |
4590
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1231 case SDL_MOUSEBUTTONDOWN: |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1232 if(event.button.button == 4 || event.button.button == 5) |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1233 mplayer_put_key(MOUSE_BASE+event.button.button-1); |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1234 else |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1235 mplayer_put_key((MOUSE_BASE+event.button.button-1) | MP_KEY_DOWN); |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1236 break; |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1237 |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1238 case SDL_MOUSEBUTTONUP: |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1239 mplayer_put_key(MOUSE_BASE+event.button.button-1); |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1240 break; |
3a76a4dcde2c
Applied patch mouse whell patch from Wojtek Kaniewski <wojtekka@bydg.pdi.net>
albeu
parents:
4530
diff
changeset
|
1241 |
1 | 1242 /* graphics mode selection shortcuts */ |
705
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1243 #ifdef BUGGY_SDL |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1244 case SDL_KEYDOWN: |
705
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1245 switch(event.key.keysym.sym) { |
1122
fe9ef743be91
fixed my previousily added bug: ifdef buggy_sdl: keypressed: default case
al3x
parents:
1110
diff
changeset
|
1246 case SDLK_UP: mplayer_put_key(KEY_UP); break; |
fe9ef743be91
fixed my previousily added bug: ifdef buggy_sdl: keypressed: default case
al3x
parents:
1110
diff
changeset
|
1247 case SDLK_DOWN: mplayer_put_key(KEY_DOWN); break; |
fe9ef743be91
fixed my previousily added bug: ifdef buggy_sdl: keypressed: default case
al3x
parents:
1110
diff
changeset
|
1248 case SDLK_LEFT: mplayer_put_key(KEY_LEFT); break; |
fe9ef743be91
fixed my previousily added bug: ifdef buggy_sdl: keypressed: default case
al3x
parents:
1110
diff
changeset
|
1249 case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT); break; |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1250 case SDLK_LESS: mplayer_put_key(shift_key?'>':'<'); break; |
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1251 case SDLK_GREATER: mplayer_put_key('>'); break; |
705
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1252 case SDLK_ASTERISK: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1253 case SDLK_KP_MULTIPLY: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1254 case SDLK_SLASH: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1255 case SDLK_KP_DIVIDE: |
1122
fe9ef743be91
fixed my previousily added bug: ifdef buggy_sdl: keypressed: default case
al3x
parents:
1110
diff
changeset
|
1256 default: break; |
705
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1257 } |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1258 break; |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1259 case SDL_KEYUP: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1260 #else |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1261 case SDL_KEYDOWN: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1262 #endif |
1 | 1263 keypressed = event.key.keysym.sym; |
703
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
1264 if(verbose > 1) printf("SDL: Key pressed: '%i'\n", keypressed); |
265
1d02e6f7c63a
Only small change to allow pausing of movie (p or SPACE).
atmosfear
parents:
97
diff
changeset
|
1265 |
357 | 1266 /* 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
|
1267 if ( ((keypressed == SDLK_c)) && (priv->fullmodes) ) { |
1 | 1268 /* select next fullscreen mode */ |
1269 priv->fullmode++; | |
1270 if (priv->fullmode > (findArrayEnd(priv->fullmodes) - 1)) priv->fullmode = 0; | |
1271 set_fullmode(priv->fullmode); | |
1272 | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1273 if(verbose > 1) printf("SDL: Set next available fullscreen mode.\n"); |
1 | 1274 } |
1275 | |
1396
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1276 else if ( keypressed == SDLK_n ) { |
2182 | 1277 #ifdef HAVE_X11 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
1278 aspect(&priv->dstwidth, &priv->dstheight,A_NOZOOM); |
2182 | 1279 #endif |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
1280 if (priv->surface->w != priv->dstwidth || priv->surface->h != priv->dstheight) { |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1281 set_video_mode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags); |
1396
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1282 priv->windowsize.w = priv->surface->w; |
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1283 priv->windowsize.h = priv->surface->h; |
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1284 if(verbose > 1) printf("SDL: Normal size\n"); |
1509
f9beae70c5c2
Removed D key for doublesize, already clobbered by framedrop.
atmos4
parents:
1501
diff
changeset
|
1285 } else |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2182
diff
changeset
|
1286 if (priv->surface->w != priv->dstwidth * 2 || priv->surface->h != priv->dstheight * 2) { |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1287 set_video_mode(priv->dstwidth * 2, priv->dstheight * 2, priv->bpp, priv->sdlflags); |
1396
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1288 priv->windowsize.w = priv->surface->w; |
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1289 priv->windowsize.h = priv->surface->h; |
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1290 if(verbose > 1) printf("SDL: Double size\n"); |
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1291 } |
3c7f13cb0a8a
Added double/normal resize patch by Wojtek Kaniewski <wojtekka at bydg.pdi.net>
atmos4
parents:
1238
diff
changeset
|
1292 } |
1509
f9beae70c5c2
Removed D key for doublesize, already clobbered by framedrop.
atmos4
parents:
1501
diff
changeset
|
1293 |
1 | 1294 else switch(keypressed){ |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
1295 case SDLK_RETURN: |
6440
2997a3faf381
Streamline enter-key behaviour suggested by Christian Ohm and disable I420/IYUV because
atmos4
parents:
5894
diff
changeset
|
1296 SDL_ShowCursor(1); |
2997a3faf381
Streamline enter-key behaviour suggested by Christian Ohm and disable I420/IYUV because
atmos4
parents:
5894
diff
changeset
|
1297 mplayer_put_key(KEY_ENTER); |
2997a3faf381
Streamline enter-key behaviour suggested by Christian Ohm and disable I420/IYUV because
atmos4
parents:
5894
diff
changeset
|
1298 break; |
331
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
1299 case SDLK_ESCAPE: |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
1300 case SDLK_q: |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
1301 SDL_ShowCursor(1); |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
1302 mplayer_put_key('q'); |
0f1737e626fa
- Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents:
265
diff
changeset
|
1303 break; |
475
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
1304 /*case SDLK_o: mplayer_put_key('o');break; |
575
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
1305 case SDLK_SPACE: mplayer_put_key(' ');break; |
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
1306 case SDLK_p: mplayer_put_key('p');break;*/ |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1307 case SDLK_7: mplayer_put_key(shift_key?'/':'7'); |
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1308 case SDLK_PLUS: mplayer_put_key(shift_key?'*':'+'); |
1 | 1309 case SDLK_KP_PLUS: mplayer_put_key('+');break; |
1310 case SDLK_MINUS: | |
575
3fde7340afd5
Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents:
543
diff
changeset
|
1311 case SDLK_KP_MINUS: mplayer_put_key('-');break; |
637
19d941a8b46f
Added support for osd menue and kexrepeats for mixer keys.
atmosfear
parents:
635
diff
changeset
|
1312 case SDLK_TAB: mplayer_put_key('\t');break; |
653 | 1313 case SDLK_PAGEUP: mplayer_put_key(KEY_PAGE_UP);break; |
1314 case SDLK_PAGEDOWN: mplayer_put_key(KEY_PAGE_DOWN);break; | |
705
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1315 #ifdef BUGGY_SDL |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1316 case SDLK_UP: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1317 case SDLK_DOWN: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1318 case SDLK_LEFT: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1319 case SDLK_RIGHT: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1320 case SDLK_ASTERISK: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1321 case SDLK_KP_MULTIPLY: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1322 case SDLK_SLASH: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1323 case SDLK_KP_DIVIDE: |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1324 break; |
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1325 #else |
703
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
1326 case SDLK_UP: mplayer_put_key(KEY_UP);break; |
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
1327 case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break; |
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
1328 case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break; |
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
1329 case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break; |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1330 case SDLK_LESS: mplayer_put_key(shift_key?'>':'<'); break; |
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1331 case SDLK_GREATER: mplayer_put_key('>'); break; |
703
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
1332 case SDLK_ASTERISK: |
5834 | 1333 case SDLK_KP_MULTIPLY: mplayer_put_key('*'); break; |
703
fcc01494c0fe
Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents:
653
diff
changeset
|
1334 case SDLK_SLASH: |
5834 | 1335 case SDLK_KP_DIVIDE: mplayer_put_key('/'); break; |
705
27d351f251eb
Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents:
703
diff
changeset
|
1336 #endif |
475
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
1337 default: |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1338 //printf("got scancode: %d keysym: %d mod: %d %d\n", event.key.keysym.scancode, keypressed, event.key.keysym.mod); |
475
904d1cfda2dd
changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents:
451
diff
changeset
|
1339 mplayer_put_key(keypressed); |
1 | 1340 } |
1341 | |
1342 break; | |
1710 | 1343 case SDL_QUIT: |
1344 SDL_ShowCursor(1); | |
1345 mplayer_put_key('q'); | |
1346 break; | |
1 | 1347 } |
1348 } | |
1349 } | |
4530
22a4c7957f03
Add playlist keys (some missing?!) and add some shift handlers to allow keys to work with german keyboards.
atmos4
parents:
4528
diff
changeset
|
1350 #undef shift_key |
1 | 1351 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1352 /* Erase (paint it black) the rectangle specified by x, y, w and h in the surface |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1353 or overlay which is used for OSD |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1354 */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1355 static void erase_rectangle(int x, int y, int w, int h) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1356 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1357 struct sdl_priv_s *priv = &sdl_priv; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1358 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1359 switch(priv->format) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1360 case IMGFMT_YV12: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1361 case IMGFMT_I420: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1362 case IMGFMT_IYUV: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1363 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1364 SDL_OVR_LOCK((void) 0) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1365 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1366 /* Erase Y plane */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1367 erase_area_1(x, w, h, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1368 priv->overlay->pitches[0], 0, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1369 priv->overlay->pixels[0] + |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1370 priv->overlay->pitches[0]*y); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1371 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1372 /* Erase U and V planes */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1373 w /= 2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1374 x /= 2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1375 h /= 2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1376 y /= 2; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1377 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1378 erase_area_1(x, w, h, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1379 priv->overlay->pitches[1], 128, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1380 priv->overlay->pixels[1] + |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1381 priv->overlay->pitches[1]*y); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1382 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1383 erase_area_1(x, w, h, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1384 priv->overlay->pitches[2], 128, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1385 priv->overlay->pixels[2] + |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1386 priv->overlay->pitches[2]*y); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1387 SDL_OVR_UNLOCK |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1388 break; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1389 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1390 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1391 case IMGFMT_YUY2: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1392 case IMGFMT_YVYU: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1393 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1394 /* yuy2 and yvyu represent black the same way */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1395 uint8_t yuy2_black[] = {0, 128, 0, 128}; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1396 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1397 SDL_OVR_LOCK((void) 0) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1398 erase_area_4(x*2, w*2, h, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1399 priv->overlay->pitches[0], |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1400 *((uint32_t*) yuy2_black), |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1401 priv->overlay->pixels[0] + |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1402 priv->overlay->pitches[0]*y); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1403 SDL_OVR_UNLOCK |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1404 break; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1405 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1406 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1407 case IMGFMT_UYVY: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1408 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1409 uint8_t uyvy_black[] = {128, 0, 128, 0}; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1410 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1411 SDL_OVR_LOCK((void) 0) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1412 erase_area_4(x*2, w*2, h, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1413 priv->overlay->pitches[0], |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1414 *((uint32_t*) uyvy_black), |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1415 priv->overlay->pixels[0] + |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1416 priv->overlay->pitches[0]*y); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1417 SDL_OVR_UNLOCK |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1418 break; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1419 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1420 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1421 case IMGFMT_RGB15: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1422 case IMGFMT_BGR15: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1423 case IMGFMT_RGB16: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1424 case IMGFMT_BGR16: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1425 case IMGFMT_RGB24: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1426 case IMGFMT_BGR24: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1427 case IMGFMT_RGB32: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1428 case IMGFMT_BGR32: |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1429 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1430 SDL_Rect rect; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1431 rect.w = w; rect.h = h; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1432 rect.x = x; rect.y = y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1433 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1434 if(priv->dblit) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1435 SDL_SRF_LOCK(priv->surface, (void) 0) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1436 SDL_FillRect(priv->surface, &rect, 0); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1437 SDL_SRF_UNLOCK(priv->surface) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1438 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1439 else { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1440 SDL_SRF_LOCK(priv->rgbsurface, (void) 0) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1441 SDL_FillRect(priv->rgbsurface, &rect, 0); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1442 SDL_SRF_UNLOCK(priv->rgbsurface) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1443 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1444 break; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1445 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1446 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1447 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1448 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1396
diff
changeset
|
1449 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1396
diff
changeset
|
1450 { struct sdl_priv_s *priv = &sdl_priv; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1396
diff
changeset
|
1451 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1452 priv->osd_has_changed = vo_osd_changed(0); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1453 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1454 if(priv->osd_has_changed) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1455 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1456 int i; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1457 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1458 for(i = 0; i < 2; i++) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1459 if(priv->dirty_off_frame[i].x < 0 || priv->dirty_off_frame[i].y < 0) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1460 continue; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1461 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1462 erase_rectangle(priv->dirty_off_frame[i].x, priv->dirty_off_frame[i].y, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1463 priv->dirty_off_frame[i].w, priv->dirty_off_frame[i].h); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1464 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1465 priv->dirty_off_frame[i].x = -1; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1466 priv->dirty_off_frame[i].y = -1; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1467 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1468 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1469 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1396
diff
changeset
|
1470 /* update osd/subtitles */ |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1471 if(priv->mode == YUV) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1472 vo_draw_text(priv->overlay->w, priv->overlay->h, draw_alpha); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1473 else { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1474 if(priv->dblit) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1475 vo_draw_text(priv->surface->w, priv->surface->h, draw_alpha); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1476 else |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1477 vo_draw_text(priv->rgbsurface->w, priv->rgbsurface->h, draw_alpha); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1478 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1479 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1480 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1481 /* Fill area beginning at 'pixels' with 'color'. 'x_start', 'width' and 'pitch' |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1482 * are given in bytes. 4 bytes at a time. |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1483 */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1484 static void erase_area_4(int x_start, int width, int height, int pitch, uint32_t color, uint8_t* pixels) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1485 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1486 int x_end = x_start/4 + width/4; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1487 int x, y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1488 uint32_t* data = (uint32_t*) pixels; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1489 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1490 x_start /= 4; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1491 pitch /= 4; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1492 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1493 for(y = 0; y < height; y++) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1494 for(x = x_start; x < x_end; x++) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1495 data[y*pitch + x] = color; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1496 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1497 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1498 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1499 /* Fill area beginning at 'pixels' with 'color'. 'x_start', 'width' and 'pitch' |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1500 * are given in bytes. 1 byte at a time. |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1501 */ |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1502 static void erase_area_1(int x_start, int width, int height, int pitch, uint8_t color, uint8_t* pixels) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1503 { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1504 int y; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1505 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1506 for(y = 0; y < height; y++) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1507 memset(&pixels[y*pitch + x_start], color, width); |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1508 } |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1396
diff
changeset
|
1509 } |
1 | 1510 |
1511 /** | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1396
diff
changeset
|
1512 * Display the surface we have written our data to |
1 | 1513 * |
1514 * params : mode == index of the desired fullscreen mode | |
1515 * returns : doesn't return | |
1516 **/ | |
1517 | |
1518 static void flip_page (void) | |
1519 { | |
1520 struct sdl_priv_s *priv = &sdl_priv; | |
1521 | |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1522 switch(priv->format) { |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1523 case IMGFMT_RGB15: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1524 case IMGFMT_BGR15: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1525 case IMGFMT_RGB16: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1526 case IMGFMT_BGR16: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1527 case IMGFMT_RGB24: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1528 case IMGFMT_BGR24: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1529 case IMGFMT_RGB32: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1530 case IMGFMT_BGR32: |
1219
e169f798ff71
Sync with SF cvs. (Bugfixed YUV aalib and RGB/BGR32 converted modes.)
atmos4
parents:
1197
diff
changeset
|
1531 if(!priv->dblit) { |
1194
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1532 /* blit to the RGB surface */ |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1533 if(SDL_BlitSurface (priv->rgbsurface, NULL, priv->surface, NULL)) |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1534 printf("SDL: Blit failed: %s\n", SDL_GetError()); |
40550e1458e8
Drastic! speedup of rgb code. Removed nonsens memhole fixes.
atmosfear
parents:
1188
diff
changeset
|
1535 } |
1 | 1536 |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1537 /* update screen */ |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1538 //SDL_UpdateRect(priv->surface, 0, 0, priv->surface->clip_rect.w, priv->surface->clip_rect.h); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1539 if(priv->osd_has_changed) { |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1540 priv->osd_has_changed = 0; |
784
dee122f9cdb9
Added full aspect awareness, rewrote fullscreen handling.
atmosfear
parents:
772
diff
changeset
|
1541 SDL_UpdateRects(priv->surface, 1, &priv->surface->clip_rect); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1542 } |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1543 else |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1544 SDL_UpdateRect(priv->surface, 0, priv->y_screen_top, |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1545 priv->surface->clip_rect.w, priv->y_screen_bottom); |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1546 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1547 /* check if we have a double buffered surface and flip() if we do. */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1548 if ( priv->surface->flags & SDL_DOUBLEBUF ) |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1549 SDL_Flip(priv->surface); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1550 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1551 break; |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1552 default: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1553 /* blit to the YUV overlay */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1554 SDL_DisplayYUVOverlay (priv->overlay, &priv->surface->clip_rect); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1555 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1556 /* check if we have a double buffered surface and flip() if we do. */ |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1557 if ( priv->surface->flags & SDL_DOUBLEBUF ) |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1558 SDL_Flip(priv->surface); |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1559 |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1560 //SDL_LockYUVOverlay (priv->overlay); // removed because unused!? |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1561 } |
1 | 1562 } |
1563 | |
1564 static uint32_t | |
1565 query_format(uint32_t format) | |
1566 { | |
1567 switch(format){ | |
1568 case IMGFMT_YV12: | |
6440
2997a3faf381
Streamline enter-key behaviour suggested by Christian Ohm and disable I420/IYUV because
atmos4
parents:
5894
diff
changeset
|
1569 // it seems buggy (not hw accelerated), so just use YV12 instead! |
2997a3faf381
Streamline enter-key behaviour suggested by Christian Ohm and disable I420/IYUV because
atmos4
parents:
5894
diff
changeset
|
1570 // case IMGFMT_I420: |
2997a3faf381
Streamline enter-key behaviour suggested by Christian Ohm and disable I420/IYUV because
atmos4
parents:
5894
diff
changeset
|
1571 // case IMGFMT_IYUV: |
1 | 1572 case IMGFMT_YUY2: |
408 | 1573 case IMGFMT_UYVY: |
1574 case IMGFMT_YVYU: | |
5894
af9efcb80244
Use new style query_formats flags. Fixes bug with flip.
ksorim
parents:
5834
diff
changeset
|
1575 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | |
af9efcb80244
Use new style query_formats flags. Fixes bug with flip.
ksorim
parents:
5834
diff
changeset
|
1576 VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; |
635
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1577 case IMGFMT_RGB15: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1578 case IMGFMT_BGR15: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1579 case IMGFMT_RGB16: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1580 case IMGFMT_BGR16: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1581 case IMGFMT_RGB24: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1582 case IMGFMT_BGR24: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1583 case IMGFMT_RGB32: |
b9735f811d7d
15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents:
616
diff
changeset
|
1584 case IMGFMT_BGR32: |
5894
af9efcb80244
Use new style query_formats flags. Fixes bug with flip.
ksorim
parents:
5834
diff
changeset
|
1585 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_FLIP; |
1 | 1586 } |
1587 return 0; | |
1588 } | |
1589 | |
1590 | |
1591 static void | |
1592 uninit(void) | |
1593 { | |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1594 #ifdef HAVE_X11 |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1595 static Display *XDisplay; |
5267
e5f57c576c48
Fixes crash which occured when it wasn't possible to connect to the display
ksorim
parents:
5260
diff
changeset
|
1596 XDisplay = XOpenDisplay(NULL); |
e5f57c576c48
Fixes crash which occured when it wasn't possible to connect to the display
ksorim
parents:
5260
diff
changeset
|
1597 if(XDisplay) { |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1598 if(verbose) printf("SDL: activating XScreensaver/DPMS\n"); |
5267
e5f57c576c48
Fixes crash which occured when it wasn't possible to connect to the display
ksorim
parents:
5260
diff
changeset
|
1599 |
772
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1600 saver_on(XDisplay); |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1601 XCloseDisplay(XDisplay); |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1602 } |
e70a52f17f92
Added flipped video support and activate/deactivate screensaver under X.
atmosfear
parents:
770
diff
changeset
|
1603 #endif |
1122
fe9ef743be91
fixed my previousily added bug: ifdef buggy_sdl: keypressed: default case
al3x
parents:
1110
diff
changeset
|
1604 sdl_close(); |
1 | 1605 } |
4352 | 1606 |
1607 static uint32_t preinit(const char *arg) | |
1608 { | |
5240 | 1609 struct sdl_priv_s *priv = &sdl_priv; |
1610 | |
1611 priv->rgbsurface = NULL; | |
1612 priv->overlay = NULL; | |
1613 priv->surface = NULL; | |
1614 | |
1615 return 0; | |
4352 | 1616 } |
1617 | |
5058 | 1618 static uint32_t get_image(mp_image_t *mpi) |
1619 { | |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1620 struct sdl_priv_s *priv = &sdl_priv; |
5058 | 1621 |
1622 if(priv->format != mpi->imgfmt) return VO_FALSE; | |
1623 if(mpi->type == MP_IMGTYPE_STATIC || mpi->type == MP_IMGTYPE_TEMP) { | |
5460
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1624 if(mpi->flags&MP_IMGFLAG_PLANAR) { |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1625 mpi->planes[0] = priv->overlay->pixels[0] + priv->y*priv->overlay->pitches[0]; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1626 mpi->stride[0] = priv->overlay->pitches[0]; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1627 if(mpi->flags&MP_IMGFLAG_SWAPPED) { |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1628 mpi->planes[1] = priv->overlay->pixels[1] + priv->y*priv->overlay->pitches[1]/2; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1629 mpi->stride[1] = priv->overlay->pitches[1]; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1630 mpi->planes[2] = priv->overlay->pixels[2] + priv->y*priv->overlay->pitches[2]/2; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1631 mpi->stride[2] = priv->overlay->pitches[2]; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1632 } else { |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1633 mpi->planes[2] = priv->overlay->pixels[1] + priv->y*priv->overlay->pitches[1]/2; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1634 mpi->stride[2] = priv->overlay->pitches[1]; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1635 mpi->planes[1] = priv->overlay->pixels[2] + priv->y*priv->overlay->pitches[2]/2; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1636 mpi->stride[1] = priv->overlay->pitches[2]; |
acf7acfa7acc
Fix I420 handling, though still don't know why divx4 codec queries for I420 not YUY2!
atmos4
parents:
5385
diff
changeset
|
1637 } |
5058 | 1638 } |
1639 else if(IMGFMT_IS_RGB(priv->format) || IMGFMT_IS_BGR(priv->format)) { | |
1640 if(priv->dblit) { | |
1641 if(mpi->type == MP_IMGTYPE_STATIC && (priv->surface->flags & SDL_DOUBLEBUF)) | |
1642 return VO_FALSE; | |
1643 | |
1644 mpi->planes[0] = priv->surface->pixels + priv->y*priv->surface->pitch; | |
1645 mpi->stride[0] = priv->surface->pitch; | |
1646 } | |
1647 else { | |
1648 mpi->planes[0] = priv->rgbsurface->pixels + priv->y*priv->rgbsurface->pitch; | |
1649 mpi->stride[0] = priv->rgbsurface->pitch; | |
1650 } | |
1651 } | |
1652 else { | |
1653 mpi->planes[0] = priv->overlay->pixels[0] + priv->y*priv->overlay->pitches[0]; | |
1654 mpi->stride[0] = priv->overlay->pitches[0]; | |
1655 } | |
1656 | |
1657 mpi->flags|=MP_IMGFLAG_DIRECT; | |
1658 return VO_TRUE; | |
1659 } | |
1660 | |
1661 return VO_FALSE; | |
1662 } | |
1663 | |
4596 | 1664 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 1665 { |
4772 | 1666 struct sdl_priv_s *priv = &sdl_priv; |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4590
diff
changeset
|
1667 switch (request) { |
5058 | 1668 case VOCTRL_GET_IMAGE: |
1669 return get_image(data); | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4590
diff
changeset
|
1670 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4590
diff
changeset
|
1671 return query_format(*((uint32_t*)data)); |
4772 | 1672 case VOCTRL_FULLSCREEN: |
1673 if (priv->surface->flags & SDL_FULLSCREEN) { | |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4790
diff
changeset
|
1674 set_video_mode(priv->windowsize.w, priv->windowsize.h, priv->bpp, priv->sdlflags); |
4772 | 1675 SDL_ShowCursor(1); |
1676 if(verbose > 1) printf("SDL: Windowed mode\n"); | |
1677 } else if (priv->fullmodes) { | |
1678 set_fullmode(priv->fullmode); | |
1679 if(verbose > 1) printf("SDL: Set fullscreen mode\n"); | |
1680 } | |
4790 | 1681 return VO_TRUE; |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4590
diff
changeset
|
1682 } |
4772 | 1683 |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4590
diff
changeset
|
1684 return VO_NOTIMPL; |
4352 | 1685 } |