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() */
42 #include "video_output.h"
43 #include "video_text.h"
44 #include "video_spu.h"
45 #include "video_yuv.h"
50 #include "vdec_idct.h"
51 #include "video_decoder.h"
53 /*****************************************************************************
55 *****************************************************************************/
56 static int BinaryLog ( u32 i );
57 static void MaskToShift ( int *pi_left, int *pi_right, u32 i_mask );
58 static int InitThread ( vout_thread_t *p_vout );
59 static void RunThread ( vout_thread_t *p_vout );
60 static void ErrorThread ( vout_thread_t *p_vout );
61 static void EndThread ( vout_thread_t *p_vout );
62 static void DestroyThread ( vout_thread_t *p_vout, int i_status );
63 static void Print ( vout_thread_t *p_vout, int i_x, int i_y,
64 int i_h_align, int i_v_align,
65 unsigned char *psz_text );
66 static void SetBufferArea ( vout_thread_t *p_vout, int i_x, int i_y,
68 static void SetBufferPicture ( vout_thread_t *p_vout, picture_t *p_pic );
69 static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
70 static void RenderPictureInfo ( vout_thread_t *p_vout, picture_t *p_pic );
71 static void RenderSubPicture ( vout_thread_t *p_vout,
72 subpicture_t *p_subpic );
73 static void RenderInterface ( vout_thread_t *p_vout );
74 static int RenderIdle ( vout_thread_t *p_vout );
75 static int RenderSplash ( vout_thread_t *p_vout );
76 static void RenderInfo ( vout_thread_t *p_vout );
77 static int Manage ( vout_thread_t *p_vout );
78 static int Align ( vout_thread_t *p_vout, int *pi_x,
79 int *pi_y, int i_width, int i_height,
80 int i_h_align, int i_v_align );
81 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
82 u16 *green, u16 *blue, u16 *transp );
84 /*****************************************************************************
85 * vout_CreateThread: creates a new video output thread
86 *****************************************************************************
87 * This function creates a new video output thread, and returns a pointer
88 * to its description. On error, it returns NULL.
89 * If pi_status is NULL, then the function will block until the thread is ready.
90 * If not, it will be updated using one of the THREAD_* constants.
91 *****************************************************************************/
92 vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window,
93 int i_width, int i_height, int *pi_status,
94 int i_method, void *p_data )
96 vout_thread_t * p_vout; /* thread descriptor */
97 typedef void ( vout_getplugin_t ) ( vout_thread_t * p_vout );
98 int i_status; /* thread status */
99 int i_index; /* index for array initialization */
100 int i_best_index = 0, i_best_score = 0;
102 /* Allocate descriptor */
104 p_vout = (vout_thread_t *) malloc( sizeof(vout_thread_t) );
107 intf_ErrMsg( "vout error: %s\n", strerror(ENOMEM) );
111 p_vout->p_set_palette = SetPalette;
113 /* Get a suitable video plugin */
114 for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
116 /* If there's a plugin in p_info ... */
117 if( p_main->p_bank->p_info[ i_index ] != NULL )
119 /* ... and if this plugin provides the functions we want ... */
120 if( p_main->p_bank->p_info[ i_index ]->vout_GetPlugin != NULL )
122 /* ... and if this plugin has a good score ... */
123 if( p_main->p_bank->p_info[ i_index ]->i_score > i_best_score )
125 /* ... then take it */
126 i_best_score = p_main->p_bank->p_info[ i_index ]->i_score;
127 i_best_index = i_index;
133 if( i_best_score == 0 )
139 /* Get the plugin functions */
140 ( (vout_getplugin_t *)
141 p_main->p_bank->p_info[ i_best_index ]->vout_GetPlugin )( p_vout );
143 /* Initialize thread properties - thread id and locks will be initialized
147 p_vout->b_active = 0;
148 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
149 *p_vout->pi_status = THREAD_CREATE;
151 /* Initialize some fields used by the system-dependant method - these
152 * fields will probably be modified by the method, and are only
154 p_vout->i_changes = 0;
155 p_vout->i_width = i_width;
156 p_vout->i_height = i_height;
157 p_vout->i_bytes_per_line = i_width * 2;
158 p_vout->i_screen_depth = 15;
159 p_vout->i_bytes_per_pixel = 2;
160 p_vout->f_gamma = VOUT_GAMMA;
161 p_vout->b_need_render = 1;
163 p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
164 VOUT_GRAYSCALE_DEFAULT );
165 p_vout->vdec_DecodeMacroblock = vdec_DecodeMacroblockC;
167 p_vout->b_interface = 0;
170 intf_DbgMsg( "wished configuration: %dx%d, %d/%d bpp (%d Bpl)\n",
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\n",
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\n" );
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\n" );
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 );
260 vlc_mutex_lock( &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\n", 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)\n", 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\n", 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\n",
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)\n",
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\n", 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("spu warning: %s\n", strerror( ENOMEM ) );
468 intf_DbgMsg("subpicture %p (in free subpicture slot)\n", p_free_subpic );
470 vlc_mutex_unlock( &p_vout->subpicture_lock );
471 return( p_free_subpic );
474 /* No free or destroyed subpicture could be found */
475 intf_DbgMsg( "warning: subpicture heap is full\n" );
476 vlc_mutex_unlock( &p_vout->subpicture_lock );
480 /*****************************************************************************
481 * vout_DestroySubPicture: remove a subpicture from the heap
482 *****************************************************************************
483 * This function frees a previously reserved subpicture.
484 * It is meant to be used when the construction of a picture aborted.
485 * This function does not need locking since reserved subpictures are ignored
486 * by the output thread.
487 *****************************************************************************/
488 void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
491 /* Check if status is valid */
492 if( p_subpic->i_status != RESERVED_SUBPICTURE )
494 intf_DbgMsg("error: subpicture %p has invalid status %d\n",
495 p_subpic, p_subpic->i_status );
499 p_subpic->i_status = DESTROYED_SUBPICTURE;
502 intf_DbgMsg("subpicture %p\n", p_subpic);
506 /*****************************************************************************
507 * vout_DisplayPicture: display a picture
508 *****************************************************************************
509 * Remove the reservation flag of a picture, which will cause it to be ready for
510 * display. The picture won't be displayed until vout_DatePicture has been
512 *****************************************************************************/
513 void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
515 vlc_mutex_lock( &p_vout->picture_lock );
516 switch( p_pic->i_status )
518 case RESERVED_PICTURE:
519 p_pic->i_status = RESERVED_DISP_PICTURE;
521 case RESERVED_DATED_PICTURE:
522 p_pic->i_status = READY_PICTURE;
526 intf_DbgMsg("error: picture %p has invalid status %d\n", p_pic, p_pic->i_status );
532 intf_DbgMsg("picture %p\n", p_pic);
534 vlc_mutex_unlock( &p_vout->picture_lock );
537 /*****************************************************************************
538 * vout_DatePicture: date a picture
539 *****************************************************************************
540 * Remove the reservation flag of a picture, which will cause it to be ready for
541 * display. The picture won't be displayed until vout_DisplayPicture has been
543 *****************************************************************************/
544 void vout_DatePicture( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date )
547 char psz_date[MSTRTIME_MAX_SIZE]; /* date */
550 vlc_mutex_lock( &p_vout->picture_lock );
552 switch( p_pic->i_status )
554 case RESERVED_PICTURE:
555 p_pic->i_status = RESERVED_DATED_PICTURE;
557 case RESERVED_DISP_PICTURE:
558 p_pic->i_status = READY_PICTURE;
562 intf_DbgMsg("error: picture %p has invalid status %d\n", p_pic, p_pic->i_status );
568 intf_DbgMsg("picture %p, display date: %s\n", p_pic, mstrtime( psz_date, p_pic->date) );
570 vlc_mutex_unlock( &p_vout->picture_lock );
573 /*****************************************************************************
574 * vout_CreatePicture: allocate a picture in the video output heap.
575 *****************************************************************************
576 * This function create a reserved image in the video output heap.
577 * A null pointer is returned if the function fails. This method provides an
578 * already allocated zone of memory in the picture data fields. It needs locking
579 * since several pictures can be created by several producers threads.
580 *****************************************************************************/
581 picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
582 int i_width, int i_height )
584 int i_picture; /* picture index */
585 int i_chroma_width = 0; /* chroma width */
586 picture_t * p_free_picture = NULL; /* first free picture */
587 picture_t * p_destroyed_picture = NULL; /* first destroyed picture */
590 vlc_mutex_lock( &p_vout->picture_lock );
593 * Look for an empty place
595 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
597 if( p_vout->p_picture[i_picture].i_status == DESTROYED_PICTURE )
599 /* Picture is marked for destruction, but is still allocated - note
600 * that if width and type are the same for two pictures, chroma_width
601 * should also be the same */
602 if( (p_vout->p_picture[i_picture].i_type == i_type) &&
603 (p_vout->p_picture[i_picture].i_height == i_height) &&
604 (p_vout->p_picture[i_picture].i_width == i_width) )
606 /* Memory size do match : memory will not be reallocated, and function
607 * can end immediately - this is the best possible case, since no
608 * memory allocation needs to be done */
609 p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
610 p_vout->i_pictures++;
612 intf_DbgMsg("picture %p (in destroyed picture slot)\n",
613 &p_vout->p_picture[i_picture] );
615 vlc_mutex_unlock( &p_vout->picture_lock );
616 return( &p_vout->p_picture[i_picture] );
618 else if( p_destroyed_picture == NULL )
620 /* Memory size do not match, but picture index will be kept in
621 * case no other place are left */
622 p_destroyed_picture = &p_vout->p_picture[i_picture];
625 else if( (p_free_picture == NULL) &&
626 (p_vout->p_picture[i_picture].i_status == FREE_PICTURE ))
628 /* Picture is empty and ready for allocation */
629 p_free_picture = &p_vout->p_picture[i_picture];
633 /* If no free picture is available, use a destroyed picture */
634 if( (p_free_picture == NULL) && (p_destroyed_picture != NULL ) )
636 /* No free picture or matching destroyed picture has been found, but
637 * a destroyed picture is still avalaible */
638 free( p_destroyed_picture->p_data );
639 p_free_picture = p_destroyed_picture;
645 if( p_free_picture != NULL )
647 /* Allocate memory */
650 case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
651 i_chroma_width = i_width / 2;
652 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
653 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
654 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*4/2;
655 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*5/2;
657 case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
658 i_chroma_width = i_width / 2;
659 p_free_picture->p_data = malloc( i_height * i_chroma_width * 4 * sizeof( yuv_data_t ) );
660 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
661 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
662 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*3;
664 case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
665 i_chroma_width = i_width;
666 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
667 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
668 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width;
669 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
673 intf_DbgMsg("error: unknown picture type %d\n", i_type );
674 p_free_picture->p_data = NULL;
679 if( p_free_picture->p_data != NULL )
681 /* Copy picture information, set some default values */
682 p_free_picture->i_type = i_type;
683 p_free_picture->i_status = RESERVED_PICTURE;
684 p_free_picture->i_matrix_coefficients = 1;
685 p_free_picture->i_width = i_width;
686 p_free_picture->i_height = i_height;
687 p_free_picture->i_chroma_width = i_chroma_width;
688 p_free_picture->i_display_horizontal_offset = 0;
689 p_free_picture->i_display_vertical_offset = 0;
690 p_free_picture->i_display_width = i_width;
691 p_free_picture->i_display_height = i_height;
692 p_free_picture->i_aspect_ratio = AR_SQUARE_PICTURE;
693 p_free_picture->i_refcount = 0;
694 p_vout->i_pictures++;
698 /* Memory allocation failed : set picture as empty */
699 p_free_picture->i_type = EMPTY_PICTURE;
700 p_free_picture->i_status = FREE_PICTURE;
701 p_free_picture = NULL;
702 intf_ErrMsg( "vout warning: %s\n", strerror( ENOMEM ) );
706 intf_DbgMsg("picture %p (in free picture slot)\n", p_free_picture );
708 vlc_mutex_unlock( &p_vout->picture_lock );
709 return( p_free_picture );
712 /* No free or destroyed picture could be found */
713 intf_DbgMsg( "warning: picture heap is full\n" );
714 vlc_mutex_unlock( &p_vout->picture_lock );
718 /*****************************************************************************
719 * vout_DestroyPicture: remove a permanent or reserved picture from the heap
720 *****************************************************************************
721 * This function frees a previously reserved picture or a permanent
722 * picture. It is meant to be used when the construction of a picture aborted.
723 * Note that the picture will be destroyed even if it is linked !
724 *****************************************************************************/
725 void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
727 vlc_mutex_lock( &p_vout->picture_lock );
730 /* Check if picture status is valid */
731 if( (p_pic->i_status != RESERVED_PICTURE) &&
732 (p_pic->i_status != RESERVED_DATED_PICTURE) &&
733 (p_pic->i_status != RESERVED_DISP_PICTURE) )
735 intf_DbgMsg("error: picture %p has invalid status %d\n", p_pic, p_pic->i_status );
739 p_pic->i_status = DESTROYED_PICTURE;
740 p_vout->i_pictures--;
743 intf_DbgMsg("picture %p\n", p_pic);
745 vlc_mutex_unlock( &p_vout->picture_lock );
748 /*****************************************************************************
749 * vout_LinkPicture: increment reference counter of a picture
750 *****************************************************************************
751 * This function increment the reference counter of a picture in the video
752 * heap. It needs a lock since several producer threads can access the picture.
753 *****************************************************************************/
754 void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
756 vlc_mutex_lock( &p_vout->picture_lock );
760 intf_DbgMsg("picture %p refcount=%d\n", p_pic, p_pic->i_refcount );
763 vlc_mutex_unlock( &p_vout->picture_lock );
766 /*****************************************************************************
767 * vout_UnlinkPicture: decrement reference counter of a picture
768 *****************************************************************************
769 * This function decrement the reference counter of a picture in the video heap.
770 *****************************************************************************/
771 void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
773 vlc_mutex_lock( &p_vout->picture_lock );
777 if( p_pic->i_refcount < 0 )
779 intf_DbgMsg("error: refcount < 0\n");
780 p_pic->i_refcount = 0;
784 if( (p_pic->i_refcount == 0) && (p_pic->i_status == DISPLAYED_PICTURE) )
786 p_pic->i_status = DESTROYED_PICTURE;
787 p_vout->i_pictures--;
791 intf_DbgMsg("picture %p refcount=%d\n", p_pic, p_pic->i_refcount );
794 vlc_mutex_unlock( &p_vout->picture_lock );
797 /*****************************************************************************
798 * vout_SetBuffers: set buffers adresses
799 *****************************************************************************
800 * This function is called by system drivers to set buffers video memory
802 *****************************************************************************/
803 void vout_SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
805 /* No picture previously */
806 p_vout->p_buffer[0].i_pic_x = 0;
807 p_vout->p_buffer[0].i_pic_y = 0;
808 p_vout->p_buffer[0].i_pic_width = 0;
809 p_vout->p_buffer[0].i_pic_height = 0;
810 p_vout->p_buffer[1].i_pic_x = 0;
811 p_vout->p_buffer[1].i_pic_y = 0;
812 p_vout->p_buffer[1].i_pic_width = 0;
813 p_vout->p_buffer[1].i_pic_height = 0;
815 /* The first area covers all the screen */
816 p_vout->p_buffer[0].i_areas = 1;
817 p_vout->p_buffer[0].pi_area_begin[0] = 0;
818 p_vout->p_buffer[0].pi_area_end[0] = p_vout->i_height - 1;
819 p_vout->p_buffer[1].i_areas = 1;
820 p_vout->p_buffer[1].pi_area_begin[0] = 0;
821 p_vout->p_buffer[1].pi_area_end[0] = p_vout->i_height - 1;
824 p_vout->p_buffer[0].p_data = p_buf1;
825 p_vout->p_buffer[1].p_data = p_buf2;
828 /*****************************************************************************
829 * vout_Pixel2RGB: return red, green and blue from pixel value
830 *****************************************************************************
831 * Return color values, in 0-255 range, of the decomposition of a pixel. This
832 * is a slow routine and should only be used for initialization phase.
833 *****************************************************************************/
834 void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
836 *pi_red = i_pixel & p_vout->i_red_mask;
837 *pi_green = i_pixel & p_vout->i_green_mask;
838 *pi_blue = i_pixel & p_vout->i_blue_mask;
841 /* following functions are local */
843 /*****************************************************************************
844 * BinaryLog: computes the base 2 log of a binary value
845 *****************************************************************************
846 * This functions is used by MaskToShift, to get a bit index from a binary
848 *****************************************************************************/
849 static int BinaryLog(u32 i)
874 if (i != ((u32)1 << i_log))
876 intf_DbgMsg("internal error: binary log overflow\n");
882 /*****************************************************************************
883 * MaskToShift: transform a color mask into right and left shifts
884 *****************************************************************************
885 * This function is used for obtaining color shifts from masks.
886 *****************************************************************************/
887 static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
889 u32 i_low, i_high; /* lower hand higher bits of the mask */
892 i_low = i_mask & (- i_mask); /* lower bit of the mask */
893 i_high = i_mask + i_low; /* higher bit of the mask */
895 /* Transform bits into an index */
896 i_low = BinaryLog (i_low);
897 i_high = BinaryLog (i_high);
899 /* Update pointers and return */
901 *pi_right = (8 - i_high + i_low);
904 /*****************************************************************************
905 * InitThread: initialize video output thread
906 *****************************************************************************
907 * This function is called from RunThread and performs the second step of the
908 * initialization. It returns 0 on success. Note that the thread's flag are not
909 * modified inside this function.
910 *****************************************************************************/
911 static int InitThread( vout_thread_t *p_vout )
915 *p_vout->pi_status = THREAD_START;
921 /* Initialize output method - this function issues its own error messages */
922 if( p_vout->p_sys_init( p_vout ) )
927 if( p_vout->b_need_render )
929 /* Initialize convertion tables and functions */
930 if( vout_InitYUV( p_vout ) )
932 intf_ErrMsg("error: can't allocate YUV translation tables\n");
937 /* Mark thread as running and return */
938 p_vout->b_active = 1;
939 *p_vout->pi_status = THREAD_READY;
942 intf_DbgMsg("thread ready\n");
946 /*****************************************************************************
947 * RunThread: video output thread
948 *****************************************************************************
949 * Video output thread. This function does only returns when the thread is
950 * terminated. It handles the pictures arriving in the video heap and the
951 * display device events.
952 *****************************************************************************/
953 static void RunThread( vout_thread_t *p_vout)
955 int i_index; /* index in heap */
956 mtime_t current_date; /* current date */
957 mtime_t display_date; /* display date */
958 boolean_t b_display; /* display flag */
959 picture_t * p_pic; /* picture pointer */
960 subpicture_t * p_subpic; /* subpicture pointer */
965 p_vout->b_error = InitThread( p_vout );
966 if( p_vout->b_error )
968 DestroyThread( p_vout, THREAD_ERROR );
974 * Main loop - it is not executed if an error occured during
977 while( (!p_vout->b_die) && (!p_vout->b_error) )
979 /* Initialize loop variables */
983 current_date = mdate();
986 if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
988 intf_Msg("vout stats: picture heap: %d/%d\n",
989 p_vout->i_pictures, VOUT_MAX_PICTURES);
994 * Find the picture to display - this operation does not need lock,
995 * since only READY_PICTUREs are handled
997 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
999 if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) &&
1000 ( (p_pic == NULL) ||
1001 (p_vout->p_picture[i_index].date < display_date) ) )
1003 p_pic = &p_vout->p_picture[i_index];
1004 display_date = p_pic->date;
1010 /* Computes FPS rate */
1011 p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ] = display_date;
1013 if( display_date < current_date - p_vout->render_time )
1015 /* Picture is late: it will be destroyed and the thread
1016 * will sleep and go to next picture */
1018 vlc_mutex_lock( &p_vout->picture_lock );
1019 if( p_pic->i_refcount )
1021 p_pic->i_status = DISPLAYED_PICTURE;
1025 p_pic->i_status = DESTROYED_PICTURE;
1026 p_vout->i_pictures--;
1029 "warning: late picture skipped (%p)\n", p_pic );
1030 vlc_mutex_unlock( &p_vout->picture_lock );
1034 else if( display_date > current_date + VOUT_DISPLAY_DELAY )
1036 /* A picture is ready to be rendered, but its rendering date
1037 * is far from the current one so the thread will perform an
1038 * empty loop as if no picture were found. The picture state
1045 * Find the subpictures to display - this operation does not need
1046 * lock, since only READY_SUBPICTURE are handled. If no picture
1047 * has been selected, display_date will depend on the subpicture.
1048 * We get an easily parsable chained list of subpictures which
1049 * ends with NULL since p_subpic was initialized to NULL.
1051 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1053 if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
1055 p_vout->p_subpicture[i_index].p_next = p_subpic;
1056 p_subpic = &p_vout->p_subpicture[i_index];
1061 * Perform rendering, sleep and display rendered picture
1063 if( p_pic ) /* picture and perhaps subpicture */
1065 b_display = p_vout->b_active;
1066 p_vout->last_display_date = display_date;
1067 p_vout->p_rendered_pic = p_pic;
1069 /* FIXME: if b_need_render == 0 we need to do something with
1070 * the subpictures one day. */
1071 if( p_vout->b_need_render && b_display )
1073 /* Set picture dimensions and clear buffer */
1074 SetBufferPicture( p_vout, p_pic );
1076 /* Render picture and information */
1077 RenderPicture( p_vout, p_pic );
1078 if( p_vout->b_info )
1080 RenderPictureInfo( p_vout, p_pic );
1081 RenderInfo( p_vout );
1085 RenderSubPicture( p_vout, p_subpic );
1089 /* Render interface and subpicture */
1090 if( b_display && p_vout->b_interface && p_vout->b_need_render )
1092 RenderInterface( p_vout );
1096 else if( p_vout->b_active && p_vout->b_need_render
1097 && p_vout->init_display_date == 0)
1099 /* Idle or interface screen alone */
1101 if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
1103 /* Interface has changed, so a new rendering is required - force
1104 * it by setting last idle date to 0 */
1105 p_vout->last_idle_date = 0;
1108 /* Render idle screen and update idle date, then render interface if
1110 b_display = RenderIdle( p_vout );
1113 p_vout->last_idle_date = current_date;
1114 if( p_vout->b_interface )
1116 RenderInterface( p_vout );
1128 * Check for the current time and
1129 * display splash screen if everything is on time
1131 if( p_vout->init_display_date > 0 && p_vout->b_need_render )
1133 if( p_vout->b_active &&
1134 mdate()-p_vout->init_display_date < 5000000)
1136 /* there is something to display ! */
1138 RenderSplash( p_vout );
1141 /* no splash screen ! */
1142 intf_ErrMsgImm("End of splash screen\n");
1143 p_vout->init_display_date=0;
1149 * Sleep, wake up and display rendered picture
1152 if( display_date != 0 )
1154 /* Store render time using Bresenham algorithm */
1155 p_vout->render_time += mdate() - current_date;
1156 p_vout->render_time >>= 1;
1159 /* Give back change lock */
1160 vlc_mutex_unlock( &p_vout->change_lock );
1162 /* Sleep a while or until a given date */
1163 if( display_date != 0 )
1165 mwait( display_date - VOUT_MWAIT_TOLERANCE );
1169 msleep( VOUT_IDLE_SLEEP );
1172 /* On awakening, take back lock and send immediately picture to display,
1173 * then swap buffers */
1174 vlc_mutex_lock( &p_vout->change_lock );
1176 intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d\n", p_pic, p_subpic,
1177 p_vout->i_buffer_index, b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ );
1179 if( b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ )
1181 p_vout->p_sys_display( p_vout );
1183 p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;
1189 /* Remove picture from heap */
1190 vlc_mutex_lock( &p_vout->picture_lock );
1191 if( p_pic->i_refcount )
1193 p_pic->i_status = DISPLAYED_PICTURE;
1197 p_pic->i_status = DESTROYED_PICTURE;
1198 p_vout->i_pictures--;
1200 vlc_mutex_unlock( &p_vout->picture_lock );
1205 * Check events and manage thread
1207 if( p_vout->p_sys_manage( p_vout ) | Manage( p_vout ) )
1209 /* A fatal error occured, and the thread must terminate immediately,
1210 * without displaying anything - setting b_error to 1 cause the
1211 * immediate end of the main while() loop. */
1212 p_vout->b_error = 1;
1217 * Error loop - wait until the thread destruction is requested
1219 if( p_vout->b_error )
1221 ErrorThread( p_vout );
1225 EndThread( p_vout );
1226 DestroyThread( p_vout, THREAD_OVER );
1227 intf_DbgMsg( "thread end\n" );
1230 /*****************************************************************************
1231 * ErrorThread: RunThread() error loop
1232 *****************************************************************************
1233 * This function is called when an error occured during thread main's loop. The
1234 * thread can still receive feed, but must be ready to terminate as soon as
1236 *****************************************************************************/
1237 static void ErrorThread( vout_thread_t *p_vout )
1239 /* Wait until a `die' order */
1241 while( !p_vout->b_die )
1244 msleep( VOUT_IDLE_SLEEP );
1248 /*****************************************************************************
1249 * EndThread: thread destruction
1250 *****************************************************************************
1251 * This function is called when the thread ends after a sucessful
1252 * initialization. It frees all ressources allocated by InitThread.
1253 *****************************************************************************/
1254 static void EndThread( vout_thread_t *p_vout )
1256 int i_index; /* index in heap */
1260 *p_vout->pi_status = THREAD_END;
1262 /* Destroy all remaining pictures and subpictures */
1263 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
1265 if( p_vout->p_picture[i_index].i_status != FREE_PICTURE )
1267 free( p_vout->p_picture[i_index].p_data );
1270 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1272 if( p_vout->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
1274 free( p_vout->p_subpicture[i_index].p_data );
1278 /* Destroy translation tables */
1279 vout_EndYUV( p_vout );
1280 p_vout->p_sys_end( p_vout );
1283 /*****************************************************************************
1284 * DestroyThread: thread destruction
1285 *****************************************************************************
1286 * This function is called when the thread ends. It frees all ressources
1287 * allocated by CreateThread. Status is available at this stage.
1288 *****************************************************************************/
1289 static void DestroyThread( vout_thread_t *p_vout, int i_status )
1291 int *pi_status; /* status adress */
1293 /* Store status adress */
1295 pi_status = p_vout->pi_status;
1297 /* Destroy thread structures allocated by Create and InitThread */
1298 vout_UnloadFont( p_vout->p_default_font );
1299 vout_UnloadFont( p_vout->p_large_font );
1300 p_vout->p_sys_destroy( p_vout );
1302 /* Free structure */
1304 *pi_status = i_status;
1307 /*****************************************************************************
1308 * Print: print simple text on a picture
1309 *****************************************************************************
1310 * This function will print a simple text on the picture. It is designed to
1311 * print debugging or general information.
1312 *****************************************************************************/
1313 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 )
1315 int i_text_height; /* total text height */
1316 int i_text_width; /* total text width */
1318 /* Update upper left coordinates according to alignment */
1319 vout_TextSize( p_vout->p_default_font, 0, psz_text, &i_text_width, &i_text_height );
1320 if( !Align( p_vout, &i_x, &i_y, i_text_width, i_text_height, i_h_align, i_v_align ) )
1322 /* Set area and print text */
1323 SetBufferArea( p_vout, i_x, i_y, i_text_width, i_text_height );
1324 vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1325 i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
1326 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1327 p_vout->i_white_pixel, 0, 0,
1332 /*****************************************************************************
1333 * SetBufferArea: activate an area in current buffer
1334 *****************************************************************************
1335 * This function is called when something is rendered on the current buffer.
1336 * It set the area as active and prepare it to be cleared on next rendering.
1337 * Pay attention to the fact that in this functions, i_h is in fact the end y
1338 * coordinate of the new area.
1339 *****************************************************************************/
1340 static void SetBufferArea( vout_thread_t *p_vout, int i_x, int i_y, int i_w, int i_h )
1342 vout_buffer_t * p_buffer; /* current buffer */
1343 int i_area_begin, i_area_end; /* area vertical extension */
1344 int i_area, i_area_copy; /* area index */
1345 int i_area_shift; /* shift distance for areas */
1347 /* Choose buffer and modify h to end of area position */
1348 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1352 * Remove part of the area which is inside the picture - this is done
1353 * by calling again SetBufferArea with the correct areas dimensions.
1355 if( (i_x >= p_buffer->i_pic_x) && (i_x + i_w <= p_buffer->i_pic_x + p_buffer->i_pic_width) )
1357 i_area_begin = p_buffer->i_pic_y;
1358 i_area_end = i_area_begin + p_buffer->i_pic_height - 1;
1360 if( ((i_y >= i_area_begin) && (i_y <= i_area_end)) ||
1361 ((i_h >= i_area_begin) && (i_h <= i_area_end)) ||
1362 ((i_y < i_area_begin) && (i_h > i_area_end)) )
1364 /* Keep the stripe above the picture, if any */
1365 if( i_y < i_area_begin )
1367 SetBufferArea( p_vout, i_x, i_y, i_w, i_area_begin - i_y );
1369 /* Keep the stripe below the picture, if any */
1370 if( i_h > i_area_end )
1372 SetBufferArea( p_vout, i_x, i_area_end, i_w, i_h - i_area_end );
1378 /* Skip some extensions until interesting areas */
1380 (i_area < p_buffer->i_areas) &&
1381 (p_buffer->pi_area_end[i_area] + 1 <= i_y);
1387 if( i_area == p_buffer->i_areas )
1389 /* New area is below all existing ones: just add it at the end of the
1390 * array, if possible - otherwise, append it to the last one */
1391 if( i_area < VOUT_MAX_AREAS )
1393 p_buffer->pi_area_begin[i_area] = i_y;
1394 p_buffer->pi_area_end[i_area] = i_h;
1395 p_buffer->i_areas++;
1400 intf_DbgMsg("area overflow\n");
1402 p_buffer->pi_area_end[VOUT_MAX_AREAS - 1] = i_h;
1407 i_area_begin = p_buffer->pi_area_begin[i_area];
1408 i_area_end = p_buffer->pi_area_end[i_area];
1410 if( i_y < i_area_begin )
1412 if( i_h >= i_area_begin - 1 )
1414 /* Extend area above */
1415 p_buffer->pi_area_begin[i_area] = i_y;
1419 /* Create a new area above : merge last area if overflow, then
1420 * move all old areas down */
1421 if( p_buffer->i_areas == VOUT_MAX_AREAS )
1424 intf_DbgMsg("areas overflow\n");
1426 p_buffer->pi_area_end[VOUT_MAX_AREAS - 2] = p_buffer->pi_area_end[VOUT_MAX_AREAS - 1];
1430 p_buffer->i_areas++;
1432 for( i_area_copy = p_buffer->i_areas - 1; i_area_copy > i_area; i_area_copy-- )
1434 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy - 1];
1435 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy - 1];
1437 p_buffer->pi_area_begin[i_area] = i_y;
1438 p_buffer->pi_area_end[i_area] = i_h;
1442 if( i_h > i_area_end )
1444 /* Find further areas which can be merged with the new one */
1445 for( i_area_copy = i_area + 1;
1446 (i_area_copy < p_buffer->i_areas) &&
1447 (p_buffer->pi_area_begin[i_area] <= i_h);
1454 if( i_area_copy != i_area )
1456 /* Merge with last possible areas */
1457 p_buffer->pi_area_end[i_area] = MAX( i_h, p_buffer->pi_area_end[i_area_copy] );
1459 /* Shift lower areas upward */
1460 i_area_shift = i_area_copy - i_area;
1461 p_buffer->i_areas -= i_area_shift;
1462 for( i_area_copy = i_area + 1; i_area_copy < p_buffer->i_areas; i_area_copy++ )
1464 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy + i_area_shift];
1465 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy + i_area_shift];
1470 /* Extend area below */
1471 p_buffer->pi_area_end[i_area] = i_h;
1477 /*****************************************************************************
1478 * SetBufferPicture: clear buffer and set picture area
1479 *****************************************************************************
1480 * This function is called before any rendering. It clears the current
1481 * rendering buffer and set the new picture area. If the picture pointer is
1482 * NULL, then no picture area is defined. Floating operations are avoided since
1483 * some MMX calculations may follow.
1484 *****************************************************************************/
1485 static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
1487 vout_buffer_t * p_buffer; /* current buffer */
1488 int i_pic_x, i_pic_y; /* picture position */
1489 int i_pic_width, i_pic_height; /* picture dimensions */
1490 int i_old_pic_y, i_old_pic_height; /* old picture area */
1491 int i_vout_width, i_vout_height; /* display dimensions */
1492 int i_area; /* area index */
1493 int i_data_index; /* area data index */
1494 int i_data_size; /* area data size, in 256 bytes blocs */
1495 u64 * p_data; /* area data, for clearing */
1496 byte_t * p_data8; /* area data, for clearing (slow) */
1498 /* Choose buffer and set display dimensions */
1499 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1500 i_vout_width = p_vout->i_width;
1501 i_vout_height = p_vout->i_height;
1504 * Computes new picture size
1508 /* Try horizontal scaling first - width must be a mutiple of 16 */
1509 i_pic_width = (( p_vout->b_scale || (p_pic->i_width > i_vout_width)) ?
1510 i_vout_width : p_pic->i_width) & ~0xf;
1511 switch( p_pic->i_aspect_ratio )
1513 case AR_3_4_PICTURE:
1514 i_pic_height = i_pic_width * 3 / 4;
1516 case AR_16_9_PICTURE:
1517 i_pic_height = i_pic_width * 9 / 16;
1519 case AR_221_1_PICTURE:
1520 i_pic_height = i_pic_width * 100 / 221;
1522 case AR_SQUARE_PICTURE:
1524 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1528 /* If picture dimensions using horizontal scaling are too large, use
1529 * vertical scaling. Since width must be a multiple of 16, height is
1530 * adjusted again after. */
1531 if( i_pic_height > i_vout_height )
1533 i_pic_height = ( p_vout->b_scale || (p_pic->i_height > i_vout_height)) ?
1534 i_vout_height : p_pic->i_height;
1535 switch( p_pic->i_aspect_ratio )
1537 case AR_3_4_PICTURE:
1538 i_pic_width = (i_pic_height * 4 / 3) & ~0xf;
1539 i_pic_height = i_pic_width * 3 / 4;
1541 case AR_16_9_PICTURE:
1542 i_pic_width = (i_pic_height * 16 / 9) & ~0xf;
1543 i_pic_height = i_pic_width * 9 / 16;
1545 case AR_221_1_PICTURE:
1546 i_pic_width = (i_pic_height * 221 / 100) & ~0xf;
1547 i_pic_height = i_pic_width * 100 / 221;
1549 case AR_SQUARE_PICTURE:
1551 i_pic_width = (p_pic->i_width * i_pic_height / p_pic->i_height) & ~0xf;
1552 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1557 /* Set picture position */
1558 i_pic_x = (p_vout->i_width - i_pic_width) / 2;
1559 i_pic_y = (p_vout->i_height - i_pic_height) / 2;
1563 /* No picture: size is 0 */
1571 * Set new picture size - if it is smaller than the previous one, clear
1572 * around it. Since picture are centered, only their size is tested.
1574 if( (p_buffer->i_pic_width > i_pic_width) || (p_buffer->i_pic_height > i_pic_height) )
1576 i_old_pic_y = p_buffer->i_pic_y;
1577 i_old_pic_height = p_buffer->i_pic_height;
1578 p_buffer->i_pic_x = i_pic_x;
1579 p_buffer->i_pic_y = i_pic_y;
1580 p_buffer->i_pic_width = i_pic_width;
1581 p_buffer->i_pic_height = i_pic_height;
1582 SetBufferArea( p_vout, 0, i_old_pic_y, p_vout->i_width, i_old_pic_height );
1586 p_buffer->i_pic_x = i_pic_x;
1587 p_buffer->i_pic_y = i_pic_y;
1588 p_buffer->i_pic_width = i_pic_width;
1589 p_buffer->i_pic_height = i_pic_height;
1595 for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
1598 intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d\n", p_pic,
1599 p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
1601 i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
1602 p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
1603 for( i_data_index = i_data_size / 256; i_data_index-- ; )
1605 /* Clear 256 bytes block */
1606 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1607 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1608 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1609 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1610 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1611 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1612 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1613 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1615 for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
1617 /* Clear remaining 16 bytes blocks */
1618 *p_data++ = 0; *p_data++ = 0;
1620 p_data8 = (byte_t *)p_data;
1621 for( i_data_index = i_data_size % 16; i_data_index--; )
1623 /* Clear remaining bytes */
1631 p_buffer->i_areas = 0;
1634 /*****************************************************************************
1635 * RenderPicture: render a picture
1636 *****************************************************************************
1637 * This function converts a picture from a video heap to a pixel-encoded image
1638 * and copies it to the current rendering buffer. No lock is required, since
1639 * the * rendered picture has been determined as existant, and will only be
1640 * destroyed by the vout thread later.
1641 *****************************************************************************/
1642 static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
1645 char psz_date[MSTRTIME_MAX_SIZE]; /* picture date */
1646 mtime_t render_time; /* picture rendering time */
1648 vout_buffer_t * p_buffer; /* rendering buffer */
1649 byte_t * p_pic_data; /* convertion destination */
1651 /* Get and set rendering information */
1652 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1653 p_pic_data = p_buffer->p_data +
1654 p_buffer->i_pic_x * p_vout->i_bytes_per_pixel +
1655 p_buffer->i_pic_y * p_vout->i_bytes_per_line;
1657 render_time = mdate();
1661 * Choose appropriate rendering function and render picture
1663 switch( p_pic->i_type )
1665 case YUV_420_PICTURE:
1666 p_vout->yuv.p_Convert420( p_vout, p_pic_data,
1667 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1668 p_pic->i_width, p_pic->i_height,
1669 p_buffer->i_pic_width, p_buffer->i_pic_height,
1670 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1671 p_pic->i_matrix_coefficients );
1673 case YUV_422_PICTURE:
1674 p_vout->yuv.p_Convert422( p_vout, p_pic_data,
1675 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1676 p_pic->i_width, p_pic->i_height,
1677 p_buffer->i_pic_width, p_buffer->i_pic_height,
1678 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1679 p_pic->i_matrix_coefficients );
1681 case YUV_444_PICTURE:
1682 p_vout->yuv.p_Convert444( p_vout, p_pic_data,
1683 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1684 p_pic->i_width, p_pic->i_height,
1685 p_buffer->i_pic_width, p_buffer->i_pic_height,
1686 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1687 p_pic->i_matrix_coefficients );
1691 intf_DbgMsg("error: unknown picture type %d\n", p_pic->i_type );
1697 /* Print picture date and rendering time */
1698 intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s\n", p_pic,
1699 p_vout->i_buffer_index, (long) (mdate() - render_time),
1700 mstrtime( psz_date, p_pic->date ));
1704 /*****************************************************************************
1705 * RenderPictureInfo: print additionnal information on a picture
1706 *****************************************************************************
1707 * This function will print information such as fps and other picture
1708 * dependant information.
1709 *****************************************************************************/
1710 static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
1712 char psz_buffer[256]; /* string buffer */
1715 * Print FPS rate in upper right corner
1717 if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
1719 long i_fps = VOUT_FPS_SAMPLES * 1000000 * 10 /
1720 ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1)
1721 % VOUT_FPS_SAMPLES ] -
1722 p_vout->p_fps_sample[ p_vout->c_fps_samples
1723 % VOUT_FPS_SAMPLES ] );
1724 sprintf( psz_buffer, "%li.%i fps", i_fps / 10, (int)i_fps % 10 );
1725 Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
1729 * Print frames count and loop time in upper left corner
1731 sprintf( psz_buffer, "%ld frames, render: %ldus",
1732 (long) p_vout->c_fps_samples, (long) p_vout->render_time );
1733 Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
1737 * Print picture information in lower right corner
1739 sprintf( psz_buffer, "%s picture %dx%d (%dx%d%+d%+d %s) -> %dx%d+%d+%d",
1740 (p_pic->i_type == YUV_420_PICTURE) ? "4:2:0" :
1741 ((p_pic->i_type == YUV_422_PICTURE) ? "4:2:2" :
1742 ((p_pic->i_type == YUV_444_PICTURE) ? "4:4:4" : "ukn-type")),
1743 p_pic->i_width, p_pic->i_height,
1744 p_pic->i_display_width, p_pic->i_display_height,
1745 p_pic->i_display_horizontal_offset, p_pic->i_display_vertical_offset,
1746 (p_pic->i_aspect_ratio == AR_SQUARE_PICTURE) ? "sq" :
1747 ((p_pic->i_aspect_ratio == AR_3_4_PICTURE) ? "4:3" :
1748 ((p_pic->i_aspect_ratio == AR_16_9_PICTURE) ? "16:9" :
1749 ((p_pic->i_aspect_ratio == AR_221_1_PICTURE) ? "2.21:1" : "ukn-ar" ))),
1750 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_width,
1751 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height,
1752 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_x,
1753 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y );
1754 Print( p_vout, 0, 0, RIGHT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1758 /*****************************************************************************
1759 * RenderSplash: render splash picture
1760 *****************************************************************************
1761 * This function will print something on the screen. It will return 0 if
1762 * nothing has been rendered, or 1 if something has been changed on the screen.
1763 * Note that if you absolutely want something to be printed, you will have
1764 * to force it by setting the last idle date to 0.
1765 * Unlike other rendering functions, this one calls the SetBufferPicture
1766 * function when needed.
1767 *****************************************************************************/
1768 int RenderSplash( vout_thread_t *p_vout )
1770 int i_x = 0, i_y = 0; /* text position */
1771 int i_width, i_height; /* text size */
1772 char *psz_text = "VideoLAN Client (" VERSION ")"; /* text to display */
1774 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1775 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1777 // SetBufferPicture( p_vout, NULL );
1778 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1779 &i_width, &i_height );
1780 if( !Align( p_vout, &i_x, &i_y, i_width, i_height, CENTER_RALIGN, CENTER_RALIGN ) )
1782 vout_Print( p_vout->p_large_font,
1783 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1784 i_x * p_vout->i_bytes_per_pixel + (i_y - 16 ) * p_vout->i_bytes_per_line,
1785 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1786 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1787 WIDE_TEXT | OUTLINED_TEXT, psz_text, 100);
1788 SetBufferArea( p_vout, i_x, i_y, i_width, i_height);
1794 /*****************************************************************************
1795 * RenderIdle: render idle picture
1796 *****************************************************************************
1797 * This function will print something on the screen. It will return 0 if
1798 * nothing has been rendered, or 1 if something has been changed on the screen.
1799 * Note that if you absolutely want something to be printed, you will have
1800 * to force it by setting the last idle date to 0.
1801 * Unlike other rendering functions, this one calls the SetBufferPicture
1802 * function when needed.
1803 *****************************************************************************/
1804 int RenderIdle( vout_thread_t *p_vout )
1806 int i_x = 0, i_y = 0; /* text position */
1807 int i_width, i_height; /* text size */
1808 mtime_t current_date; /* current date */
1809 int i_amount = 0; /* amount to draw */
1810 char *psz_text = "Waiting for stream"; /* text to display */
1811 char *psz_wtext = "[................]";
1814 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1815 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1818 current_date = mdate();
1819 if( (current_date - p_vout->last_display_date) > VOUT_IDLE_DELAY
1820 // && (current_date - p_vout->last_idle_date) > VOUT_IDLE_DELAY
1823 SetBufferPicture( p_vout, NULL );
1824 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1825 &i_width, &i_height );
1826 if( !Align( p_vout, &i_x, &i_y, i_width, i_height * 2, CENTER_RALIGN, CENTER_RALIGN ) )
1828 i_amount = (int) ((current_date - p_vout->last_display_date ) / 5000LL);
1829 vout_Print( p_vout->p_large_font,
1830 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1831 i_x * p_vout->i_bytes_per_pixel + i_y * p_vout->i_bytes_per_line,
1832 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1833 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1834 WIDE_TEXT | OUTLINED_TEXT, psz_text, (i_amount / 3 ) %110);
1836 vout_Print( p_vout->p_large_font,
1837 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1838 i_x * p_vout->i_bytes_per_pixel + (i_y + 16) * p_vout->i_bytes_per_line,
1839 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1840 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1841 WIDE_TEXT | OUTLINED_TEXT, psz_wtext, (i_amount/5)%110 );
1844 SetBufferArea( p_vout, i_x, i_y, i_width, i_height * 2 );
1851 /*****************************************************************************
1852 * RenderInfo: render additionnal information
1853 *****************************************************************************
1854 * This function renders information which do not depend on the current
1856 *****************************************************************************/
1857 static void RenderInfo( vout_thread_t *p_vout )
1860 char psz_buffer[256]; /* string buffer */
1861 int i_ready_pic = 0; /* ready pictures */
1862 int i_reserved_pic = 0; /* reserved pictures */
1863 int i_picture; /* picture index */
1868 * Print thread state in lower left corner
1870 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
1872 switch( p_vout->p_picture[i_picture].i_status )
1874 case RESERVED_PICTURE:
1875 case RESERVED_DATED_PICTURE:
1876 case RESERVED_DISP_PICTURE:
1884 sprintf( psz_buffer, "pic: %d (%d/%d)/%d",
1885 p_vout->i_pictures, i_reserved_pic, i_ready_pic, VOUT_MAX_PICTURES );
1886 Print( p_vout, 0, 0, LEFT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1890 /*****************************************************************************
1891 * RenderSubPicture: render a subpicture
1892 *****************************************************************************
1893 * This function renders a sub picture unit.
1894 *****************************************************************************/
1895 static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
1897 p_vout_font_t p_font; /* text font */
1898 int i_width, i_height; /* subpicture dimensions */
1900 while( p_subpic != NULL )
1902 switch( p_subpic->i_type )
1904 case DVD_SUBPICTURE: /* DVD subpicture unit */
1905 /* test if the picture really has to be displayed */
1906 if( mdate() < p_subpic->begin_date )
1908 /* not yet, see you later */
1911 if( mdate() > p_subpic->end_date )
1913 /* too late, destroying the subpic */
1914 vout_DestroySubPicture( p_vout, p_subpic );
1917 vout_RenderSPU( &p_vout->p_buffer[ p_vout->i_buffer_index ],
1918 p_subpic, p_vout->i_bytes_per_pixel,
1919 p_vout->i_bytes_per_line );
1921 case TEXT_SUBPICTURE: /* single line text */
1922 /* Select default font if not specified */
1923 p_font = p_subpic->type.text.p_font;
1924 if( p_font == NULL )
1926 p_font = p_vout->p_default_font;
1929 /* Compute text size (width and height fields are ignored)
1931 vout_TextSize( p_font, p_subpic->type.text.i_style,
1932 p_subpic->p_data, &i_width, &i_height );
1933 if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y,
1934 i_width, i_height, p_subpic->i_horizontal_align,
1935 p_subpic->i_vertical_align ) )
1938 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1939 p_subpic->i_x * p_vout->i_bytes_per_pixel +
1940 p_subpic->i_y * p_vout->i_bytes_per_line,
1941 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1942 p_subpic->type.text.i_char_color,
1943 p_subpic->type.text.i_border_color,
1944 p_subpic->type.text.i_bg_color,
1945 p_subpic->type.text.i_style, p_subpic->p_data, 100 );
1946 SetBufferArea( p_vout, p_subpic->i_x, p_subpic->i_y,
1947 i_width, i_height );
1953 intf_DbgMsg( "error: unknown subpicture %p type %d\n",
1954 p_subpic, p_subpic->i_type );
1958 p_subpic = p_subpic->p_next;
1962 /*****************************************************************************
1963 * RenderInterface: render the interface
1964 *****************************************************************************
1965 * This function renders the interface, if any.
1966 *****************************************************************************/
1967 static void RenderInterface( vout_thread_t *p_vout )
1969 int i_height, i_text_height; /* total and text height */
1970 int i_width_1, i_width_2; /* text width */
1971 int i_byte; /* byte index */
1972 const char *psz_text_1 = "[1-9] Channel [i]nfo [c]olor [g/G]amma";
1973 const char *psz_text_2 = "[+/-] Volume [m]ute [s]caling [Q]uit";
1976 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_1, &i_width_1, &i_height );
1977 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_2, &i_width_2, &i_text_height );
1978 i_height += i_text_height;
1980 /* Render background */
1981 for( i_byte = (p_vout->i_height - i_height) * p_vout->i_bytes_per_line;
1982 i_byte < p_vout->i_height * p_vout->i_bytes_per_line;
1986 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = p_vout->i_blue_pixel;
1989 /* Render text, if not larger than screen */
1990 if( i_width_1 < p_vout->i_width )
1992 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1993 (p_vout->i_height - i_height) * p_vout->i_bytes_per_line,
1994 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1995 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
1996 OUTLINED_TEXT, psz_text_1, 100 );
1998 if( i_width_2 < p_vout->i_width )
2000 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2001 (p_vout->i_height - i_height + i_text_height) * p_vout->i_bytes_per_line,
2002 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2003 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2004 OUTLINED_TEXT, psz_text_2, 100 );
2007 /* Activate modified area */
2008 SetBufferArea( p_vout, 0, p_vout->i_height - i_height, p_vout->i_width, i_height );
2011 /*****************************************************************************
2012 * Manage: manage thread
2013 *****************************************************************************
2014 * This function will handle changes in thread configuration.
2015 *****************************************************************************/
2016 static int Manage( vout_thread_t *p_vout )
2019 if( p_vout->i_changes )
2021 intf_DbgMsg("changes: 0x%x (no display: 0x%x)\n", p_vout->i_changes,
2022 0 /* p_vout->i_changes & VOUT_NODISPLAY_CHANGE */ );
2026 /* On gamma or grayscale change, rebuild tables */
2027 if( p_vout->i_changes & (VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2030 /* Change vdec_DecodeMacroblock when switching between BW and C */
2031 if( !p_vout->b_grayscale )
2033 p_vout->vdec_DecodeMacroblock = vdec_DecodeMacroblockC;
2035 else if( p_vout->b_grayscale)
2037 p_vout->vdec_DecodeMacroblock = vdec_DecodeMacroblockBW;
2039 if( vout_ResetYUV( p_vout ) )
2041 intf_ErrMsg("error: can't rebuild convertion tables\n");
2046 /* Clear changes flags which does not need management or have been
2048 p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2049 VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
2050 VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE );
2052 /* Detect unauthorized changes */
2053 if( p_vout->i_changes )
2055 /* Some changes were not acknowledged by p_vout->p_sys_manage or this
2056 * function, it means they should not be authorized */
2057 intf_ErrMsg( "error: unauthorized changes in the video output thread\n" );
2064 /*****************************************************************************
2065 * Align: align a subpicture in the screen
2066 *****************************************************************************
2067 * This function is used for rendering text or subpictures. It returns non 0
2068 * it the final aera is not fully included in display area. Return coordinates
2070 *****************************************************************************/
2071 static int Align( vout_thread_t *p_vout, int *pi_x, int *pi_y,
2072 int i_width, int i_height, int i_h_align, int i_v_align )
2074 /* Align horizontally */
2078 *pi_x -= i_width / 2;
2081 *pi_x += (p_vout->i_width - i_width) / 2;
2087 *pi_x += p_vout->i_width - i_width;
2091 /* Align vertically */
2095 *pi_y -= i_height / 2;
2098 *pi_y += (p_vout->i_height - i_height) / 2;
2104 *pi_y += p_vout->i_height - i_height;
2106 case SUBTITLE_RALIGN:
2107 *pi_y += (p_vout->i_height + p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y +
2108 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height - i_height) / 2;
2112 /* Return non 0 if clipping failed */
2113 return( (*pi_x < 0) || (*pi_y < 0) ||
2114 (*pi_x + i_width > p_vout->i_width) || (*pi_y + i_height > p_vout->i_height) );
2117 /*****************************************************************************
2118 * SetPalette: sets an 8 bpp palette
2119 *****************************************************************************
2120 * This function is just a prototype that does nothing. Architectures that
2121 * support palette allocation should override it.
2122 *****************************************************************************/
2123 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
2124 u16 *green, u16 *blue, u16 *transp )
2126 intf_ErrMsg( "SetPalette: method does not support palette changing\n" );