annotate libvo/vo_sdl.c @ 400:ae91bfef2a94

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