1 /*****************************************************************************
2 * vout_sdl.c: SDL video output display method
3 *****************************************************************************
4 * Copyright (C) 1998-2001 VideoLAN
5 * $Id: vout_sdl.c,v 1.76 2002/01/04 14:01:34 sam Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Pierre Baillet <oct@zoy.org>
9 * Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
29 #include <errno.h> /* ENOMEM */
30 #include <stdlib.h> /* free() */
31 #include <string.h> /* strerror() */
33 #include <videolan/vlc.h>
35 #include <sys/types.h>
37 # include <netinet/in.h> /* BSD: struct in_addr */
40 #include SDL_INCLUDE_FILE
45 #include "video_output.h"
47 #include "interface.h"
49 #include "stream_control.h" /* needed by input_ext-intf.h... */
50 #include "input_ext-intf.h"
52 #define SDL_MAX_DIRECTBUFFERS 5
53 #define SDL_DEFAULT_BPP 16
55 /*****************************************************************************
56 * vout_sys_t: video output SDL method descriptor
57 *****************************************************************************
58 * This structure is part of the video output thread descriptor.
59 * It describes the SDL specific properties of an output thread.
60 *****************************************************************************/
61 typedef struct vout_sys_s
63 SDL_Surface * p_display; /* display device */
64 SDL_Overlay * p_overlay; /* An overlay we keep to grab the XVideo port */
70 u32 i_chroma; /* The internally selected chroma */
79 boolean_t b_cursor_autohidden;
84 /*****************************************************************************
85 * picture_sys_t: direct buffer method descriptor
86 *****************************************************************************
87 * This structure is part of the picture descriptor, it describes the
88 * SDL specific properties of a direct buffer.
89 *****************************************************************************/
90 typedef struct picture_sys_s
92 SDL_Overlay *p_overlay;
96 /*****************************************************************************
97 * Seeking function TODO: put this in a generic location !
98 *****************************************************************************/
99 static __inline__ void vout_Seek( off_t i_seek )
101 #define area p_main->p_intf->p_input->stream.p_selected_area
102 off_t i_tell = area->i_tell;
104 i_tell += i_seek * (off_t)50 * p_main->p_intf->p_input->stream.i_mux_rate;
106 i_tell = ( i_tell <= area->i_start ) ? area->i_start
107 : ( i_tell >= area->i_size ) ? area->i_size
110 input_Seek( p_main->p_intf->p_input, i_tell );
114 /*****************************************************************************
115 * Return the best suited FourCC value for a given chroma. We use this
116 * because a decoder may output FOURCC_IYUV, which is exactly the same as
117 * FOURCC_I420, but X servers usually know FOURCC_I420 and not FOURCC_IYUV.
118 *****************************************************************************/
119 static __inline__ u32 BestChroma( u32 i_chroma )
121 /* XXX: don't forget to update vout_Init if you change this */
124 /* These ones are almost the same */
128 return SDL_YV12_OVERLAY;
130 /* These ones are all the same */
134 return SDL_UYVY_OVERLAY;
136 /* These ones are all the same */
139 return SDL_YUY2_OVERLAY;
141 /* We know this one */
143 return SDL_YVYU_OVERLAY;
145 /* This is seldom supported, but we know how to convert it */
147 return SDL_YUY2_OVERLAY;
149 /* We don't know this chroma, but maybe SDL does */
155 /*****************************************************************************
157 *****************************************************************************/
158 static int vout_Probe ( probedata_t *p_data );
159 static int vout_Create ( struct vout_thread_s * );
160 static int vout_Init ( struct vout_thread_s * );
161 static void vout_End ( struct vout_thread_s * );
162 static void vout_Destroy ( struct vout_thread_s * );
163 static int vout_Manage ( struct vout_thread_s * );
164 static void vout_Render ( struct vout_thread_s *, struct picture_s * );
165 static void vout_Display ( struct vout_thread_s *, struct picture_s * );
167 static int SDLOpenDisplay ( vout_thread_t *p_vout );
168 static void SDLCloseDisplay ( vout_thread_t *p_vout );
169 static int SDLNewPicture ( vout_thread_t *p_vout, picture_t *p_pic );
171 /*****************************************************************************
172 * Functions exported as capabilities. They are declared as static so that
173 * we don't pollute the namespace too much.
174 *****************************************************************************/
175 void _M( vout_getfunctions )( function_list_t * p_function_list )
177 p_function_list->pf_probe = vout_Probe;
178 p_function_list->functions.vout.pf_create = vout_Create;
179 p_function_list->functions.vout.pf_init = vout_Init;
180 p_function_list->functions.vout.pf_end = vout_End;
181 p_function_list->functions.vout.pf_destroy = vout_Destroy;
182 p_function_list->functions.vout.pf_manage = vout_Manage;
183 p_function_list->functions.vout.pf_render = vout_Render;
184 p_function_list->functions.vout.pf_display = vout_Display;
185 p_function_list->functions.vout.pf_setpalette = NULL;
188 /*****************************************************************************
189 * vout_Probe: probe the video driver and return a score
190 *****************************************************************************
191 * This function tries to initialize SDL and returns a score to the
192 * plugin manager so that it can select the best plugin.
193 *****************************************************************************/
194 static int vout_Probe( probedata_t *p_data )
196 if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
204 /*****************************************************************************
205 * vout_Create: allocate SDL video thread output method
206 *****************************************************************************
207 * This function allocate and initialize a SDL vout method. It uses some of the
208 * vout properties to choose the correct mode, and change them according to the
209 * mode actually used.
210 *****************************************************************************/
211 static int vout_Create( vout_thread_t *p_vout )
213 if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
218 /* Allocate structure */
219 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
220 if( p_vout->p_sys == NULL )
222 intf_ErrMsg( "vout error: can't create p_sys (%s)", strerror(ENOMEM) );
226 /* Initialize library */
227 if( SDL_Init( SDL_INIT_VIDEO
229 /* Win32 SDL implementation doesn't support SDL_INIT_EVENTTHREAD yet*/
230 | SDL_INIT_EVENTTHREAD
233 /* In debug mode you may want vlc to dump a core instead of staying
235 | SDL_INIT_NOPARACHUTE
239 intf_ErrMsg( "vout error: can't initialize SDL (%s)", SDL_GetError() );
240 free( p_vout->p_sys );
244 p_vout->p_sys->b_cursor = 1;
245 p_vout->p_sys->b_cursor_autohidden = 0;
246 p_vout->p_sys->i_lastmoved = mdate();
248 if( p_vout->render.i_height * p_vout->render.i_aspect
249 >= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
251 p_vout->p_sys->i_width = p_vout->render.i_height
252 * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
253 p_vout->p_sys->i_height = p_vout->render.i_height;
257 p_vout->p_sys->i_width = p_vout->render.i_width;
258 p_vout->p_sys->i_height = p_vout->render.i_width
259 * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
263 if( p_vout->p_sys->i_width <= 300 && p_vout->p_sys->i_height <= 300 )
265 p_vout->p_sys->i_width <<= 1;
266 p_vout->p_sys->i_height <<= 1;
268 else if( p_vout->p_sys->i_width <= 400 && p_vout->p_sys->i_height <= 400 )
270 p_vout->p_sys->i_width += p_vout->p_sys->i_width >> 1;
271 p_vout->p_sys->i_height += p_vout->p_sys->i_height >> 1;
275 if( SDLOpenDisplay( p_vout ) )
277 intf_ErrMsg( "vout error: can't set up SDL (%s)", SDL_GetError() );
278 SDL_QuitSubSystem( SDL_INIT_VIDEO );
279 free( p_vout->p_sys );
286 /*****************************************************************************
287 * vout_Init: initialize SDL video thread output method
288 *****************************************************************************
289 * This function initialize the SDL display device.
290 *****************************************************************************/
291 static int vout_Init( vout_thread_t *p_vout )
296 p_vout->p_sys->i_surfaces = 0;
298 I_OUTPUTPICTURES = 0;
300 /* Initialize the output structure */
301 if( p_vout->p_sys->p_overlay == NULL )
303 /* All we have is an RGB image with square pixels */
304 p_vout->output.i_chroma = p_vout->p_sys->i_chroma;
305 p_vout->output.i_width = p_vout->p_sys->i_width;
306 p_vout->output.i_height = p_vout->p_sys->i_height;
307 p_vout->output.i_aspect = p_vout->p_sys->i_width
309 / p_vout->p_sys->i_height;
313 switch( p_vout->render.i_chroma )
327 /* We can directly handle all these chromas */
328 p_vout->output.i_chroma = p_vout->render.i_chroma;
329 p_vout->output.i_width = p_vout->render.i_width;
330 p_vout->output.i_height = p_vout->render.i_height;
331 p_vout->output.i_aspect = p_vout->render.i_aspect;
335 /* We need to convert this one, but at least we keep the
337 p_vout->output.i_chroma = p_vout->p_sys->i_chroma;
338 p_vout->output.i_width = p_vout->render.i_width;
339 p_vout->output.i_height = p_vout->render.i_height;
340 p_vout->output.i_aspect = p_vout->render.i_aspect;
344 /* All we have is an RGB image with square pixels */
345 p_vout->output.i_chroma = p_vout->p_sys->i_chroma;
346 p_vout->output.i_width = p_vout->p_sys->i_width;
347 p_vout->output.i_height = p_vout->p_sys->i_height;
348 p_vout->output.i_aspect = p_vout->p_sys->i_width
350 / p_vout->p_sys->i_height;
355 /* Try to initialize SDL_MAX_DIRECTBUFFERS direct buffers */
356 while( I_OUTPUTPICTURES < SDL_MAX_DIRECTBUFFERS )
360 /* Find an empty picture slot */
361 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
363 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
365 p_pic = p_vout->p_picture + i_index;
370 /* Allocate the picture if we found one */
371 if( p_pic == NULL || SDLNewPicture( p_vout, p_pic ) )
376 p_pic->i_status = DESTROYED_PICTURE;
377 p_pic->i_type = DIRECT_PICTURE;
379 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
387 /*****************************************************************************
388 * vout_End: terminate Sys video thread output method
389 *****************************************************************************
390 * Terminate an output method created by vout_SDLCreate
391 *****************************************************************************/
392 static void vout_End( vout_thread_t *p_vout )
396 /* Free the output buffers we allocated */
397 for( i_index = I_OUTPUTPICTURES ; i_index ; )
400 if( p_vout->p_sys->p_overlay == NULL )
406 SDL_UnlockYUVOverlay(
407 PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
409 PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
411 free( PP_OUTPUTPICTURE[ i_index ]->p_sys );
415 /*****************************************************************************
416 * vout_Destroy: destroy Sys video thread output method
417 *****************************************************************************
418 * Terminate an output method created by vout_SDLCreate
419 *****************************************************************************/
420 static void vout_Destroy( vout_thread_t *p_vout )
422 SDLCloseDisplay( p_vout );
424 SDL_QuitSubSystem( SDL_INIT_VIDEO );
426 free( p_vout->p_sys );
429 /*****************************************************************************
430 * vout_Manage: handle Sys events
431 *****************************************************************************
432 * This function should be called regularly by video output thread. It returns
433 * a non null value if an error occured.
434 *****************************************************************************/
435 static int vout_Manage( vout_thread_t *p_vout )
437 SDL_Event event; /* SDL event */
440 while( SDL_PollEvent(&event) )
444 case SDL_VIDEORESIZE: /* Resizing of window */
445 p_vout->p_sys->i_width = event.resize.w;
446 p_vout->p_sys->i_height = event.resize.h;
447 SDLCloseDisplay( p_vout );
448 SDLOpenDisplay( p_vout );
451 case SDL_MOUSEMOTION:
452 if( p_vout->p_sys->b_cursor &&
453 (abs(event.motion.xrel) > 2 || abs(event.motion.yrel) > 2) )
455 if( p_vout->p_sys->b_cursor_autohidden )
457 p_vout->p_sys->b_cursor_autohidden = 0;
462 p_vout->p_sys->i_lastmoved = mdate();
467 case SDL_MOUSEBUTTONUP:
468 switch( event.button.button )
470 case SDL_BUTTON_RIGHT:
471 p_main->p_intf->b_menu_change = 1;
476 case SDL_MOUSEBUTTONDOWN:
477 switch( event.button.button )
479 case SDL_BUTTON_LEFT:
480 /* In this part we will eventually manage
481 * clicks for DVD navigation for instance. For the
482 * moment just pause the stream. */
483 input_SetStatus( p_main->p_intf->p_input, INPUT_STATUS_PAUSE );
497 p_main->p_intf->b_die = 1;
500 case SDL_KEYDOWN: /* if a key is pressed */
502 switch( event.key.keysym.sym )
504 case SDLK_q: /* quit */
506 p_main->p_intf->b_die = 1;
509 case SDLK_f: /* switch to fullscreen */
510 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
513 case SDLK_c: /* toggle grayscale */
514 p_vout->b_grayscale = ! p_vout->b_grayscale;
515 p_vout->i_changes |= VOUT_GRAYSCALE_CHANGE;
518 case SDLK_i: /* toggle info */
519 p_vout->b_info = ! p_vout->b_info;
520 p_vout->i_changes |= VOUT_INFO_CHANGE;
523 case SDLK_s: /* toggle scaling */
524 p_vout->b_scale = ! p_vout->b_scale;
525 p_vout->i_changes |= VOUT_SCALE_CHANGE;
528 case SDLK_SPACE: /* toggle interface */
529 p_vout->b_interface = ! p_vout->b_interface;
530 p_vout->i_changes |= VOUT_INTF_CHANGE;
534 p_main->p_intf->b_menu_change = 1;
553 case SDLK_F10: network_ChannelJoin( 0 ); break;
554 case SDLK_F1: network_ChannelJoin( 1 ); break;
555 case SDLK_F2: network_ChannelJoin( 2 ); break;
556 case SDLK_F3: network_ChannelJoin( 3 ); break;
557 case SDLK_F4: network_ChannelJoin( 4 ); break;
558 case SDLK_F5: network_ChannelJoin( 5 ); break;
559 case SDLK_F6: network_ChannelJoin( 6 ); break;
560 case SDLK_F7: network_ChannelJoin( 7 ); break;
561 case SDLK_F8: network_ChannelJoin( 8 ); break;
562 case SDLK_F9: network_ChannelJoin( 9 ); break;
565 intf_DbgMsg( "unhandled key %i", event.key.keysym.sym );
575 /* Fullscreen change */
576 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
578 p_vout->b_fullscreen = ! p_vout->b_fullscreen;
580 SDL_WM_ToggleFullScreen(p_vout->p_sys->p_display);
582 p_vout->p_sys->b_cursor_autohidden = 0;
583 SDL_ShowCursor( p_vout->p_sys->b_cursor &&
584 ! p_vout->p_sys->b_cursor_autohidden );
586 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
590 if( ! p_vout->p_sys->b_cursor_autohidden &&
591 ( mdate() - p_vout->p_sys->i_lastmoved > 2000000 ) )
593 /* Hide the mouse automatically */
594 p_vout->p_sys->b_cursor_autohidden = 1;
601 /*****************************************************************************
602 * vout_Render: render previously calculated output
603 *****************************************************************************/
604 static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
609 /*****************************************************************************
610 * vout_Display: displays previously rendered output
611 *****************************************************************************
612 * This function sends the currently rendered image to the display.
613 *****************************************************************************/
614 static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
619 vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height,
626 if( p_vout->p_sys->p_overlay == NULL )
629 SDL_Flip( p_vout->p_sys->p_display );
633 /* Overlay picture */
634 SDL_UnlockYUVOverlay( p_pic->p_sys->p_overlay);
635 SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
636 SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
640 /* following functions are local */
642 /*****************************************************************************
643 * SDLOpenDisplay: open and initialize SDL device
644 *****************************************************************************
645 * Open and initialize display according to preferences specified in the vout
647 *****************************************************************************/
648 static int SDLOpenDisplay( vout_thread_t *p_vout )
653 /* Initialize flags and cursor */
654 i_flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE | SDL_DOUBLEBUF;
655 i_flags |= p_vout->b_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE;
657 i_bpp = SDL_VideoModeOK( p_vout->p_sys->i_width, p_vout->p_sys->i_height,
658 SDL_DEFAULT_BPP, i_flags );
661 intf_ErrMsg( "vout error: no video mode available" );
665 p_vout->p_sys->p_display = SDL_SetVideoMode( p_vout->p_sys->i_width,
666 p_vout->p_sys->i_height,
669 if( p_vout->p_sys->p_display == NULL )
671 intf_ErrMsg( "vout error: cannot set video mode" );
675 SDL_LockSurface( p_vout->p_sys->p_display );
677 /* Ask BestChroma what we should use as a chroma */
678 p_vout->p_sys->i_chroma = BestChroma( p_vout->render.i_chroma );
680 p_vout->p_sys->p_overlay =
681 SDL_CreateYUVOverlay( 32, 32, p_vout->p_sys->i_chroma,
682 p_vout->p_sys->p_display );
684 /* See if BestChroma's guess was valid */
685 if( p_vout->p_sys->p_overlay == NULL )
687 intf_WarnMsg( 3, "vout warning: cannot set SDL overlay 0x%.8llx",
688 p_vout->p_sys->i_chroma );
690 switch( p_vout->p_sys->p_display->format->BitsPerPixel )
693 p_vout->p_sys->i_chroma = FOURCC_BI_RGB;
696 p_vout->p_sys->i_chroma = FOURCC_RV15;
699 p_vout->p_sys->i_chroma = FOURCC_RV16;
702 p_vout->p_sys->i_chroma = FOURCC_BI_BITFIELDS;
705 p_vout->p_sys->i_chroma = FOURCC_BI_BITFIELDS;
708 intf_ErrMsg( "vout error: unknown screen depth" );
709 SDL_UnlockSurface( p_vout->p_sys->p_display );
710 SDL_FreeSurface( p_vout->p_sys->p_display );
714 p_vout->p_sys->i_red_mask = p_vout->p_sys->p_display->format->Rmask;
715 p_vout->p_sys->i_green_mask = p_vout->p_sys->p_display->format->Gmask;
716 p_vout->p_sys->i_blue_mask = p_vout->p_sys->p_display->format->Bmask;
718 SDL_WM_SetCaption( VOUT_TITLE " (software RGB SDL output)",
719 VOUT_TITLE " (software RGB SDL output)" );
723 if( p_vout->p_sys->p_overlay->hw_overlay )
725 SDL_WM_SetCaption( VOUT_TITLE " (hardware YUV SDL output)",
726 VOUT_TITLE " (hardware YUV SDL output)" );
730 SDL_WM_SetCaption( VOUT_TITLE " (software YUV SDL output)",
731 VOUT_TITLE " (software YUV SDL output)" );
735 SDL_EventState( SDL_KEYUP, SDL_IGNORE ); /* ignore keys up */
740 /*****************************************************************************
741 * SDLCloseDisplay: close and reset SDL device
742 *****************************************************************************
743 * This function returns all resources allocated by SDLOpenDisplay and restore
744 * the original state of the device.
745 *****************************************************************************/
746 static void SDLCloseDisplay( vout_thread_t *p_vout )
748 SDL_FreeYUVOverlay( p_vout->p_sys->p_overlay );
749 SDL_UnlockSurface ( p_vout->p_sys->p_display );
750 SDL_FreeSurface( p_vout->p_sys->p_display );
753 /*****************************************************************************
754 * SDLNewPicture: allocate a picture
755 *****************************************************************************
756 * Returns 0 on success, -1 otherwise
757 *****************************************************************************/
758 static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
760 int i_width = p_vout->output.i_width;
761 int i_height = p_vout->output.i_height;
763 switch( p_vout->p_sys->i_chroma )
765 case SDL_YV12_OVERLAY:
766 case SDL_IYUV_OVERLAY:
767 case SDL_YUY2_OVERLAY:
768 case SDL_UYVY_OVERLAY:
769 case SDL_YVYU_OVERLAY:
770 p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
772 if( p_pic->p_sys == NULL )
777 p_pic->p_sys->p_overlay =
778 SDL_CreateYUVOverlay( i_width, i_height,
779 p_vout->p_sys->i_chroma,
780 p_vout->p_sys->p_display );
782 if( p_pic->p_sys->p_overlay == NULL )
784 free( p_pic->p_sys );
788 SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
790 p_pic->Y_PIXELS = p_pic->p_sys->p_overlay->pixels[0];
791 p_pic->p[Y_PLANE].i_lines = p_pic->p_sys->p_overlay->h;
792 p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[0];
794 switch( p_vout->p_sys->i_chroma )
796 case SDL_YV12_OVERLAY:
797 p_pic->p[Y_PLANE].i_pixel_bytes = 1;
798 p_pic->p[Y_PLANE].b_margin = 0;
800 p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
801 p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
802 p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
803 p_pic->p[U_PLANE].i_pixel_bytes = 1;
804 p_pic->p[U_PLANE].b_margin = 0;
806 p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
807 p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
808 p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
809 p_pic->p[V_PLANE].i_pixel_bytes = 1;
810 p_pic->p[V_PLANE].b_margin = 0;
815 case SDL_IYUV_OVERLAY:
816 p_pic->p[Y_PLANE].i_pixel_bytes = 1;
817 p_pic->p[Y_PLANE].b_margin = 0;
819 p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
820 p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
821 p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
822 p_pic->p[U_PLANE].i_pixel_bytes = 1;
823 p_pic->p[U_PLANE].b_margin = 0;
825 p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
826 p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
827 p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
828 p_pic->p[V_PLANE].i_pixel_bytes = 1;
829 p_pic->p[V_PLANE].b_margin = 0;
835 p_pic->p[Y_PLANE].i_pixel_bytes = 2;
836 p_pic->p[Y_PLANE].b_margin = 0;
846 if( p_vout->p_sys->i_surfaces )
848 /* We already allocated this surface, return */
852 p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
854 if( p_pic->p_sys == NULL )
859 p_pic->p->p_pixels = p_vout->p_sys->p_display->pixels;
860 p_pic->p->i_lines = p_vout->p_sys->p_display->h;
861 p_pic->p->i_pitch = p_vout->p_sys->p_display->pitch;
863 p_pic->p->i_pixel_bytes = 2;
864 if( p_pic->p->i_pitch != 2 * p_vout->p_sys->p_display->w )
866 intf_ErrMsg("OOO XXX OOO --- Wooooooohoooo !! --- OOO XXX OOO");
867 intf_ErrMsg("%i != 2 * %i", p_pic->p->i_pitch, p_vout->p_sys->p_display->w );
869 p_pic->p->b_margin = 0;
871 p_pic->p->i_red_mask = p_vout->p_sys->p_display->format->Rmask;
872 p_pic->p->i_green_mask = p_vout->p_sys->p_display->format->Gmask;
873 p_pic->p->i_blue_mask = p_vout->p_sys->p_display->format->Bmask;
875 p_vout->p_sys->i_surfaces++;