annotate libvo/vo_sdl.c @ 12489:4a8748f99375

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