annotate libvo/vo_sdl.c @ 762:38bde387acf2

v0.8 prerelease (vki ekezetesitse, ha van ideje!)
author gabucino
date Fri, 11 May 2001 07:10:44 +0000
parents 27d351f251eb
children 0e549c933515
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
579
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
17 * from http://mplayer.sourceforge.net.
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
18 *
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
19 * Current license is not decided yet, but we're heading for GPL.
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
20 *
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
21 * -- old disclaimer --
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
22 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 * A mpeg2dec display driver that does output through the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 * Simple DirectMedia Layer (SDL) library. This effectively gives us all
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 * sorts of output options: X11, SVGAlib, fbcon, AAlib, GGI. Win32, MacOS
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 * and BeOS support, too. Yay. SDL info, source, and binaries can be found
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 * at http://slouken.devolution.com/SDL/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 * the Free Software Foundation; either version 2, or (at your option)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 * any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 * along with GNU Make; see the file COPYING. If not, write to
579
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
43 * the Free Software Foundation.
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
44 *
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
45 * -- end old disclaimer --
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 * Changes:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 * Dominik Schnitzer <dominik@schnitzer.at> - November 08, 2000.
84
802fbd1760ae aspect ratio patch by Felix B¸«änemann
arpi_esp
parents: 31
diff changeset
49 * - Added resizing support, fullscreen: changed the sdlmodes selection
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 * routine.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 * - SDL bugfixes: removed the atexit(SLD_Quit), SDL_Quit now resides in
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 * the plugin_exit routine.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 * - Commented the source :)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 * - Shortcuts: for switching between Fullscreen/Windowed mode and for
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 * cycling between the different Fullscreen modes.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 * - Small bugfixes: proper width/height of movie
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 * Dominik Schnitzer <dominik@schnitzer.at> - November 11, 2000.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 * - Cleanup code, more comments
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 * - Better error handling
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 * Bruno Barreyra <barreyra@ufl.edu> - December 10, 2000.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 * - Eliminated memcpy's for entire frames
579
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
62 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 11, 2001
84
802fbd1760ae aspect ratio patch by Felix B¸«änemann
arpi_esp
parents: 31
diff changeset
63 * - Added aspect-ratio awareness for fullscreen
579
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
64 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 11, 2001
97
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
65 * - Fixed aspect-ratio awareness, did only vertical scaling (black bars above
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
66 * and below), now also does horizontal scaling (black bars left and right),
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
67 * so you get the biggest possible picture with correct aspect-ratio.
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
68 * Felix Buenemann <Atmosfear@users.sourceforge.net> - March 12, 2001
579
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
69 * - Minor bugfix to aspect-ratio for non-4:3-resolutions (like 1280x1024)
97
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
70 * - Bugfix to check_events() to reveal mouse cursor after 'q'-quit in
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
71 * fullscreen-mode
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
72 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 10, 2001
331
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
73 * - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
74 * bug (key had to be pressed twice to be detected)
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
75 * - Changed key-handling: 'f' cycles fullscreen/windowed, ESC/RETURN/'q' quits
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
76 * - Bugfix which avoids exit, because return is passed to sdl-output on startup,
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
77 * which caused the player to exit (keyboard-buffer problem? better solution
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
78 * recommed)
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
79 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 11, 2001
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
80 * - OSD and subtitle support added
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
81 * - some minor code-changes
355
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
82 * - added code to comply with new fullscreen meaning
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
83 * - changed fullscreen-mode-cycling from '+' to 'c' (interferred with audiosync
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
84 * adjustment)
386
020ca66964e4 - added keymapping to toggle OSD ('o' key)
atmosfear
parents: 357
diff changeset
85 * Felix Buenemann <Atmosfear@users.sourceforge.net> - April 13, 2001
020ca66964e4 - added keymapping to toggle OSD ('o' key)
atmosfear
parents: 357
diff changeset
86 * - added keymapping to toggle OSD ('o' key)
394
f4fb35ef4c06 - added some defines to modify some sdl-out internas (see comments)
atmosfear
parents: 386
diff changeset
87 * - added some defines to modify some sdl-out internas (see comments)
475
904d1cfda2dd changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents: 451
diff changeset
88 *
904d1cfda2dd changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents: 451
diff changeset
89 * Felix Buenemann: further changes will be visible through cvs log, don't want
579
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
90 * to update this all the time (CVS info on http://mplayer.sourceforge.net)
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
91 *
256f3d32a4af Added maintainer info and disclaimer.
atmosfear
parents: 575
diff changeset
92 * KNOWN BUGS:
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
93 * - Crashes with aalib (fixed, but have to find cause!)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95
542
7eaec864e3d2 doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents: 475
diff changeset
96 /* 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
97 #undef SDL_NOHWSURFACE
7eaec864e3d2 doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents: 475
diff changeset
98
705
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
99 //#define BUGGY_SDL //defined by configure
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
100
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 #include <inttypes.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109
354
7de9e48c83a5 memcpy() moved mmx.h -> fastmemcpy.h
arpi_esp
parents: 351
diff changeset
110 #include "fastmemcpy.h"
616
41d6eec69b60 clean up
pontscho
parents: 612
diff changeset
111 #include "sub.h"
350
601822cc8c52 applied MMX2 memcpy() patch by Nick Kurshev
arpi_esp
parents: 331
diff changeset
112
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 LIBVO_EXTERN(sdl)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
115 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
116 char *sdl_driver;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
117 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
118 int sdl_forcexv;
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
119
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 {
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
122 "SDL YUV/RGB/BGR renderer (SDL v1.1.7+ only!)",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 "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
124 "Ryan C. Gordon <icculus@lokigames.com>, Felix Buenemann <atmosfear@users.sourceforge.net>",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 #include <SDL/SDL.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 /** Private SDL Data structure **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 static struct sdl_priv_s {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133
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
134 /* 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
135 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
136
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
137 /* SDL display surface */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 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
139
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
140 /* 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
141 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
142
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
143 /* SDL YUV overlay */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 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
145
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
146 /* x,y video position for centering */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
147 SDL_Rect vidpos;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 /* available fullscreen modes */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 SDL_Rect **fullmodes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 /* surface attributes for fullscreen and windowed mode */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 Uint32 sdlflags, sdlfullflags;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 /* save the windowed output extents */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 SDL_Rect windowsize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 /* Bits per Pixel */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 Uint8 bpp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160
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
161 /* 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
162 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
163 #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
164 #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
165 #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
166
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 /* current fullscreen mode, 0 = highest available fullscreen mode */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 int fullmode;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 /* YUV ints */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 int framePlaneY, framePlaneUV;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 int stridePlaneY, stridePlaneUV;
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
173
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
174 /* 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
175 int framePlaneRGB;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
176
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 int width,height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 int format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 } sdl_priv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
182 /** libvo Plugin functions **/
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
183
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
184 /**
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
185 * draw_alpha is used for osd and subtitle display.
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
186 *
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
187 **/
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
188
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
189 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
190 struct sdl_priv_s *priv = &sdl_priv;
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
191
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
192 switch(priv->format) {
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
193 case IMGFMT_YV12:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
194 case IMGFMT_I420:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
195 case IMGFMT_IYUV:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
196 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+priv->width*y0+x0,priv->width);
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
197 break;
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
198 case IMGFMT_YUY2:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
199 case IMGFMT_YVYU:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
200 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0),2*priv->width);
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
201 break;
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
202 case IMGFMT_UYVY:
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
203 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0)+1,2*priv->width);
635
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
204 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
205 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
206 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
207 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+2*(y0*priv->width+x0),2*priv->width);
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
208 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
209 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
210 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
211 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+2*(y0*priv->width+x0),2*priv->width);
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
212 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
213 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
214 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
215 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+3*(y0*priv->width+x0),3*priv->width);
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 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
217 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
218 case IMGFMT_BGR32:
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 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+4*(y0*priv->width+x0),4*priv->width);
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 break;
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
221 }
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
222 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 * Take a null-terminated array of pointers, and find the last element.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 * params : array == array of which we want to find the last element.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 * returns : index of last NON-NULL element.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 static inline int findArrayEnd (SDL_Rect **array)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 int i = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 while ( array[i++] ); /* keep loopin' ... */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 /* return the index of the last array element */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 return i - 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 * Open and prepare SDL output.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 * params : *plugin ==
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 * *name ==
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 * returns : 0 on success, -1 on failure
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 **/
331
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
249
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 static int sdl_open (void *plugin, void *name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 struct sdl_priv_s *priv = &sdl_priv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 const SDL_VideoInfo *vidInfo = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 static int opened = 0;
331
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
255
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 if (opened)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 opened = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259
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
260 if(verbose > 2) printf("SDL: Opening Plugin\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
261
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
262 if(sdl_driver) setenv("SDL_VIDEODRIVER", sdl_driver, 1);
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
263
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
264 /* does the user want SDL to try and force Xv */
635
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
265 if(sdl_forcexv) setenv("SDL_VIDEO_X11_NODIRECTCOLOR", "1", 1);
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
266
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
267 /* does the user want to disable Xv and use software scaling instead */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
268 if(sdl_noxv) setenv("SDL_VIDEO_YUV_HWACCEL", "0", 1);
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
269
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270
84
802fbd1760ae aspect ratio patch by Felix B¸«änemann
arpi_esp
parents: 31
diff changeset
271 /* default to no fullscreen mode, we'll set this as soon we have the avail. modes */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 priv->fullmode = -2;
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
273
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
274 priv->surface = NULL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
275 priv->rgbsurface = NULL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
276 priv->overlay = NULL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
277 priv->fullmodes = NULL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
278 priv->bpp = 0;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
279
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
280 /* initialize the SDL Video system */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
281 if (SDL_Init (SDL_INIT_VIDEO/*|SDL_INIT_NOPARACHUTE*/)) {
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
282 if(verbose > 2) printf("SDL: Initializing of SDL failed: %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
283 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
284 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
285
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
286 SDL_VideoDriverName(priv->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
287 if(verbose) printf("SDL: Using driver: %s\n", priv->driver);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 /* other default values */
394
f4fb35ef4c06 - added some defines to modify some sdl-out internas (see comments)
atmosfear
parents: 386
diff changeset
289 #ifdef SDL_NOHWSURFACE
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
290 if(verbose) printf("SDL: using software-surface\n");
394
f4fb35ef4c06 - added some defines to modify some sdl-out internas (see comments)
atmosfear
parents: 386
diff changeset
291 priv->sdlflags = SDL_SWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT;
f4fb35ef4c06 - added some defines to modify some sdl-out internas (see comments)
atmosfear
parents: 386
diff changeset
292 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT;
f4fb35ef4c06 - added some defines to modify some sdl-out internas (see comments)
atmosfear
parents: 386
diff changeset
293 #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
294 if((strcmp(priv->driver, "dga") == 0) && (priv->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
295 if(verbose) printf("SDL: using software-surface\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
296 priv->sdlflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
297 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
298 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
299 else {
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
300 if(verbose) printf("SDL: using hardware-surface\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
301 priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
302 priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_HWACCEL;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
303 }
394
f4fb35ef4c06 - added some defines to modify some sdl-out internas (see comments)
atmosfear
parents: 386
diff changeset
304 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305
703
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
306 /* Setup Keyrepeats (500/30 are defaults) */
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
307 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 /* get information about the graphics adapter */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 vidInfo = SDL_GetVideoInfo ();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 /* collect all fullscreen & hardware modes available */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 if (!(priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags))) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 /* non hardware accelerated fullscreen modes */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 priv->sdlfullflags &= ~SDL_HWSURFACE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 /* test for normal resizeable & windowed hardware accellerated surfaces */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 if (!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 /* test for NON hardware accelerated resizeable surfaces - poor you.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 * That's all we have. If this fails there's nothing left.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 * Theoretically there could be Fullscreenmodes left - we ignore this for now.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 priv->sdlflags &= ~SDL_HWSURFACE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 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
329 printf("SDL: Couldn't get any acceptable SDL Mode for output.\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 }
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
333
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 /* YUV overlays need at least 16-bit color depth, but the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 * display might less. The SDL AAlib target says it can only do
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 * 8-bits, for example. So, if the display is less than 16-bits,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 * 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
339 */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
340 //commented out for RGB test reasons
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 priv->bpp = vidInfo->vfmt->BitsPerPixel;
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
342 //FIXME: DO NOT ADD ANY CODE BELOW THIS OR SDL WILL CRASH WITH AALIB!
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
343 if (!priv->mode && priv->bpp < 16) {
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
344
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
345 if(verbose) printf("SDL: Your SDL display target wants to be at a color depth of (%d), but we need it to be at\
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 least 16 bits, so we need to emulate 16-bit color. This is going to slow things down; you might want to\
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
347 increase your display's color depth, if possible.\n", priv->bpp);
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
348
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 priv->bpp = 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351
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
352 /* 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
353 * 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
354 * 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
355 */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
356 /*SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
331
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
357 SDL_EventState(SDL_KEYDOWN, SDL_IGNORE);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 SDL_EventState(SDL_QUIT, SDL_IGNORE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
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
363 SDL_EventState(SDL_USEREVENT, SDL_IGNORE);*/
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
364
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 /* Success! */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 * Close SDL, Cleanups, Free Memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 * params : *plugin
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 * returns : non-zero on success, zero on error.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 static int sdl_close (void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 struct sdl_priv_s *priv = &sdl_priv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 /* Cleanup YUV Overlay structure */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 if (priv->overlay)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 SDL_FreeYUVOverlay(priv->overlay);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385
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 /* Free RGB Surface */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
387 if (priv->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
388 SDL_FreeSurface(priv->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
389
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 /* Free our blitting surface */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 if (priv->surface)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 SDL_FreeSurface(priv->surface);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
394 /* DONT attempt to free the fullscreen modes array. SDL_Quit* does this for us */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 /* Cleanup 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
397 SDL_Quit();
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 //SDL_QuitSubSystem(SDL_INIT_VIDEO);
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 /* might have to be changed to quitsubsystem only, if plugins become
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
400 * changeable on the fly */
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
401
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
402 if(verbose > 2) printf("SDL: Closed Plugin\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406
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 * Sets the specified fullscreen mode.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 * params : mode == index of the desired fullscreen mode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 * returns : doesn't return
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 static void set_fullmode (int mode)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 struct sdl_priv_s *priv = &sdl_priv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 SDL_Surface *newsurface = NULL;
97
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
419 int haspect, waspect = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 /* if we haven't set a fullmode yet, default to the lowest res fullmode first */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 if (mode < 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 mode = priv->fullmode = findArrayEnd(priv->fullmodes) - 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424
97
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
425 /* Calculate proper aspect ratio for fullscreen
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
426 * 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
427 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
428 /* 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
429 if (haspect < 0) {
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
430 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
431 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
432 }
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
433 // 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
434
97
cab74dfde6dd Felix B¸«änemann added support for horizontal scaling for aspect-ratio in
atmosfear
parents: 84
diff changeset
435 /* 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
436 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
437
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438 /* if we were successfull hide the mouse cursor and save the mode */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 if (newsurface) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 priv->surface = newsurface;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 SDL_ShowCursor(0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 }
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
443 //TODO: check if this produces memhole! (no surface freeing)
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 priv->vidpos.x = (priv->surface->w - priv->width) / 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
445 priv->vidpos.y = (priv->surface->h - priv->height) / 2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 * Initialize an SDL surface and an SDL YUV overlay.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 * params : width == width of video we'll be displaying.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 * height == height of video we'll be displaying.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 * fullscreen == want to be fullscreen?
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455 * title == Title for window titlebar.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
456 * returns : non-zero on success, zero on error.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 //static int sdl_setup (int width, int height)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 struct sdl_priv_s *priv = &sdl_priv;
357
681979d4031a - small bugfixes
atmosfear
parents: 355
diff changeset
464 unsigned int sdl_format;
575
3fde7340afd5 Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents: 543
diff changeset
465
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
466 sdl_format = format;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 switch(format){
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
468 case IMGFMT_YV12:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
469 if(verbose) printf("SDL: Using 0x%X (YV12) image format\n", format); break;
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
470 case IMGFMT_IYUV:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
471 if(verbose) printf("SDL: Using 0x%X (IYUV) image format\n", format); break;
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
472 case IMGFMT_YUY2:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
473 if(verbose) printf("SDL: Using 0x%X (YUY2) image format\n", format); break;
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
474 case IMGFMT_UYVY:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
475 if(verbose) printf("SDL: Using 0x%X (UYVY) image format\n", format); break;
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
476 case IMGFMT_YVYU:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
477 if(verbose) printf("SDL: Using 0x%X (YVYU) image format\n", format); break;
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
478 case IMGFMT_I420:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
479 if(verbose) printf("SDL: Using 0x%X (I420) image format\n", format);
542
7eaec864e3d2 doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents: 475
diff changeset
480 printf("SDL: Mapping I420 to IYUV\n");
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
481 sdl_format = SDL_IYUV_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
482 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
483 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
484 if(verbose) printf("SDL: Using 0x%X (BGR15) image format\n", 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
485 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
486 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
487 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
488 if(verbose) printf("SDL: Using 0x%X (RGB15) image format\n", 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
489 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
490 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
491 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
492 if(verbose) printf("SDL: Using 0x%X (BGR16) image format\n", 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
493 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
494 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
495 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
496 if(verbose) printf("SDL: Using 0x%X (RGB16) image format\n", 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
497 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
498 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
499 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
500 if(verbose) printf("SDL: Using 0x%X (BGR24) image format\n", 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
501 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
502 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
503 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
504 if(verbose) printf("SDL: Using 0x%X (RGB24) image format\n", 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
505 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
506 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
507 case IMGFMT_BGR32:
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
508 if(verbose) printf("SDL: Using 0x%X (BGR32) image format\n", 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
509 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
510 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
511 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
512 if(verbose) printf("SDL: Using 0x%X (RGB32) image format\n", 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
513 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
514 break;
451
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
515 default:
542
7eaec864e3d2 doesn't include fastmemcpy.h when SDL_NOXV is defined.
atmosfear
parents: 475
diff changeset
516 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
517 return -1;
e27a365b0303 fixes osd/subtitle for UYVY image format and steps back to 1.15 changes
atmosfear
parents: 448
diff changeset
518 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
519
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
520 sdl_open (NULL, NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
521
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
522 /* Set output window title */
355
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
523 SDL_WM_SetCaption (".: MPlayer : F = Fullscreen/Windowed : C = Cycle Fullscreen Resolutions :.", "SDL Video Out");
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
524 //SDL_WM_SetCaption (title, title);
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
525
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
526 /* Save the original Image size */
84
802fbd1760ae aspect ratio patch by Felix B¸«änemann
arpi_esp
parents: 31
diff changeset
527
648
157cb66e1a43 -x -y quickfix for release, code will be changed completely later.
atmosfear
parents: 637
diff changeset
528 //priv->width = d_width ? d_width : width;
157cb66e1a43 -x -y quickfix for release, code will be changed completely later.
atmosfear
parents: 637
diff changeset
529 //priv->height = d_height ? d_height : height;
157cb66e1a43 -x -y quickfix for release, code will be changed completely later.
atmosfear
parents: 637
diff changeset
530 priv->width = width;
157cb66e1a43 -x -y quickfix for release, code will be changed completely later.
atmosfear
parents: 637
diff changeset
531 priv->height = height;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
532 priv->format = 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
533 priv->windowsize.w = d_width ? d_width : width;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
534 priv->windowsize.h = d_height ? d_height : height;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
535
355
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
536 /* bit 0 (0x01) means fullscreen (-fs)
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
537 * bit 1 (0x02) means mode switching (-vm)
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
538 * bit 2 (0x04) enables software scaling (-zoom)
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
539 */
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
540 // printf("SDL: fullscreenflag is set to: %i\n", fullscreen);
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
541 // printf("SDL: Width: %i Height: %i D_Width %i D_Height: %i\n", width, height, d_width, d_height);
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
542 switch(fullscreen){
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
543 case 0x01:
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
544 case 0x05:
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
545 priv->width = width;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
546 priv->height = height;
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
547 if(verbose) printf("SDL: setting zoomed fullscreen without modeswitching\n");
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
548 printf("SDL: Info - please use -vm (unscaled) or -zoom (scaled) for best fullscreen experience\n");
612
77e0094f0cce some warnings killed
szabii
parents: 580
diff changeset
549 if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags)))
355
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
550 SDL_ShowCursor(0);
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
551 break;
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
552 case 0x02:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
553 if(verbose) printf("SDL: setting nonzoomed fullscreen with modeswitching\n");
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
554 printf("SDL: Info - please use -zoom switch to scale video\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
555 if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags)))
355
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
556 SDL_ShowCursor(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
557 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
558 case 0x04:
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
559 case 0x06:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
560 if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n");
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
561 printf("SDL: Info - please use -vm switch instead if you don't want scaled video\n");
355
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
562 priv->surface=NULL;
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
563 set_fullmode(priv->fullmode);
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
564 break;
70833462dee9 - added code to comply with new fullscreen meaning
atmosfear
parents: 354
diff changeset
565 default:
543
ee0010d0ca81 Changed some code so it only kicks in when XV is disable.
atmosfear
parents: 542
diff changeset
566 if(verbose) printf("SDL: setting windowed mode\n");
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
567 if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlflags))
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
568 && (strcmp(priv->driver, "dga") == 0)) SDL_ShowCursor(0); //TODO: other sdl drivers that are fullscreen only?
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
569 }
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
570 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
571 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
572 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
573 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
574
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
575 switch(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
576 /* 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
577 //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
578 // 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
579 // 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
580 // 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
581 // 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
582 // 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
583 // 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
584 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
585 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 15, 31, 992, 31744, 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
586 printf ("SDL: Couldn't create a RGB surface: %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
587 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
588 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
589 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
590 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
591 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 15, 31744, 992, 31, 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
592 printf ("SDL: Couldn't create a RGB surface: %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
593 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
594 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
595 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
596 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
597 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 16, 31, 2016, 63488, 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
598 printf ("SDL: Couldn't create a RGB surface: %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
599 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
600 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
601 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
602 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
603 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 16, 63488, 2016, 31, 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
604 printf ("SDL: Couldn't create a RGB surface: %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
605 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
606 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
607 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
608 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
609 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 24, 0x0000FF, 0x00FF00, 0xFF0000, 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
610 printf ("SDL: Couldn't create a RGB surface: %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
611 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
612 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
613 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
614 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
615 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 24, 0xFF0000, 0x00FF00, 0x0000FF, 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
616 printf ("SDL: Couldn't create a RGB surface: %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
617 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
618 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
619 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
620 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
621 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000))) {
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
622 printf ("SDL: Couldn't create a RGB surface: %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
623 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
624 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
625 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
626 case IMGFMT_BGR32:
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
627 if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000))) {
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
628 printf ("SDL: Couldn't create a RGB surface: %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
629 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
630 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
631 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
632 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
633 /* Initialize and create the YUV Overlay used for video out */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
634 if (!(priv->overlay = SDL_CreateYUVOverlay (width, height, sdl_format, 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
635 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
636 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
637 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
638 priv->framePlaneY = width * height;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
639 priv->framePlaneUV = (width * height) >> 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
640 priv->stridePlaneY = width;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
641 priv->stridePlaneUV = width/2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
642 }
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
643
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
644 if(priv->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
645 priv->framePlaneRGB = width * height * priv->rgbsurface->format->BytesPerPixel;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
646 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
647 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
648 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
649
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
650
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
651 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
652 * Draw a frame to the SDL YUV overlay.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
653 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
654 * params : *src[] == the Y, U, and V planes that make up the frame.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
655 * returns : non-zero on success, zero on error.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
656 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
657
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
658 //static int sdl_draw_frame (frame_t *frame)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
659 static uint32_t draw_frame(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
660 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
661 struct sdl_priv_s *priv = &sdl_priv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
662 uint8_t *dst;
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
663
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
664 switch(priv->format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
665 case IMGFMT_YV12:
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
666 case IMGFMT_I420:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
667 case IMGFMT_IYUV:
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
668 /*if (SDL_LockYUVOverlay (priv->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
669 if(verbose) printf("SDL: Couldn't lock YUV overlay\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
670 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
671 }*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
672 dst = (uint8_t *) *(priv->overlay->pixels);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
673 memcpy (dst, src[0], priv->framePlaneY);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
674 dst += priv->framePlaneY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
675 memcpy (dst, src[2], priv->framePlaneUV);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
676 dst += priv->framePlaneUV;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
677 memcpy (dst, src[1], priv->framePlaneUV);
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
678 /*SDL_UnlockYUVOverlay (priv->overlay);*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
679 break;
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
680
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
681 case IMGFMT_YUY2:
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
682 case IMGFMT_UYVY:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
683 case IMGFMT_YVYU:
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
684 /*if (SDL_LockYUVOverlay (priv->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
685 if(verbose) printf("SDL: Couldn't lock YUV overlay\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
686 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
687 }*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
688 dst = (uint8_t *) *(priv->overlay->pixels);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
689 memcpy (dst, src[0], priv->width*priv->height*2);
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
690 /*SDL_UnlockYUVOverlay (priv->overlay);*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
691 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
692
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
693 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
694 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
695 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
696 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
697 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
698 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
699 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
700 case IMGFMT_BGR32:
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
701 /*if(SDL_MUSTLOCK(priv->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
702 if (SDL_LockSurface (priv->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
703 if(verbose) printf("SDL: Couldn't lock RGB surface\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
704 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
705 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
706 }*/
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
707 dst = (uint8_t *) priv->rgbsurface->pixels;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
708 memcpy (dst, src[0], priv->framePlaneRGB);
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
709 /*if(SDL_MUSTLOCK(priv->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
710 SDL_UnlockSurface (priv->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
711 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
712
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
713 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
714
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
715 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
716 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
717
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
718
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
719 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
720 * Draw a slice (16 rows of image) to the SDL YUV overlay.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
721 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
722 * params : *src[] == the Y, U, and V planes that make up the slice.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
723 * returns : non-zero on error, zero on success.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
724 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
725
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
726 //static uint32_t draw_slice(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
727 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
728 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
729 struct sdl_priv_s *priv = &sdl_priv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
730 uint8_t *dst;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
731 uint8_t *src;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
732 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
733
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
734 /*if (SDL_LockYUVOverlay (priv->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
735 if(verbose) printf("SDL: Couldn't lock YUV overlay");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
736 return -1;
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
737 }*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
738
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
739 dst = (uint8_t *) *(priv->overlay->pixels)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
740 + (priv->stridePlaneY * y + x);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
741 src = image[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
742 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
743 memcpy(dst,src,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
744 src+=stride[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
745 dst+=priv->stridePlaneY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
746 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
747
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
748 x/=2;y/=2;w/=2;h/=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
749
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
750 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
751 + (priv->stridePlaneUV * y + x);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
752 src = image[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
753 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
754 memcpy(dst,src,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
755 src+=stride[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
756 dst+=priv->stridePlaneUV;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
757 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
758
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
759 dst = (uint8_t *) *(priv->overlay->pixels) + priv->framePlaneY
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
760 + priv->framePlaneUV + (priv->stridePlaneUV * y + x);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
761 src = image[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
762 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
763 memcpy(dst,src,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
764 src+=stride[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
765 dst+=priv->stridePlaneUV;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
766 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
767
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
768 /*SDL_UnlockYUVOverlay (priv->overlay);*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
769
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
770 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
771 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
772
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
773
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
774
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
775 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
776 * Checks for SDL keypress and window resize events
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
777 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
778 * params : none
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
779 * returns : doesn't return
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
780 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
781
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
782 #include "../linux/keycodes.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
783 extern void mplayer_put_key(int code);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
784
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
785 static void check_events (void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
786 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
787 struct sdl_priv_s *priv = &sdl_priv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
788 SDL_Event event;
331
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
789 SDLKey keypressed = 0;
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
790 static int firstcheck = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
791
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
792 /* Poll the waiting SDL Events */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
793 while ( SDL_PollEvent(&event) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
794 switch (event.type) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
795
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
796 /* capture window resize events */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
797 case SDL_VIDEORESIZE:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
798 priv->surface = SDL_SetVideoMode(event.resize.w, event.resize.h, priv->bpp, priv->sdlflags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
799
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
800 /* save video extents, to restore them after going fullscreen */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
801 //if(!(priv->surface->flags & SDL_FULLSCREEN)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
802 priv->windowsize.w = priv->surface->w;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
803 priv->windowsize.h = priv->surface->h;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
804 //}
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
805 if(verbose > 2) printf("SDL: Window resize\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
806 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
807
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
808
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
809 /* graphics mode selection shortcuts */
705
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
810 #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
811 case SDL_KEYDOWN:
705
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
812 switch(event.key.keysym.sym) {
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
813 case SDLK_UP: mplayer_put_key(KEY_UP);break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
814 case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
815 case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
816 case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
817 case SDLK_ASTERISK:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
818 case SDLK_KP_MULTIPLY:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
819 case SDLK_w: mplayer_put_key('*');break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
820 case SDLK_SLASH:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
821 case SDLK_KP_DIVIDE:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
822 case SDLK_s: mplayer_put_key('/');break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
823 }
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
824 break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
825 case SDL_KEYUP:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
826 #else
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
827 case SDL_KEYDOWN:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
828 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
829 keypressed = event.key.keysym.sym;
703
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
830 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
831
357
681979d4031a - small bugfixes
atmosfear
parents: 355
diff changeset
832 /* 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
833 if ( ((keypressed == SDLK_c)) && (priv->fullmodes) ) {
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
834 /* select next fullscreen mode */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
835 priv->fullmode++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
836 if (priv->fullmode > (findArrayEnd(priv->fullmodes) - 1)) priv->fullmode = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
837 set_fullmode(priv->fullmode);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
838
635
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
839 if(verbose > 1) printf("SDL: Set next available fullscreen mode.\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
840 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
841
331
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
842 /* f key pressed toggles/exits fullscreenmode */
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
843 else if ( keypressed == SDLK_f ) {
265
1d02e6f7c63a Only small change to allow pausing of movie (p or SPACE).
atmosfear
parents: 97
diff changeset
844 if (priv->surface->flags & SDL_FULLSCREEN) {
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
845 priv->surface = SDL_SetVideoMode(priv->windowsize.w, priv->windowsize.h, priv->bpp, priv->sdlflags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
846 SDL_ShowCursor(1);
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
847 if(verbose > 1) printf("SDL: Windowed mode\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
848 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
849 else if (priv->fullmodes){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
850 set_fullmode(priv->fullmode);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
851
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
852 if(verbose > 1) printf("SDL: Set fullscreen mode\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
853 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
854 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
855
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
856 else switch(keypressed){
331
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
857 case SDLK_RETURN:
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
858 if (!firstcheck) { firstcheck = 1; break; }
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
859 case SDLK_ESCAPE:
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
860 case SDLK_q:
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
861 SDL_ShowCursor(1);
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
862 mplayer_put_key('q');
0f1737e626fa - Changed keypress-detection from keydown to keyup, seems to fix keyrepeat
atmosfear
parents: 265
diff changeset
863 break;
475
904d1cfda2dd changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents: 451
diff changeset
864 /*case SDLK_o: mplayer_put_key('o');break;
575
3fde7340afd5 Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents: 543
diff changeset
865 case SDLK_SPACE: mplayer_put_key(' ');break;
3fde7340afd5 Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents: 543
diff changeset
866 case SDLK_p: mplayer_put_key('p');break;*/
3fde7340afd5 Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents: 543
diff changeset
867 case SDLK_PLUS:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
868 case SDLK_KP_PLUS: mplayer_put_key('+');break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
869 case SDLK_MINUS:
575
3fde7340afd5 Reincluded fastmemcpy.h and added some keybindings for mixer.
atmosfear
parents: 543
diff changeset
870 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
871 case SDLK_TAB: mplayer_put_key('\t');break;
653
799ef558618d Last second changes.
atmosfear
parents: 648
diff changeset
872 case SDLK_PAGEUP: mplayer_put_key(KEY_PAGE_UP);break;
799ef558618d Last second changes.
atmosfear
parents: 648
diff changeset
873 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
874 #ifdef BUGGY_SDL
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
875 case SDLK_UP:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
876 case SDLK_DOWN:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
877 case SDLK_LEFT:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
878 case SDLK_RIGHT:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
879 case SDLK_ASTERISK:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
880 case SDLK_KP_MULTIPLY:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
881 case SDLK_w:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
882 case SDLK_SLASH:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
883 case SDLK_KP_DIVIDE:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
884 case SDLK_s:
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
885 break;
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
886 #else
703
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
887 case SDLK_UP: mplayer_put_key(KEY_UP);break;
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
888 case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break;
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
889 case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break;
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
890 case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break;
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
891 case SDLK_ASTERISK:
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
892 case SDLK_KP_MULTIPLY:
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
893 case SDLK_w: mplayer_put_key('*');break;
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
894 case SDLK_SLASH:
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
895 case SDLK_KP_DIVIDE:
fcc01494c0fe Fixed keyboard input handling and slowed down keyrepeat interval.
atmosfear
parents: 653
diff changeset
896 case SDLK_s: mplayer_put_key('/');break;
705
27d351f251eb Added workaround for buggy SDL versions (before 1.2.1).
atmosfear
parents: 703
diff changeset
897 #endif
475
904d1cfda2dd changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents: 451
diff changeset
898 default:
904d1cfda2dd changed keyboard input handling to pass key through to mplayer if not special to sdl
atmosfear
parents: 451
diff changeset
899 mplayer_put_key(keypressed);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
900 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
901
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
902 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
903 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
904 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
905 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
906
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
907
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
908 /**
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
909 * Display the surface we have written our data to and check for events.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
910 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
911 * params : mode == index of the desired fullscreen mode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
912 * returns : doesn't return
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
913 **/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
914
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
915 static void flip_page (void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
916 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
917 struct sdl_priv_s *priv = &sdl_priv;
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
918 SDL_Surface *blitconv; // temporary conversion surface
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
919
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
920 /* update osd/subtitles */
351
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
921 vo_draw_text(priv->width,priv->height,draw_alpha);
2c4ded6ffebc - Full OSD and subtitle support added
atmosfear
parents: 350
diff changeset
922
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
923 /* check and react on keypresses and window resizes */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
924 check_events();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
925
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
926 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
927 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
928 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
929 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
930 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
931 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
932 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
933 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
934 case IMGFMT_BGR32:
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
935 /* blit to the 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
936 blitconv = SDL_DisplayFormat(priv->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
937 if(SDL_BlitSurface (blitconv, NULL, priv->surface, &priv->vidpos))
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
938 printf("SDL: Blit failed: %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
939 SDL_FreeSurface(blitconv);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
940
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
941 /*if(SDL_MUSTLOCK(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
942 if (SDL_LockSurface (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
943 if(verbose) printf("SDL: Couldn't lock RGB surface\n");
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
944 return;
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
945 }
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
946 }*/
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
947 /* update screen */
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
948 SDL_UpdateRect(priv->surface, priv->vidpos.x, priv->vidpos.y, priv->width, priv->height);
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
949 /*if(SDL_MUSTLOCK(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
950 SDL_UnlockSurface (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
951
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
952 /* 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
953 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
954 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
955
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
956 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
957 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
958 /* 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
959 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
960
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
961 /* 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
962 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
963 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
964
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 //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
966 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
967 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
968
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
969 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
970 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
971 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
972 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
973 case IMGFMT_YV12:
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
974 case IMGFMT_I420:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
975 case IMGFMT_IYUV:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
976 case IMGFMT_YUY2:
408
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
977 case IMGFMT_UYVY:
b61c5c4484f8 - applied overlay patch by Jens H
atmosfear
parents: 394
diff changeset
978 case IMGFMT_YVYU:
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
979 return 0x6; // hw supported & osd
b9735f811d7d 15,16,24,32Bit rgb/bgr support added, aalib fixed, performance optimizations, code cleanup and so much more...
atmosfear
parents: 616
diff changeset
980 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
981 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
982 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
983 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
984 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
985 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
986 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
987 case IMGFMT_BGR32:
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 return 0x5; // hw supported w/conversion & osd
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
989 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
990 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
991 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
992
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
993 static const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
994 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
995 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
996 return &vo_info;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
997 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
998
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
999
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1000 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1001 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1002 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1003 sdl_close();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1004 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1005