1 /*****************************************************************************
2 * video_output.c : video output thread
3 * This module describes the programming interface for video output threads.
4 * It includes functions allowing to open a new thread, send pictures to a
5 * thread, and destroy a previously oppened video output thread.
6 *****************************************************************************
7 * Copyright (C) 2000 VideoLAN
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 *****************************************************************************/
31 #include <errno.h> /* ENOMEM */
32 #include <stdlib.h> /* free() */
33 #include <stdio.h> /* sprintf() */
34 #include <string.h> /* strerror() */
37 # include <sys/times.h>
46 #include "video_output.h"
47 #include "video_text.h"
48 #include "video_spu.h"
49 #include "video_yuv.h"
54 /*****************************************************************************
56 *****************************************************************************/
57 static int BinaryLog ( u32 i );
58 static void MaskToShift ( int *pi_left, int *pi_right, u32 i_mask );
59 static int InitThread ( vout_thread_t *p_vout );
60 static void RunThread ( vout_thread_t *p_vout );
61 static void ErrorThread ( vout_thread_t *p_vout );
62 static void EndThread ( vout_thread_t *p_vout );
63 static void DestroyThread ( vout_thread_t *p_vout, int i_status );
64 static void Print ( vout_thread_t *p_vout, int i_x, int i_y,
65 int i_h_align, int i_v_align,
66 unsigned char *psz_text );
67 static void SetBufferArea ( vout_thread_t *p_vout, int i_x, int i_y,
69 static void SetBufferPicture ( vout_thread_t *p_vout, picture_t *p_pic );
70 static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
71 static void RenderPictureInfo ( vout_thread_t *p_vout, picture_t *p_pic );
72 static void RenderSubPicture ( vout_thread_t *p_vout,
73 subpicture_t *p_subpic );
74 static void RenderInterface ( vout_thread_t *p_vout );
75 static int RenderIdle ( vout_thread_t *p_vout );
76 static int RenderSplash ( vout_thread_t *p_vout );
77 static void RenderInfo ( vout_thread_t *p_vout );
78 static int Manage ( vout_thread_t *p_vout );
79 static int Align ( vout_thread_t *p_vout, int *pi_x,
80 int *pi_y, int i_width, int i_height,
81 int i_h_align, int i_v_align );
82 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
83 u16 *green, u16 *blue, u16 *transp );
85 /*****************************************************************************
86 * vout_CreateThread: creates a new video output thread
87 *****************************************************************************
88 * This function creates a new video output thread, and returns a pointer
89 * to its description. On error, it returns NULL.
90 * If pi_status is NULL, then the function will block until the thread is ready.
91 * If not, it will be updated using one of the THREAD_* constants.
92 *****************************************************************************/
93 vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window,
94 int i_width, int i_height, int *pi_status,
95 int i_method, void *p_data )
97 vout_thread_t * p_vout; /* thread descriptor */
98 typedef void ( vout_getplugin_t ) ( vout_thread_t * p_vout );
99 int i_status; /* thread status */
100 int i_index; /* index for array initialization */
101 int i_best_index = 0, i_best_score = 0;
103 /* Allocate descriptor */
104 p_vout = (vout_thread_t *) malloc( sizeof(vout_thread_t) );
107 intf_ErrMsg( "vout error: vout thread creation returned %s",
112 p_vout->p_set_palette = SetPalette;
114 /* Get a suitable video plugin */
115 for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
117 /* If there's a plugin in p_info ... */
118 if( p_main->p_bank->p_info[ i_index ] != NULL )
120 /* ... and if this plugin provides the functions we want ... */
121 if( p_main->p_bank->p_info[ i_index ]->vout_GetPlugin != NULL )
123 /* ... and if this plugin has a good score ... */
124 if( p_main->p_bank->p_info[ i_index ]->i_score > i_best_score )
126 /* ... then take it */
127 i_best_score = p_main->p_bank->p_info[ i_index ]->i_score;
128 i_best_index = i_index;
134 if( i_best_score == 0 )
140 /* Get the plugin functions */
141 ( (vout_getplugin_t *)
142 p_main->p_bank->p_info[ i_best_index ]->vout_GetPlugin )( p_vout );
144 /* Initialize thread properties - thread id and locks will be initialized
148 p_vout->b_active = 0;
149 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
150 *p_vout->pi_status = THREAD_CREATE;
152 /* Initialize some fields used by the system-dependant method - these
153 * fields will probably be modified by the method, and are only
155 p_vout->i_changes = 0;
156 p_vout->i_width = i_width;
157 p_vout->i_height = i_height;
158 p_vout->i_bytes_per_line = i_width * 2;
159 p_vout->i_screen_depth = 15;
160 p_vout->i_bytes_per_pixel = 2;
161 p_vout->f_gamma = VOUT_GAMMA;
162 p_vout->b_need_render = 1;
164 p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
165 VOUT_GRAYSCALE_DEFAULT );
167 p_vout->b_interface = 0;
170 intf_DbgMsg( "wished configuration: %dx%d, %d/%d bpp (%d Bpl)",
171 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
172 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
174 /* Initialize idle screen */
175 p_vout->last_display_date = 0;
176 p_vout->last_idle_date = 0;
177 p_vout->init_display_date = mdate();
178 p_vout->render_time = 10000;
180 /* Initialize statistics fields */
181 p_vout->c_fps_samples = 0;
183 /* Initialize buffer index */
184 p_vout->i_buffer_index = 0;
186 /* Initialize pictures and subpictures - translation tables and functions
187 * will be initialized later in InitThread */
188 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
190 p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
191 p_vout->p_picture[i_index].i_status = FREE_PICTURE;
193 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
195 p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
196 p_vout->p_subpicture[i_index].i_status= FREE_SUBPICTURE;
198 p_vout->i_pictures = 0;
200 /* Create and initialize system-dependant method - this function issues its
201 * own error messages */
202 if( p_vout->p_sys_create( p_vout, psz_display, i_root_window, p_data ) )
207 intf_DbgMsg( "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
208 "masks: 0x%x/0x%x/0x%x",
209 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
210 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
211 p_vout->i_red_mask, p_vout->i_green_mask,
212 p_vout->i_blue_mask );
214 /* Calculate shifts from system-updated masks */
215 MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
216 p_vout->i_red_mask );
217 MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
218 p_vout->i_green_mask );
219 MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
220 p_vout->i_blue_mask );
222 /* Set some useful colors */
223 p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
224 p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
225 p_vout->i_gray_pixel = RGB2PIXEL( p_vout, 128, 128, 128 );
226 p_vout->i_blue_pixel = RGB2PIXEL( p_vout, 0, 0, 50 );
228 /* Load fonts - fonts must be initialized after the system method since
229 * they may be dependant on screen depth and other thread properties */
230 p_vout->p_default_font = vout_LoadFont( DATA_PATH "/" VOUT_DEFAULT_FONT );
231 if( p_vout->p_default_font == NULL )
233 p_vout->p_default_font = vout_LoadFont( "share/" VOUT_DEFAULT_FONT );
235 if( p_vout->p_default_font == NULL )
237 intf_ErrMsg( "vout error: could not load default font" );
238 p_vout->p_sys_destroy( p_vout );
242 p_vout->p_large_font = vout_LoadFont( DATA_PATH "/" VOUT_LARGE_FONT );
243 if( p_vout->p_large_font == NULL )
245 p_vout->p_large_font = vout_LoadFont( "share/" VOUT_LARGE_FONT );
247 if( p_vout->p_large_font == NULL )
249 intf_ErrMsg( "vout error: could not load large font" );
250 vout_UnloadFont( p_vout->p_default_font );
251 p_vout->p_sys_destroy( p_vout );
256 /* Create thread and set locks */
257 vlc_mutex_init( &p_vout->picture_lock );
258 vlc_mutex_init( &p_vout->subpicture_lock );
259 vlc_mutex_init( &p_vout->change_lock );
261 if( vlc_thread_create( &p_vout->thread_id, "video output",
262 (void *) RunThread, (void *) p_vout) )
264 intf_ErrMsg("vout error: %s", strerror(ENOMEM));
265 vout_UnloadFont( p_vout->p_default_font );
266 vout_UnloadFont( p_vout->p_large_font );
267 p_vout->p_sys_destroy( p_vout );
272 intf_Msg( "Video display initialized (%dx%d, %d/%d bpp)", p_vout->i_width,
273 p_vout->i_height, p_vout->i_screen_depth,
274 p_vout->i_bytes_per_pixel * 8 );
276 /* If status is NULL, wait until the thread is created */
277 if( pi_status == NULL )
281 msleep( THREAD_SLEEP );
282 }while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
283 && (i_status != THREAD_FATAL) );
284 if( i_status != THREAD_READY )
292 /*****************************************************************************
293 * vout_DestroyThread: destroys a previously created thread
294 *****************************************************************************
295 * Destroy a terminated thread.
296 * The function will request a destruction of the specified thread. If pi_error
297 * is NULL, it will return once the thread is destroyed. Else, it will be
298 * update using one of the THREAD_* constants.
299 *****************************************************************************/
300 void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
302 int i_status; /* thread status */
306 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
307 *p_vout->pi_status = THREAD_DESTROY;
309 /* Request thread destruction */
312 /* If status is NULL, wait until thread has been destroyed */
313 if( pi_status == NULL )
317 msleep( THREAD_SLEEP );
318 }while( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
319 && (i_status != THREAD_FATAL) );
323 /*****************************************************************************
324 * vout_DisplaySubPicture: display a subpicture unit
325 *****************************************************************************
326 * Remove the reservation flag of an subpicture, which will cause it to be ready
327 * for display. The picture does not need to be locked, since it is ignored by
328 * the output thread if is reserved.
329 *****************************************************************************/
330 void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
333 char psz_begin_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
334 char psz_end_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
338 /* Check if status is valid */
339 if( p_subpic->i_status != RESERVED_SUBPICTURE )
341 intf_DbgMsg("error: subpicture %p has invalid status %d", p_subpic,
342 p_subpic->i_status );
346 /* Remove reservation flag */
347 p_subpic->i_status = READY_SUBPICTURE;
350 /* Send subpicture information */
351 intf_DbgMsg("subpicture %p: type=%d, begin date=%s, end date=%s",
352 p_subpic, p_subpic->i_type,
353 mstrtime( psz_begin_date, p_subpic->begin_date ),
354 mstrtime( psz_end_date, p_subpic->end_date ) );
358 /*****************************************************************************
359 * vout_CreateSubPicture: allocate a subpicture in the video output heap.
360 *****************************************************************************
361 * This function create a reserved subpicture in the video output heap.
362 * A null pointer is returned if the function fails. This method provides an
363 * already allocated zone of memory in the spu data fields. It needs locking
364 * since several pictures can be created by several producers threads.
365 *****************************************************************************/
366 subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
369 int i_subpic; /* subpicture index */
370 subpicture_t * p_free_subpic = NULL; /* first free subpicture */
371 subpicture_t * p_destroyed_subpic = NULL; /* first destroyed subpic */
374 vlc_mutex_lock( &p_vout->subpicture_lock );
377 * Look for an empty place
379 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
381 if( p_vout->p_subpicture[i_subpic].i_status == DESTROYED_SUBPICTURE )
383 /* Subpicture is marked for destruction, but is still allocated */
384 if( (p_vout->p_subpicture[i_subpic].i_type == i_type) &&
385 (p_vout->p_subpicture[i_subpic].i_size >= i_size) )
387 /* Memory size do match or is smaller : memory will not be
388 * reallocated, and function can end immediately - this is
389 * the best possible case, since no memory allocation needs
391 p_vout->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
393 intf_DbgMsg("subpicture %p (in destroyed subpicture slot)",
394 &p_vout->p_subpicture[i_subpic] );
396 vlc_mutex_unlock( &p_vout->subpicture_lock );
397 return( &p_vout->p_subpicture[i_subpic] );
399 else if( p_destroyed_subpic == NULL )
401 /* Memory size do not match, but subpicture index will be kept in
402 * case no other place are left */
403 p_destroyed_subpic = &p_vout->p_subpicture[i_subpic];
406 else if( (p_free_subpic == NULL) &&
407 (p_vout->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE ))
409 /* Subpicture is empty and ready for allocation */
410 p_free_subpic = &p_vout->p_subpicture[i_subpic];
414 /* If no free subpictures are available, use a destroyed subpicture */
415 if( (p_free_subpic == NULL) && (p_destroyed_subpic != NULL ) )
417 /* No free subpicture or matching destroyed subpictures have been
418 * found, but a destroyed subpicture is still avalaible */
419 free( p_destroyed_subpic->p_data );
420 p_free_subpic = p_destroyed_subpic;
426 if( p_free_subpic != NULL )
428 /* Allocate memory */
431 case TEXT_SUBPICTURE: /* text subpicture */
432 p_free_subpic->p_data = malloc( i_size + 1 );
434 case DVD_SUBPICTURE: /* DVD subpicture unit */
435 p_free_subpic->p_data = malloc( i_size );
439 intf_DbgMsg("error: unknown subpicture type %d", i_type );
440 p_free_subpic->p_data = NULL;
445 if( p_free_subpic->p_data != NULL )
447 /* Copy subpicture information, set some default values */
448 p_free_subpic->i_type = i_type;
449 p_free_subpic->i_status = RESERVED_SUBPICTURE;
450 p_free_subpic->i_size = i_size;
451 p_free_subpic->i_x = 0;
452 p_free_subpic->i_y = 0;
453 p_free_subpic->i_width = 0;
454 p_free_subpic->i_height = 0;
455 p_free_subpic->i_horizontal_align = CENTER_RALIGN;
456 p_free_subpic->i_vertical_align = CENTER_RALIGN;
460 /* Memory allocation failed : set subpicture as empty */
461 p_free_subpic->i_type = EMPTY_SUBPICTURE;
462 p_free_subpic->i_status = FREE_SUBPICTURE;
463 p_free_subpic = NULL;
464 intf_ErrMsg( "vout error: spu allocation returned %s",
465 strerror( ENOMEM ) );
469 intf_DbgMsg("subpicture %p (in free subpicture slot)", p_free_subpic );
471 vlc_mutex_unlock( &p_vout->subpicture_lock );
472 return( p_free_subpic );
475 /* No free or destroyed subpicture could be found */
476 intf_DbgMsg( "warning: subpicture heap is full" );
477 vlc_mutex_unlock( &p_vout->subpicture_lock );
481 /*****************************************************************************
482 * vout_DestroySubPicture: remove a subpicture from the heap
483 *****************************************************************************
484 * This function frees a previously reserved subpicture.
485 * It is meant to be used when the construction of a picture aborted.
486 * This function does not need locking since reserved subpictures are ignored
487 * by the output thread.
488 *****************************************************************************/
489 void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
492 /* Check if status is valid */
493 if( p_subpic->i_status != RESERVED_SUBPICTURE )
495 intf_DbgMsg("error: subpicture %p has invalid status %d",
496 p_subpic, p_subpic->i_status );
500 p_subpic->i_status = DESTROYED_SUBPICTURE;
503 intf_DbgMsg("subpicture %p", p_subpic);
507 /*****************************************************************************
508 * vout_DisplayPicture: display a picture
509 *****************************************************************************
510 * Remove the reservation flag of a picture, which will cause it to be ready for
511 * display. The picture won't be displayed until vout_DatePicture has been
513 *****************************************************************************/
514 void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
516 vlc_mutex_lock( &p_vout->picture_lock );
517 switch( p_pic->i_status )
519 case RESERVED_PICTURE:
520 p_pic->i_status = RESERVED_DISP_PICTURE;
522 case RESERVED_DATED_PICTURE:
523 p_pic->i_status = READY_PICTURE;
527 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
533 intf_DbgMsg("picture %p", p_pic);
535 vlc_mutex_unlock( &p_vout->picture_lock );
538 /*****************************************************************************
539 * vout_DatePicture: date a picture
540 *****************************************************************************
541 * Remove the reservation flag of a picture, which will cause it to be ready for
542 * display. The picture won't be displayed until vout_DisplayPicture has been
544 *****************************************************************************/
545 void vout_DatePicture( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date )
548 char psz_date[MSTRTIME_MAX_SIZE]; /* date */
551 vlc_mutex_lock( &p_vout->picture_lock );
553 switch( p_pic->i_status )
555 case RESERVED_PICTURE:
556 p_pic->i_status = RESERVED_DATED_PICTURE;
558 case RESERVED_DISP_PICTURE:
559 p_pic->i_status = READY_PICTURE;
563 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
569 intf_DbgMsg("picture %p, display date: %s", p_pic, mstrtime( psz_date, p_pic->date) );
571 vlc_mutex_unlock( &p_vout->picture_lock );
574 /*****************************************************************************
575 * vout_CreatePicture: allocate a picture in the video output heap.
576 *****************************************************************************
577 * This function create a reserved image in the video output heap.
578 * A null pointer is returned if the function fails. This method provides an
579 * already allocated zone of memory in the picture data fields. It needs locking
580 * since several pictures can be created by several producers threads.
581 *****************************************************************************/
582 picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
583 int i_width, int i_height )
585 int i_picture; /* picture index */
586 int i_chroma_width = 0; /* chroma width */
587 picture_t * p_free_picture = NULL; /* first free picture */
588 picture_t * p_destroyed_picture = NULL; /* first destroyed picture */
591 vlc_mutex_lock( &p_vout->picture_lock );
594 * Look for an empty place
596 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
598 if( p_vout->p_picture[i_picture].i_status == DESTROYED_PICTURE )
600 /* Picture is marked for destruction, but is still allocated - note
601 * that if width and type are the same for two pictures, chroma_width
602 * should also be the same */
603 if( (p_vout->p_picture[i_picture].i_type == i_type) &&
604 (p_vout->p_picture[i_picture].i_height == i_height) &&
605 (p_vout->p_picture[i_picture].i_width == i_width) )
607 /* Memory size do match : memory will not be reallocated, and function
608 * can end immediately - this is the best possible case, since no
609 * memory allocation needs to be done */
610 p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
611 p_vout->i_pictures++;
613 intf_DbgMsg("picture %p (in destroyed picture slot)",
614 &p_vout->p_picture[i_picture] );
616 vlc_mutex_unlock( &p_vout->picture_lock );
617 return( &p_vout->p_picture[i_picture] );
619 else if( p_destroyed_picture == NULL )
621 /* Memory size do not match, but picture index will be kept in
622 * case no other place are left */
623 p_destroyed_picture = &p_vout->p_picture[i_picture];
626 else if( (p_free_picture == NULL) &&
627 (p_vout->p_picture[i_picture].i_status == FREE_PICTURE ))
629 /* Picture is empty and ready for allocation */
630 p_free_picture = &p_vout->p_picture[i_picture];
634 /* If no free picture is available, use a destroyed picture */
635 if( (p_free_picture == NULL) && (p_destroyed_picture != NULL ) )
637 /* No free picture or matching destroyed picture has been found, but
638 * a destroyed picture is still avalaible */
639 free( p_destroyed_picture->p_data );
640 p_free_picture = p_destroyed_picture;
646 if( p_free_picture != NULL )
648 /* Allocate memory */
651 case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
652 i_chroma_width = i_width / 2;
653 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
654 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
655 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*4/2;
656 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*5/2;
658 case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
659 i_chroma_width = i_width / 2;
660 p_free_picture->p_data = malloc( i_height * i_chroma_width * 4 * sizeof( yuv_data_t ) );
661 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
662 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
663 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*3;
665 case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
666 i_chroma_width = i_width;
667 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
668 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
669 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width;
670 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
674 intf_DbgMsg("error: unknown picture type %d", i_type );
675 p_free_picture->p_data = NULL;
680 if( p_free_picture->p_data != NULL )
682 /* Copy picture information, set some default values */
683 p_free_picture->i_type = i_type;
684 p_free_picture->i_status = RESERVED_PICTURE;
685 p_free_picture->i_matrix_coefficients = 1;
686 p_free_picture->i_width = i_width;
687 p_free_picture->i_height = i_height;
688 p_free_picture->i_chroma_width = i_chroma_width;
689 p_free_picture->i_display_horizontal_offset = 0;
690 p_free_picture->i_display_vertical_offset = 0;
691 p_free_picture->i_display_width = i_width;
692 p_free_picture->i_display_height = i_height;
693 p_free_picture->i_aspect_ratio = AR_SQUARE_PICTURE;
694 p_free_picture->i_refcount = 0;
695 p_vout->i_pictures++;
699 /* Memory allocation failed : set picture as empty */
700 p_free_picture->i_type = EMPTY_PICTURE;
701 p_free_picture->i_status = FREE_PICTURE;
702 p_free_picture = NULL;
703 intf_ErrMsg( "vout error: picture allocation returned %s",
704 strerror( ENOMEM ) );
708 intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
710 vlc_mutex_unlock( &p_vout->picture_lock );
712 /* Initialize mutex */
713 vlc_mutex_init( &(p_free_picture->lock_deccount) );
715 return( p_free_picture );
718 /* No free or destroyed picture could be found */
719 intf_DbgMsg( "warning: picture heap is full" );
720 vlc_mutex_unlock( &p_vout->picture_lock );
724 /*****************************************************************************
725 * vout_DestroyPicture: remove a permanent or reserved picture from the heap
726 *****************************************************************************
727 * This function frees a previously reserved picture or a permanent
728 * picture. It is meant to be used when the construction of a picture aborted.
729 * Note that the picture will be destroyed even if it is linked !
730 *****************************************************************************/
731 void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
733 vlc_mutex_lock( &p_vout->picture_lock );
736 /* Check if picture status is valid */
737 if( (p_pic->i_status != RESERVED_PICTURE) &&
738 (p_pic->i_status != RESERVED_DATED_PICTURE) &&
739 (p_pic->i_status != RESERVED_DISP_PICTURE) )
741 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
745 p_pic->i_status = DESTROYED_PICTURE;
746 p_vout->i_pictures--;
749 intf_DbgMsg("picture %p", p_pic);
752 /* destroy the lock that had been initialized in CreatePicture */
753 vlc_mutex_destroy( &(p_pic->lock_deccount) );
755 vlc_mutex_unlock( &p_vout->picture_lock );
758 /*****************************************************************************
759 * vout_LinkPicture: increment reference counter of a picture
760 *****************************************************************************
761 * This function increment the reference counter of a picture in the video
762 * heap. It needs a lock since several producer threads can access the picture.
763 *****************************************************************************/
764 void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
766 vlc_mutex_lock( &p_vout->picture_lock );
770 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
773 vlc_mutex_unlock( &p_vout->picture_lock );
776 /*****************************************************************************
777 * vout_UnlinkPicture: decrement reference counter of a picture
778 *****************************************************************************
779 * This function decrement the reference counter of a picture in the video heap.
780 *****************************************************************************/
781 void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
783 vlc_mutex_lock( &p_vout->picture_lock );
787 if( p_pic->i_refcount < 0 )
789 intf_DbgMsg("error: refcount < 0");
790 p_pic->i_refcount = 0;
794 if( (p_pic->i_refcount == 0) && (p_pic->i_status == DISPLAYED_PICTURE) )
796 p_pic->i_status = DESTROYED_PICTURE;
797 p_vout->i_pictures--;
801 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
804 vlc_mutex_unlock( &p_vout->picture_lock );
807 /*****************************************************************************
808 * vout_SetBuffers: set buffers adresses
809 *****************************************************************************
810 * This function is called by system drivers to set buffers video memory
812 *****************************************************************************/
813 void vout_SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
815 /* No picture previously */
816 p_vout->p_buffer[0].i_pic_x = 0;
817 p_vout->p_buffer[0].i_pic_y = 0;
818 p_vout->p_buffer[0].i_pic_width = 0;
819 p_vout->p_buffer[0].i_pic_height = 0;
820 p_vout->p_buffer[1].i_pic_x = 0;
821 p_vout->p_buffer[1].i_pic_y = 0;
822 p_vout->p_buffer[1].i_pic_width = 0;
823 p_vout->p_buffer[1].i_pic_height = 0;
825 /* The first area covers all the screen */
826 p_vout->p_buffer[0].i_areas = 1;
827 p_vout->p_buffer[0].pi_area_begin[0] = 0;
828 p_vout->p_buffer[0].pi_area_end[0] = p_vout->i_height - 1;
829 p_vout->p_buffer[1].i_areas = 1;
830 p_vout->p_buffer[1].pi_area_begin[0] = 0;
831 p_vout->p_buffer[1].pi_area_end[0] = p_vout->i_height - 1;
834 p_vout->p_buffer[0].p_data = p_buf1;
835 p_vout->p_buffer[1].p_data = p_buf2;
838 /*****************************************************************************
839 * vout_Pixel2RGB: return red, green and blue from pixel value
840 *****************************************************************************
841 * Return color values, in 0-255 range, of the decomposition of a pixel. This
842 * is a slow routine and should only be used for initialization phase.
843 *****************************************************************************/
844 void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
846 *pi_red = i_pixel & p_vout->i_red_mask;
847 *pi_green = i_pixel & p_vout->i_green_mask;
848 *pi_blue = i_pixel & p_vout->i_blue_mask;
851 /* following functions are local */
853 /*****************************************************************************
854 * BinaryLog: computes the base 2 log of a binary value
855 *****************************************************************************
856 * This functions is used by MaskToShift, to get a bit index from a binary
858 *****************************************************************************/
859 static int BinaryLog(u32 i)
884 if (i != ((u32)1 << i_log))
886 intf_DbgMsg("internal error: binary log overflow");
892 /*****************************************************************************
893 * MaskToShift: transform a color mask into right and left shifts
894 *****************************************************************************
895 * This function is used for obtaining color shifts from masks.
896 *****************************************************************************/
897 static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
899 u32 i_low, i_high; /* lower hand higher bits of the mask */
902 i_low = i_mask & (- i_mask); /* lower bit of the mask */
903 i_high = i_mask + i_low; /* higher bit of the mask */
905 /* Transform bits into an index */
906 i_low = BinaryLog (i_low);
907 i_high = BinaryLog (i_high);
909 /* Update pointers and return */
911 *pi_right = (8 - i_high + i_low);
914 /*****************************************************************************
915 * InitThread: initialize video output thread
916 *****************************************************************************
917 * This function is called from RunThread and performs the second step of the
918 * initialization. It returns 0 on success. Note that the thread's flag are not
919 * modified inside this function.
920 *****************************************************************************/
921 static int InitThread( vout_thread_t *p_vout )
924 *p_vout->pi_status = THREAD_START;
926 vlc_mutex_lock( &p_vout->change_lock );
932 /* Initialize output method - this function issues its own error messages */
933 if( p_vout->p_sys_init( p_vout ) )
938 if( p_vout->b_need_render )
940 /* Initialize convertion tables and functions */
941 if( vout_InitYUV( p_vout ) )
943 intf_ErrMsg("vout error: can't allocate YUV translation tables");
948 /* Mark thread as running and return */
949 p_vout->b_active = 1;
950 *p_vout->pi_status = THREAD_READY;
953 intf_DbgMsg("thread ready");
957 /*****************************************************************************
958 * RunThread: video output thread
959 *****************************************************************************
960 * Video output thread. This function does only returns when the thread is
961 * terminated. It handles the pictures arriving in the video heap and the
962 * display device events.
963 *****************************************************************************/
964 static void RunThread( vout_thread_t *p_vout)
966 int i_index; /* index in heap */
967 mtime_t current_date; /* current date */
968 mtime_t display_date; /* display date */
969 boolean_t b_display; /* display flag */
970 picture_t * p_pic; /* picture pointer */
971 subpicture_t * p_subpic; /* subpicture pointer */
976 p_vout->b_error = InitThread( p_vout );
977 if( p_vout->b_error )
979 DestroyThread( p_vout, THREAD_ERROR );
984 * Main loop - it is not executed if an error occured during
987 while( (!p_vout->b_die) && (!p_vout->b_error) )
989 /* Initialize loop variables */
993 current_date = mdate();
996 if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
998 intf_Msg("vout stats: picture heap: %d/%d",
999 p_vout->i_pictures, VOUT_MAX_PICTURES);
1004 * Find the picture to display - this operation does not need lock,
1005 * since only READY_PICTUREs are handled
1007 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
1009 if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) &&
1010 ( (p_pic == NULL) ||
1011 (p_vout->p_picture[i_index].date < display_date) ) )
1013 p_pic = &p_vout->p_picture[i_index];
1014 display_date = p_pic->date;
1020 /* Computes FPS rate */
1021 p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ] = display_date;
1023 if( display_date < current_date - p_vout->render_time )
1025 /* Picture is late: it will be destroyed and the thread
1026 * will sleep and go to next picture */
1028 vlc_mutex_lock( &p_vout->picture_lock );
1029 if( p_pic->i_refcount )
1031 p_pic->i_status = DISPLAYED_PICTURE;
1035 p_pic->i_status = DESTROYED_PICTURE;
1036 p_vout->i_pictures--;
1039 "warning: late picture skipped (%p)", p_pic );
1040 vlc_mutex_unlock( &p_vout->picture_lock );
1044 else if( display_date > current_date + VOUT_DISPLAY_DELAY )
1046 /* A picture is ready to be rendered, but its rendering date
1047 * is far from the current one so the thread will perform an
1048 * empty loop as if no picture were found. The picture state
1055 * Find the subpictures to display - this operation does not need
1056 * lock, since only READY_SUBPICTURE are handled. If no picture
1057 * has been selected, display_date will depend on the subpicture.
1058 * We get an easily parsable chained list of subpictures which
1059 * ends with NULL since p_subpic was initialized to NULL.
1061 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1063 if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
1065 p_vout->p_subpicture[i_index].p_next = p_subpic;
1066 p_subpic = &p_vout->p_subpicture[i_index];
1071 * Perform rendering, sleep and display rendered picture
1073 if( p_pic ) /* picture and perhaps subpicture */
1075 b_display = p_vout->b_active;
1076 p_vout->last_display_date = display_date;
1077 p_vout->p_rendered_pic = p_pic;
1082 /* Set picture dimensions and clear buffer */
1083 SetBufferPicture( p_vout, p_pic );
1085 /* FIXME: if b_need_render == 0 we need to do something with
1086 * the subpictures one day. */
1088 if( p_vout->b_need_render && b_display )
1090 /* Render picture and information */
1091 RenderPicture( p_vout, p_pic );
1092 if( p_vout->b_info )
1094 RenderPictureInfo( p_vout, p_pic );
1095 RenderInfo( p_vout );
1099 RenderSubPicture( p_vout, p_subpic );
1103 /* Render interface and subpicture */
1104 if( b_display && p_vout->b_interface && p_vout->b_need_render )
1106 RenderInterface( p_vout );
1110 else if( p_vout->b_active && p_vout->b_need_render
1111 && p_vout->init_display_date == 0)
1113 /* Idle or interface screen alone */
1115 if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
1117 /* Interface has changed, so a new rendering is required - force
1118 * it by setting last idle date to 0 */
1119 p_vout->last_idle_date = 0;
1122 /* Render idle screen and update idle date, then render interface if
1124 b_display = RenderIdle( p_vout );
1127 p_vout->last_idle_date = current_date;
1128 if( p_vout->b_interface )
1130 RenderInterface( p_vout );
1142 * Check for the current time and
1143 * display splash screen if everything is on time
1145 if( p_vout->init_display_date > 0 && p_vout->b_need_render )
1147 if( p_vout->b_active &&
1148 mdate()-p_vout->init_display_date < 5000000)
1150 /* there is something to display ! */
1152 RenderSplash( p_vout );
1155 /* no splash screen ! */
1156 p_vout->init_display_date=0;
1162 * Sleep, wake up and display rendered picture
1165 if( display_date != 0 )
1167 /* Store render time using Bresenham algorithm */
1168 p_vout->render_time += mdate() - current_date;
1169 p_vout->render_time >>= 1;
1172 /* Give back change lock */
1173 vlc_mutex_unlock( &p_vout->change_lock );
1175 /* Sleep a while or until a given date */
1176 if( display_date != 0 )
1178 mwait( display_date - VOUT_MWAIT_TOLERANCE );
1182 msleep( VOUT_IDLE_SLEEP );
1185 /* On awakening, take back lock and send immediately picture to display,
1186 * then swap buffers */
1187 vlc_mutex_lock( &p_vout->change_lock );
1189 intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d", p_pic, p_subpic,
1190 p_vout->i_buffer_index, b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ );
1192 if( b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ )
1194 p_vout->p_sys_display( p_vout );
1196 p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;
1202 /* Remove picture from heap */
1203 vlc_mutex_lock( &p_vout->picture_lock );
1204 if( p_pic->i_refcount )
1206 p_pic->i_status = DISPLAYED_PICTURE;
1210 p_pic->i_status = DESTROYED_PICTURE;
1211 p_vout->i_pictures--;
1213 vlc_mutex_unlock( &p_vout->picture_lock );
1218 * Check events and manage thread
1220 if( p_vout->p_sys_manage( p_vout ) | Manage( p_vout ) )
1222 /* A fatal error occured, and the thread must terminate immediately,
1223 * without displaying anything - setting b_error to 1 cause the
1224 * immediate end of the main while() loop. */
1225 p_vout->b_error = 1;
1230 * Error loop - wait until the thread destruction is requested
1232 if( p_vout->b_error )
1234 ErrorThread( p_vout );
1238 EndThread( p_vout );
1239 DestroyThread( p_vout, THREAD_OVER );
1240 intf_DbgMsg( "thread end" );
1243 /*****************************************************************************
1244 * ErrorThread: RunThread() error loop
1245 *****************************************************************************
1246 * This function is called when an error occured during thread main's loop. The
1247 * thread can still receive feed, but must be ready to terminate as soon as
1249 *****************************************************************************/
1250 static void ErrorThread( vout_thread_t *p_vout )
1252 /* Wait until a `die' order */
1253 while( !p_vout->b_die )
1256 msleep( VOUT_IDLE_SLEEP );
1260 /*****************************************************************************
1261 * EndThread: thread destruction
1262 *****************************************************************************
1263 * This function is called when the thread ends after a sucessful
1264 * initialization. It frees all ressources allocated by InitThread.
1265 *****************************************************************************/
1266 static void EndThread( vout_thread_t *p_vout )
1268 int i_index; /* index in heap */
1271 *p_vout->pi_status = THREAD_END;
1275 struct tms cpu_usage;
1276 times( &cpu_usage );
1278 intf_Msg("vout stats: cpu usage (user: %d, system: %d)",
1279 cpu_usage.tms_utime, cpu_usage.tms_stime);
1283 /* Destroy all remaining pictures and subpictures */
1284 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
1286 if( p_vout->p_picture[i_index].i_status != FREE_PICTURE )
1288 free( p_vout->p_picture[i_index].p_data );
1291 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1293 if( p_vout->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
1295 free( p_vout->p_subpicture[i_index].p_data );
1299 /* Destroy translation tables */
1300 vout_EndYUV( p_vout );
1301 p_vout->p_sys_end( p_vout );
1304 /*****************************************************************************
1305 * DestroyThread: thread destruction
1306 *****************************************************************************
1307 * This function is called when the thread ends. It frees all ressources
1308 * allocated by CreateThread. Status is available at this stage.
1309 *****************************************************************************/
1310 static void DestroyThread( vout_thread_t *p_vout, int i_status )
1312 int *pi_status; /* status adress */
1314 /* Store status adress */
1315 pi_status = p_vout->pi_status;
1317 /* Destroy thread structures allocated by Create and InitThread */
1318 vout_UnloadFont( p_vout->p_default_font );
1319 vout_UnloadFont( p_vout->p_large_font );
1320 p_vout->p_sys_destroy( p_vout );
1322 /* Destroy the locks */
1323 vlc_mutex_destroy( &p_vout->picture_lock );
1324 vlc_mutex_destroy( &p_vout->subpicture_lock );
1325 vlc_mutex_destroy( &p_vout->change_lock );
1327 /* Free structure */
1329 *pi_status = i_status;
1332 /*****************************************************************************
1333 * Print: print simple text on a picture
1334 *****************************************************************************
1335 * This function will print a simple text on the picture. It is designed to
1336 * print debugging or general information.
1337 *****************************************************************************/
1338 void Print( vout_thread_t *p_vout, int i_x, int i_y, int i_h_align, int i_v_align, unsigned char *psz_text )
1340 int i_text_height; /* total text height */
1341 int i_text_width; /* total text width */
1343 /* Update upper left coordinates according to alignment */
1344 vout_TextSize( p_vout->p_default_font, 0, psz_text, &i_text_width, &i_text_height );
1345 if( !Align( p_vout, &i_x, &i_y, i_text_width, i_text_height, i_h_align, i_v_align ) )
1347 /* Set area and print text */
1348 SetBufferArea( p_vout, i_x, i_y, i_text_width, i_text_height );
1349 vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1350 i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
1351 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1352 p_vout->i_white_pixel, 0, 0,
1357 /*****************************************************************************
1358 * SetBufferArea: activate an area in current buffer
1359 *****************************************************************************
1360 * This function is called when something is rendered on the current buffer.
1361 * It set the area as active and prepare it to be cleared on next rendering.
1362 * Pay attention to the fact that in this functions, i_h is in fact the end y
1363 * coordinate of the new area.
1364 *****************************************************************************/
1365 static void SetBufferArea( vout_thread_t *p_vout, int i_x, int i_y, int i_w, int i_h )
1367 vout_buffer_t * p_buffer; /* current buffer */
1368 int i_area_begin, i_area_end; /* area vertical extension */
1369 int i_area, i_area_copy; /* area index */
1370 int i_area_shift; /* shift distance for areas */
1372 /* Choose buffer and modify h to end of area position */
1373 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1377 * Remove part of the area which is inside the picture - this is done
1378 * by calling again SetBufferArea with the correct areas dimensions.
1380 if( (i_x >= p_buffer->i_pic_x) && (i_x + i_w <= p_buffer->i_pic_x + p_buffer->i_pic_width) )
1382 i_area_begin = p_buffer->i_pic_y;
1383 i_area_end = i_area_begin + p_buffer->i_pic_height - 1;
1385 if( ((i_y >= i_area_begin) && (i_y <= i_area_end)) ||
1386 ((i_h >= i_area_begin) && (i_h <= i_area_end)) ||
1387 ((i_y < i_area_begin) && (i_h > i_area_end)) )
1389 /* Keep the stripe above the picture, if any */
1390 if( i_y < i_area_begin )
1392 SetBufferArea( p_vout, i_x, i_y, i_w, i_area_begin - i_y );
1394 /* Keep the stripe below the picture, if any */
1395 if( i_h > i_area_end )
1397 SetBufferArea( p_vout, i_x, i_area_end, i_w, i_h - i_area_end );
1403 /* Skip some extensions until interesting areas */
1405 (i_area < p_buffer->i_areas) &&
1406 (p_buffer->pi_area_end[i_area] + 1 <= i_y);
1412 if( i_area == p_buffer->i_areas )
1414 /* New area is below all existing ones: just add it at the end of the
1415 * array, if possible - otherwise, append it to the last one */
1416 if( i_area < VOUT_MAX_AREAS )
1418 p_buffer->pi_area_begin[i_area] = i_y;
1419 p_buffer->pi_area_end[i_area] = i_h;
1420 p_buffer->i_areas++;
1425 intf_DbgMsg("area overflow");
1427 p_buffer->pi_area_end[VOUT_MAX_AREAS - 1] = i_h;
1432 i_area_begin = p_buffer->pi_area_begin[i_area];
1433 i_area_end = p_buffer->pi_area_end[i_area];
1435 if( i_y < i_area_begin )
1437 if( i_h >= i_area_begin - 1 )
1439 /* Extend area above */
1440 p_buffer->pi_area_begin[i_area] = i_y;
1444 /* Create a new area above : merge last area if overflow, then
1445 * move all old areas down */
1446 if( p_buffer->i_areas == VOUT_MAX_AREAS )
1449 intf_DbgMsg("areas overflow");
1451 p_buffer->pi_area_end[VOUT_MAX_AREAS - 2] = p_buffer->pi_area_end[VOUT_MAX_AREAS - 1];
1455 p_buffer->i_areas++;
1457 for( i_area_copy = p_buffer->i_areas - 1; i_area_copy > i_area; i_area_copy-- )
1459 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy - 1];
1460 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy - 1];
1462 p_buffer->pi_area_begin[i_area] = i_y;
1463 p_buffer->pi_area_end[i_area] = i_h;
1467 if( i_h > i_area_end )
1469 /* Find further areas which can be merged with the new one */
1470 for( i_area_copy = i_area + 1;
1471 (i_area_copy < p_buffer->i_areas) &&
1472 (p_buffer->pi_area_begin[i_area] <= i_h);
1479 if( i_area_copy != i_area )
1481 /* Merge with last possible areas */
1482 p_buffer->pi_area_end[i_area] = MAX( i_h, p_buffer->pi_area_end[i_area_copy] );
1484 /* Shift lower areas upward */
1485 i_area_shift = i_area_copy - i_area;
1486 p_buffer->i_areas -= i_area_shift;
1487 for( i_area_copy = i_area + 1; i_area_copy < p_buffer->i_areas; i_area_copy++ )
1489 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy + i_area_shift];
1490 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy + i_area_shift];
1495 /* Extend area below */
1496 p_buffer->pi_area_end[i_area] = i_h;
1502 /*****************************************************************************
1503 * SetBufferPicture: clear buffer and set picture area
1504 *****************************************************************************
1505 * This function is called before any rendering. It clears the current
1506 * rendering buffer and set the new picture area. If the picture pointer is
1507 * NULL, then no picture area is defined. Floating operations are avoided since
1508 * some MMX calculations may follow.
1509 *****************************************************************************/
1510 static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
1512 vout_buffer_t * p_buffer; /* current buffer */
1513 int i_pic_x, i_pic_y; /* picture position */
1514 int i_pic_width, i_pic_height; /* picture dimensions */
1515 int i_old_pic_y, i_old_pic_height; /* old picture area */
1516 int i_vout_width, i_vout_height; /* display dimensions */
1517 int i_area; /* area index */
1518 int i_data_index; /* area data index */
1519 int i_data_size; /* area data size, in 256 bytes blocs */
1520 u64 * p_data; /* area data, for clearing */
1521 byte_t * p_data8; /* area data, for clearing (slow) */
1523 /* Choose buffer and set display dimensions */
1524 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1525 i_vout_width = p_vout->i_width;
1526 i_vout_height = p_vout->i_height;
1529 * Computes new picture size
1533 /* Try horizontal scaling first - width must be a mutiple of 16 */
1534 i_pic_width = (( p_vout->b_scale || (p_pic->i_width > i_vout_width)) ?
1535 i_vout_width : p_pic->i_width) & ~0xf;
1536 switch( p_pic->i_aspect_ratio )
1538 case AR_3_4_PICTURE:
1539 i_pic_height = i_pic_width * 3 / 4;
1541 case AR_16_9_PICTURE:
1542 i_pic_height = i_pic_width * 9 / 16;
1544 case AR_221_1_PICTURE:
1545 i_pic_height = i_pic_width * 100 / 221;
1547 case AR_SQUARE_PICTURE:
1549 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1553 /* If picture dimensions using horizontal scaling are too large, use
1554 * vertical scaling. Since width must be a multiple of 16, height is
1555 * adjusted again after. */
1556 if( i_pic_height > i_vout_height )
1558 i_pic_height = ( p_vout->b_scale || (p_pic->i_height > i_vout_height)) ?
1559 i_vout_height : p_pic->i_height;
1560 switch( p_pic->i_aspect_ratio )
1562 case AR_3_4_PICTURE:
1563 i_pic_width = (i_pic_height * 4 / 3) & ~0xf;
1564 i_pic_height = i_pic_width * 3 / 4;
1566 case AR_16_9_PICTURE:
1567 i_pic_width = (i_pic_height * 16 / 9) & ~0xf;
1568 i_pic_height = i_pic_width * 9 / 16;
1570 case AR_221_1_PICTURE:
1571 i_pic_width = (i_pic_height * 221 / 100) & ~0xf;
1572 i_pic_height = i_pic_width * 100 / 221;
1574 case AR_SQUARE_PICTURE:
1576 i_pic_width = (p_pic->i_width * i_pic_height / p_pic->i_height) & ~0xf;
1577 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1582 /* Set picture position */
1583 i_pic_x = (p_vout->i_width - i_pic_width) / 2;
1584 i_pic_y = (p_vout->i_height - i_pic_height) / 2;
1589 /* No picture: size is 0 */
1597 * Set new picture size - if it is smaller than the previous one, clear
1598 * around it. Since picture are centered, only their size is tested.
1600 if( (p_buffer->i_pic_width > i_pic_width) || (p_buffer->i_pic_height > i_pic_height) )
1602 i_old_pic_y = p_buffer->i_pic_y;
1603 i_old_pic_height = p_buffer->i_pic_height;
1604 p_buffer->i_pic_x = i_pic_x;
1605 p_buffer->i_pic_y = i_pic_y;
1606 p_buffer->i_pic_width = i_pic_width;
1607 p_buffer->i_pic_height = i_pic_height;
1608 SetBufferArea( p_vout, 0, i_old_pic_y, p_vout->i_width, i_old_pic_height );
1612 p_buffer->i_pic_x = i_pic_x;
1613 p_buffer->i_pic_y = i_pic_y;
1614 p_buffer->i_pic_width = i_pic_width;
1615 p_buffer->i_pic_height = i_pic_height;
1621 for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
1624 intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d", p_pic,
1625 p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
1627 i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
1628 p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
1629 for( i_data_index = i_data_size / 256; i_data_index-- ; )
1631 /* Clear 256 bytes block */
1632 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1633 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1634 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1635 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1636 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1637 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1638 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1639 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1641 for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
1643 /* Clear remaining 16 bytes blocks */
1644 *p_data++ = 0; *p_data++ = 0;
1646 p_data8 = (byte_t *)p_data;
1647 for( i_data_index = i_data_size % 16; i_data_index--; )
1649 /* Clear remaining bytes */
1657 p_buffer->i_areas = 0;
1660 /*****************************************************************************
1661 * RenderPicture: render a picture
1662 *****************************************************************************
1663 * This function converts a picture from a video heap to a pixel-encoded image
1664 * and copies it to the current rendering buffer. No lock is required, since
1665 * the * rendered picture has been determined as existant, and will only be
1666 * destroyed by the vout thread later.
1667 *****************************************************************************/
1668 static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
1671 char psz_date[MSTRTIME_MAX_SIZE]; /* picture date */
1672 mtime_t render_time; /* picture rendering time */
1674 vout_buffer_t * p_buffer; /* rendering buffer */
1675 byte_t * p_pic_data; /* convertion destination */
1677 /* Get and set rendering information */
1678 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1679 p_pic_data = p_buffer->p_data +
1680 p_buffer->i_pic_x * p_vout->i_bytes_per_pixel +
1681 p_buffer->i_pic_y * p_vout->i_bytes_per_line;
1683 render_time = mdate();
1689 * Choose appropriate rendering function and render picture
1691 switch( p_pic->i_type )
1693 case YUV_420_PICTURE:
1694 p_vout->yuv.p_Convert420( p_vout, p_pic_data,
1695 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1696 p_pic->i_width, p_pic->i_height,
1697 p_buffer->i_pic_width, p_buffer->i_pic_height,
1698 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1699 p_pic->i_matrix_coefficients );
1701 case YUV_422_PICTURE:
1702 p_vout->yuv.p_Convert422( p_vout, p_pic_data,
1703 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1704 p_pic->i_width, p_pic->i_height,
1705 p_buffer->i_pic_width, p_buffer->i_pic_height,
1706 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1707 p_pic->i_matrix_coefficients );
1709 case YUV_444_PICTURE:
1710 p_vout->yuv.p_Convert444( p_vout, p_pic_data,
1711 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1712 p_pic->i_width, p_pic->i_height,
1713 p_buffer->i_pic_width, p_buffer->i_pic_height,
1714 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1715 p_pic->i_matrix_coefficients );
1719 intf_DbgMsg("error: unknown picture type %d", p_pic->i_type );
1725 /* Print picture date and rendering time */
1726 intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s", p_pic,
1727 p_vout->i_buffer_index, (long) (mdate() - render_time),
1728 mstrtime( psz_date, p_pic->date ));
1732 /*****************************************************************************
1733 * RenderPictureInfo: print additionnal information on a picture
1734 *****************************************************************************
1735 * This function will print information such as fps and other picture
1736 * dependant information.
1737 *****************************************************************************/
1738 static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
1740 char psz_buffer[256]; /* string buffer */
1743 * Print FPS rate in upper right corner
1745 if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
1747 long i_fps = VOUT_FPS_SAMPLES * 1000000 * 10 /
1748 ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1)
1749 % VOUT_FPS_SAMPLES ] -
1750 p_vout->p_fps_sample[ p_vout->c_fps_samples
1751 % VOUT_FPS_SAMPLES ] );
1752 sprintf( psz_buffer, "%li.%i fps", i_fps / 10, (int)i_fps % 10 );
1753 Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
1757 * Print frames count and loop time in upper left corner
1759 sprintf( psz_buffer, "%ld frames, render: %ldus",
1760 (long) p_vout->c_fps_samples, (long) p_vout->render_time );
1761 Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
1765 * Print picture information in lower right corner
1767 sprintf( psz_buffer, "%s picture %dx%d (%dx%d%+d%+d %s) -> %dx%d+%d+%d",
1768 (p_pic->i_type == YUV_420_PICTURE) ? "4:2:0" :
1769 ((p_pic->i_type == YUV_422_PICTURE) ? "4:2:2" :
1770 ((p_pic->i_type == YUV_444_PICTURE) ? "4:4:4" : "ukn-type")),
1771 p_pic->i_width, p_pic->i_height,
1772 p_pic->i_display_width, p_pic->i_display_height,
1773 p_pic->i_display_horizontal_offset, p_pic->i_display_vertical_offset,
1774 (p_pic->i_aspect_ratio == AR_SQUARE_PICTURE) ? "sq" :
1775 ((p_pic->i_aspect_ratio == AR_3_4_PICTURE) ? "4:3" :
1776 ((p_pic->i_aspect_ratio == AR_16_9_PICTURE) ? "16:9" :
1777 ((p_pic->i_aspect_ratio == AR_221_1_PICTURE) ? "2.21:1" : "ukn-ar" ))),
1778 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_width,
1779 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height,
1780 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_x,
1781 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y );
1782 Print( p_vout, 0, 0, RIGHT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1786 /*****************************************************************************
1787 * RenderSplash: render splash picture
1788 *****************************************************************************
1789 * This function will print something on the screen. It will return 0 if
1790 * nothing has been rendered, or 1 if something has been changed on the screen.
1791 * Note that if you absolutely want something to be printed, you will have
1792 * to force it by setting the last idle date to 0.
1793 * Unlike other rendering functions, this one calls the SetBufferPicture
1794 * function when needed.
1795 *****************************************************************************/
1796 int RenderSplash( vout_thread_t *p_vout )
1798 int i_x = 0, i_y = 0; /* text position */
1799 int i_width, i_height; /* text size */
1800 char *psz_text = "VideoLAN Client (" VERSION ")"; /* text to display */
1802 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1803 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1805 // SetBufferPicture( p_vout, NULL );
1806 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1807 &i_width, &i_height );
1808 if( !Align( p_vout, &i_x, &i_y, i_width, i_height, CENTER_RALIGN, CENTER_RALIGN ) )
1810 vout_Print( p_vout->p_large_font,
1811 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1812 i_x * p_vout->i_bytes_per_pixel + (i_y - 16 ) * p_vout->i_bytes_per_line,
1813 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1814 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1815 WIDE_TEXT | OUTLINED_TEXT, psz_text, 100);
1816 SetBufferArea( p_vout, i_x, i_y, i_width, i_height);
1822 /*****************************************************************************
1823 * RenderIdle: render idle picture
1824 *****************************************************************************
1825 * This function will print something on the screen. It will return 0 if
1826 * nothing has been rendered, or 1 if something has been changed on the screen.
1827 * Note that if you absolutely want something to be printed, you will have
1828 * to force it by setting the last idle date to 0.
1829 * Unlike other rendering functions, this one calls the SetBufferPicture
1830 * function when needed.
1831 *****************************************************************************/
1832 int RenderIdle( vout_thread_t *p_vout )
1834 int i_x = 0, i_y = 0; /* text position */
1835 int i_width, i_height; /* text size */
1836 mtime_t current_date; /* current date */
1837 int i_amount = 0; /* amount to draw */
1838 char *psz_text = "Waiting for stream"; /* text to display */
1839 char *psz_wtext = "[................]";
1842 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1843 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1846 current_date = mdate();
1847 if( (current_date - p_vout->last_display_date) > VOUT_IDLE_DELAY
1848 // && (current_date - p_vout->last_idle_date) > VOUT_IDLE_DELAY
1851 SetBufferPicture( p_vout, NULL );
1852 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1853 &i_width, &i_height );
1854 if( !Align( p_vout, &i_x, &i_y, i_width, i_height * 2, CENTER_RALIGN, CENTER_RALIGN ) )
1856 i_amount = (int) ((current_date - p_vout->last_display_date ) / 5000LL);
1857 vout_Print( p_vout->p_large_font,
1858 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1859 i_x * p_vout->i_bytes_per_pixel + i_y * p_vout->i_bytes_per_line,
1860 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1861 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1862 WIDE_TEXT | OUTLINED_TEXT, psz_text, (i_amount / 3 ) %110);
1864 vout_Print( p_vout->p_large_font,
1865 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1866 i_x * p_vout->i_bytes_per_pixel + (i_y + 16) * p_vout->i_bytes_per_line,
1867 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1868 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1869 WIDE_TEXT | OUTLINED_TEXT, psz_wtext, (i_amount/5)%110 );
1872 SetBufferArea( p_vout, i_x, i_y, i_width, i_height * 2 );
1879 /*****************************************************************************
1880 * RenderInfo: render additionnal information
1881 *****************************************************************************
1882 * This function renders information which do not depend on the current
1884 *****************************************************************************/
1885 static void RenderInfo( vout_thread_t *p_vout )
1888 char psz_buffer[256]; /* string buffer */
1889 int i_ready_pic = 0; /* ready pictures */
1890 int i_reserved_pic = 0; /* reserved pictures */
1891 int i_picture; /* picture index */
1896 * Print thread state in lower left corner
1898 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
1900 switch( p_vout->p_picture[i_picture].i_status )
1902 case RESERVED_PICTURE:
1903 case RESERVED_DATED_PICTURE:
1904 case RESERVED_DISP_PICTURE:
1912 sprintf( psz_buffer, "pic: %d (%d/%d)/%d",
1913 p_vout->i_pictures, i_reserved_pic, i_ready_pic, VOUT_MAX_PICTURES );
1914 Print( p_vout, 0, 0, LEFT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1918 /*****************************************************************************
1919 * RenderSubPicture: render a subpicture
1920 *****************************************************************************
1921 * This function renders a sub picture unit.
1922 *****************************************************************************/
1923 static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
1925 p_vout_font_t p_font; /* text font */
1926 int i_width, i_height; /* subpicture dimensions */
1928 while( p_subpic != NULL )
1930 switch( p_subpic->i_type )
1932 case DVD_SUBPICTURE: /* DVD subpicture unit */
1933 /* test if the picture really has to be displayed */
1934 if( mdate() < p_subpic->begin_date )
1936 /* not yet, see you later */
1939 if( mdate() > p_subpic->end_date )
1941 /* too late, destroying the subpic */
1942 vout_DestroySubPicture( p_vout, p_subpic );
1945 vout_RenderSPU( &p_vout->p_buffer[ p_vout->i_buffer_index ],
1946 p_subpic, p_vout->i_bytes_per_pixel,
1947 p_vout->i_bytes_per_line );
1949 case TEXT_SUBPICTURE: /* single line text */
1950 /* Select default font if not specified */
1951 p_font = p_subpic->type.text.p_font;
1952 if( p_font == NULL )
1954 p_font = p_vout->p_default_font;
1957 /* Compute text size (width and height fields are ignored)
1959 vout_TextSize( p_font, p_subpic->type.text.i_style,
1960 p_subpic->p_data, &i_width, &i_height );
1961 if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y,
1962 i_width, i_height, p_subpic->i_horizontal_align,
1963 p_subpic->i_vertical_align ) )
1966 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1967 p_subpic->i_x * p_vout->i_bytes_per_pixel +
1968 p_subpic->i_y * p_vout->i_bytes_per_line,
1969 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1970 p_subpic->type.text.i_char_color,
1971 p_subpic->type.text.i_border_color,
1972 p_subpic->type.text.i_bg_color,
1973 p_subpic->type.text.i_style, p_subpic->p_data, 100 );
1974 SetBufferArea( p_vout, p_subpic->i_x, p_subpic->i_y,
1975 i_width, i_height );
1981 intf_DbgMsg( "error: unknown subpicture %p type %d",
1982 p_subpic, p_subpic->i_type );
1986 p_subpic = p_subpic->p_next;
1990 /*****************************************************************************
1991 * RenderInterface: render the interface
1992 *****************************************************************************
1993 * This function renders the interface, if any.
1994 *****************************************************************************/
1995 static void RenderInterface( vout_thread_t *p_vout )
1997 int i_height, i_text_height; /* total and text height */
1998 int i_width_1, i_width_2; /* text width */
1999 int i_byte; /* byte index */
2000 const char *psz_text_1 = "[1-9] Channel [i]nfo [c]olor [g/G]amma";
2001 const char *psz_text_2 = "[+/-] Volume [m]ute [s]caling [Q]uit";
2004 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_1, &i_width_1, &i_height );
2005 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_2, &i_width_2, &i_text_height );
2006 i_height += i_text_height;
2008 /* Render background */
2009 for( i_byte = (p_vout->i_height - i_height) * p_vout->i_bytes_per_line;
2010 i_byte < p_vout->i_height * p_vout->i_bytes_per_line;
2014 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = p_vout->i_blue_pixel;
2017 /* Render text, if not larger than screen */
2018 if( i_width_1 < p_vout->i_width )
2020 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2021 (p_vout->i_height - i_height) * p_vout->i_bytes_per_line,
2022 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2023 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2024 OUTLINED_TEXT, psz_text_1, 100 );
2026 if( i_width_2 < p_vout->i_width )
2028 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2029 (p_vout->i_height - i_height + i_text_height) * p_vout->i_bytes_per_line,
2030 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2031 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2032 OUTLINED_TEXT, psz_text_2, 100 );
2035 /* Activate modified area */
2036 SetBufferArea( p_vout, 0, p_vout->i_height - i_height, p_vout->i_width, i_height );
2039 /*****************************************************************************
2040 * Manage: manage thread
2041 *****************************************************************************
2042 * This function will handle changes in thread configuration.
2043 *****************************************************************************/
2044 static int Manage( vout_thread_t *p_vout )
2047 if( p_vout->i_changes )
2049 intf_DbgMsg("changes: 0x%x (no display: 0x%x)", p_vout->i_changes,
2050 0 /* p_vout->i_changes & VOUT_NODISPLAY_CHANGE */ );
2054 /* On gamma or grayscale change, rebuild tables */
2055 if( p_vout->i_changes & (VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2058 if( vout_ResetYUV( p_vout ) )
2060 intf_ErrMsg( "vout error: can't rebuild conversion tables" );
2065 /* Clear changes flags which does not need management or have been
2067 p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2068 VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
2069 VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE );
2071 /* Detect unauthorized changes */
2072 if( p_vout->i_changes )
2074 /* Some changes were not acknowledged by p_vout->p_sys_manage or this
2075 * function, it means they should not be authorized */
2076 intf_ErrMsg( "vout error: unauthorized changes in the vout thread" );
2083 /*****************************************************************************
2084 * Align: align a subpicture in the screen
2085 *****************************************************************************
2086 * This function is used for rendering text or subpictures. It returns non 0
2087 * it the final aera is not fully included in display area. Return coordinates
2089 *****************************************************************************/
2090 static int Align( vout_thread_t *p_vout, int *pi_x, int *pi_y,
2091 int i_width, int i_height, int i_h_align, int i_v_align )
2093 /* Align horizontally */
2097 *pi_x -= i_width / 2;
2100 *pi_x += (p_vout->i_width - i_width) / 2;
2106 *pi_x += p_vout->i_width - i_width;
2110 /* Align vertically */
2114 *pi_y -= i_height / 2;
2117 *pi_y += (p_vout->i_height - i_height) / 2;
2123 *pi_y += p_vout->i_height - i_height;
2125 case SUBTITLE_RALIGN:
2126 *pi_y += (p_vout->i_height + p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y +
2127 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height - i_height) / 2;
2131 /* Return non 0 if clipping failed */
2132 return( (*pi_x < 0) || (*pi_y < 0) ||
2133 (*pi_x + i_width > p_vout->i_width) || (*pi_y + i_height > p_vout->i_height) );
2136 /*****************************************************************************
2137 * SetPalette: sets an 8 bpp palette
2138 *****************************************************************************
2139 * This function is just a prototype that does nothing. Architectures that
2140 * support palette allocation should override it.
2141 *****************************************************************************/
2142 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
2143 u16 *green, u16 *blue, u16 *transp )
2145 intf_ErrMsg( "vout error: method does not support palette changing" );