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