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
8 * $Id: video_output.c,v 1.121 2001/04/27 19:29:11 massiot Exp $
10 * Authors: Vincent Seguin <seguin@via.ecp.fr>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
32 #include <errno.h> /* ENOMEM */
33 #include <stdlib.h> /* free() */
34 #include <stdio.h> /* sprintf() */
35 #include <string.h> /* strerror() */
38 # include <sys/times.h>
48 #include "video_output.h"
49 #include "video_text.h"
50 #include "video_spu.h"
51 #include "video_yuv.h"
57 /*****************************************************************************
59 *****************************************************************************/
60 static int BinaryLog ( u32 i );
61 static void MaskToShift ( int *pi_left, int *pi_right, u32 i_mask );
62 static int InitThread ( vout_thread_t *p_vout );
63 static void RunThread ( vout_thread_t *p_vout );
64 static void ErrorThread ( vout_thread_t *p_vout );
65 static void EndThread ( vout_thread_t *p_vout );
66 static void DestroyThread ( vout_thread_t *p_vout, int i_status );
67 static void Print ( vout_thread_t *p_vout, int i_x, int i_y,
68 int i_h_align, int i_v_align,
69 unsigned char *psz_text );
70 static void SetBufferArea ( vout_thread_t *p_vout, int i_x, int i_y,
72 static void SetBufferPicture ( vout_thread_t *p_vout, picture_t *p_pic );
73 static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
74 static void RenderPictureInfo ( vout_thread_t *p_vout, picture_t *p_pic );
75 static void RenderSubPicture ( vout_thread_t *p_vout,
76 subpicture_t *p_subpic );
77 static void RenderInterface ( vout_thread_t *p_vout );
78 static int RenderIdle ( vout_thread_t *p_vout );
79 static int RenderSplash ( vout_thread_t *p_vout );
80 static void RenderInfo ( vout_thread_t *p_vout );
81 static int Manage ( vout_thread_t *p_vout );
82 static int Align ( vout_thread_t *p_vout, int *pi_x,
83 int *pi_y, int i_width, int i_height,
84 int i_h_align, int i_v_align );
85 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
86 u16 *green, u16 *blue, u16 *transp );
88 /*****************************************************************************
89 * vout_CreateThread: creates a new video output thread
90 *****************************************************************************
91 * This function creates a new video output thread, and returns a pointer
92 * to its description. On error, it returns NULL.
93 * If pi_status is NULL, then the function will block until the thread is ready.
94 * If not, it will be updated using one of the THREAD_* constants.
95 *****************************************************************************/
96 vout_thread_t * vout_CreateThread ( int *pi_status )
98 vout_thread_t * p_vout; /* thread descriptor */
99 int i_status; /* thread status */
100 int i_index; /* index for array initialization */
102 /* Allocate descriptor */
103 p_vout = (vout_thread_t *) malloc( sizeof(vout_thread_t) );
106 intf_ErrMsg( "vout error: vout thread creation returned %s",
111 /* Choose the best module */
112 p_vout->p_module = module_Need( p_main->p_bank,
113 MODULE_CAPABILITY_VOUT, NULL );
115 if( p_vout->p_module == NULL )
117 intf_ErrMsg( "vout error: no suitable vout module" );
122 #define f p_vout->p_module->p_functions->vout.functions.vout
123 p_vout->pf_create = f.pf_create;
124 p_vout->pf_init = f.pf_init;
125 p_vout->pf_end = f.pf_end;
126 p_vout->pf_destroy = f.pf_destroy;
127 p_vout->pf_manage = f.pf_manage;
128 p_vout->pf_display = f.pf_display;
129 p_vout->pf_setpalette = f.pf_setpalette;
132 if( p_vout->pf_setpalette == NULL )
134 p_vout->pf_setpalette = SetPalette;
137 /* Initialize thread properties - thread id and locks will be initialized
141 p_vout->b_active = 0;
142 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
143 *p_vout->pi_status = THREAD_CREATE;
145 /* Initialize some fields used by the system-dependant method - these
146 * fields will probably be modified by the method, and are only
148 p_vout->i_changes = 0;
149 p_vout->i_width = main_GetIntVariable( VOUT_WIDTH_VAR,
150 VOUT_WIDTH_DEFAULT );
151 p_vout->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR,
152 VOUT_HEIGHT_DEFAULT );
153 p_vout->i_bytes_per_line = p_vout->i_width * 2;
154 p_vout->i_screen_depth = 15;
155 p_vout->i_bytes_per_pixel = 2;
156 p_vout->f_gamma = VOUT_GAMMA;
157 p_vout->b_need_render = 1;
160 p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
161 VOUT_GRAYSCALE_DEFAULT );
163 p_vout->b_interface = 0;
166 intf_WarnMsg( 1, "wished configuration: %dx%d, %d/%d bpp (%d Bpl)",
167 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
168 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
170 /* Initialize idle screen */
171 p_vout->last_display_date = 0;
172 p_vout->last_idle_date = 0;
173 p_vout->init_display_date = mdate();
174 p_vout->render_time = 10000;
176 /* Initialize statistics fields */
177 p_vout->c_fps_samples = 0;
179 /* Initialize buffer index */
180 p_vout->i_buffer_index = 0;
182 /* Initialize pictures and subpictures - translation tables and functions
183 * will be initialized later in InitThread */
184 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
186 p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
187 p_vout->p_picture[i_index].i_status = FREE_PICTURE;
189 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
191 p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
192 p_vout->p_subpicture[i_index].i_status= FREE_SUBPICTURE;
194 p_vout->i_pictures = 0;
196 /* Create and initialize system-dependant method - this function issues its
197 * own error messages */
198 if( p_vout->pf_create( p_vout ) )
200 module_Unneed( p_main->p_bank, p_vout->p_module );
204 intf_WarnMsg( 1, "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
205 "masks: 0x%x/0x%x/0x%x",
206 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
207 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
208 p_vout->i_red_mask, p_vout->i_green_mask,
209 p_vout->i_blue_mask );
211 /* Calculate shifts from system-updated masks */
212 MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
213 p_vout->i_red_mask );
214 MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
215 p_vout->i_green_mask );
216 MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
217 p_vout->i_blue_mask );
219 /* Set some useful colors */
220 p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
221 p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
222 p_vout->i_gray_pixel = RGB2PIXEL( p_vout, 128, 128, 128 );
223 p_vout->i_blue_pixel = RGB2PIXEL( p_vout, 0, 0, 50 );
225 /* Load fonts - fonts must be initialized after the system method since
226 * they may be dependant on screen depth and other thread properties */
227 p_vout->p_default_font = vout_LoadFont( VOUT_DEFAULT_FONT );
228 if( p_vout->p_default_font == NULL )
230 intf_ErrMsg( "vout error: could not load default font" );
233 p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
234 if( p_vout->p_large_font == NULL )
236 intf_ErrMsg( "vout error: could not load large font" );
239 /* Create thread and set locks */
240 vlc_mutex_init( &p_vout->picture_lock );
241 vlc_mutex_init( &p_vout->subpicture_lock );
242 vlc_mutex_init( &p_vout->change_lock );
244 if( vlc_thread_create( &p_vout->thread_id, "video output",
245 (void *) RunThread, (void *) p_vout) )
247 intf_ErrMsg("vout error: %s", strerror(ENOMEM));
248 vout_UnloadFont( p_vout->p_default_font );
249 vout_UnloadFont( p_vout->p_large_font );
250 p_vout->pf_destroy( p_vout );
255 intf_Msg( "vout: video display initialized (%dx%d, %d/%d bpp)",
256 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
257 p_vout->i_bytes_per_pixel * 8 );
259 /* If status is NULL, wait until the thread is created */
260 if( pi_status == NULL )
264 msleep( THREAD_SLEEP );
265 }while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
266 && (i_status != THREAD_FATAL) );
267 if( i_status != THREAD_READY )
275 /*****************************************************************************
276 * vout_DestroyThread: destroys a previously created thread
277 *****************************************************************************
278 * Destroy a terminated thread.
279 * The function will request a destruction of the specified thread. If pi_error
280 * is NULL, it will return once the thread is destroyed. Else, it will be
281 * update using one of the THREAD_* constants.
282 *****************************************************************************/
283 void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
285 int i_status; /* thread status */
289 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
290 *p_vout->pi_status = THREAD_DESTROY;
292 /* Request thread destruction */
295 /* If status is NULL, wait until thread has been destroyed */
296 if( pi_status == NULL )
300 msleep( THREAD_SLEEP );
301 }while( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
302 && (i_status != THREAD_FATAL) );
306 /*****************************************************************************
307 * vout_DisplaySubPicture: display a subpicture unit
308 *****************************************************************************
309 * Remove the reservation flag of an subpicture, which will cause it to be ready
310 * for display. The picture does not need to be locked, since it is ignored by
311 * the output thread if is reserved.
312 *****************************************************************************/
313 void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
316 char psz_begin_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
317 char psz_end_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
321 /* Check if status is valid */
322 if( p_subpic->i_status != RESERVED_SUBPICTURE )
324 intf_ErrMsg("error: subpicture %p has invalid status %d", p_subpic,
325 p_subpic->i_status );
329 /* Remove reservation flag */
330 p_subpic->i_status = READY_SUBPICTURE;
333 /* Send subpicture information */
334 intf_DbgMsg("subpicture %p: type=%d, begin date=%s, end date=%s",
335 p_subpic, p_subpic->i_type,
336 mstrtime( psz_begin_date, p_subpic->begin_date ),
337 mstrtime( psz_end_date, p_subpic->end_date ) );
341 /*****************************************************************************
342 * vout_CreateSubPicture: allocate a subpicture in the video output heap.
343 *****************************************************************************
344 * This function create a reserved subpicture in the video output heap.
345 * A null pointer is returned if the function fails. This method provides an
346 * already allocated zone of memory in the spu data fields. It needs locking
347 * since several pictures can be created by several producers threads.
348 *****************************************************************************/
349 subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
352 int i_subpic; /* subpicture index */
353 subpicture_t * p_free_subpic = NULL; /* first free subpicture */
354 subpicture_t * p_destroyed_subpic = NULL; /* first destroyed subpic */
357 vlc_mutex_lock( &p_vout->subpicture_lock );
360 * Look for an empty place
362 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
364 if( p_vout->p_subpicture[i_subpic].i_status == DESTROYED_SUBPICTURE )
366 /* Subpicture is marked for destruction, but is still allocated */
367 if( (p_vout->p_subpicture[i_subpic].i_type == i_type) &&
368 (p_vout->p_subpicture[i_subpic].i_size >= i_size) )
370 /* Memory size do match or is smaller : memory will not be
371 * reallocated, and function can end immediately - this is
372 * the best possible case, since no memory allocation needs
374 p_vout->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
376 intf_DbgMsg("subpicture %p (in destroyed subpicture slot)",
377 &p_vout->p_subpicture[i_subpic] );
379 vlc_mutex_unlock( &p_vout->subpicture_lock );
380 return( &p_vout->p_subpicture[i_subpic] );
382 else if( p_destroyed_subpic == NULL )
384 /* Memory size do not match, but subpicture index will be kept in
385 * case no other place are left */
386 p_destroyed_subpic = &p_vout->p_subpicture[i_subpic];
389 else if( (p_free_subpic == NULL) &&
390 (p_vout->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE ))
392 /* Subpicture is empty and ready for allocation */
393 p_free_subpic = &p_vout->p_subpicture[i_subpic];
397 /* If no free subpictures are available, use a destroyed subpicture */
398 if( (p_free_subpic == NULL) && (p_destroyed_subpic != NULL ) )
400 /* No free subpicture or matching destroyed subpictures have been
401 * found, but a destroyed subpicture is still avalaible */
402 free( p_destroyed_subpic->p_data );
403 p_free_subpic = p_destroyed_subpic;
409 if( p_free_subpic != NULL )
411 /* Allocate memory */
414 case TEXT_SUBPICTURE: /* text subpicture */
415 p_free_subpic->p_data = malloc( i_size + 1 );
417 case DVD_SUBPICTURE: /* DVD subpicture unit */
418 p_free_subpic->p_data = malloc( i_size );
422 intf_ErrMsg("error: unknown subpicture type %d", i_type );
423 p_free_subpic->p_data = NULL;
428 if( p_free_subpic->p_data != NULL )
430 /* Copy subpicture information, set some default values */
431 p_free_subpic->i_type = i_type;
432 p_free_subpic->i_status = RESERVED_SUBPICTURE;
433 p_free_subpic->i_size = i_size;
434 p_free_subpic->i_x = 0;
435 p_free_subpic->i_y = 0;
436 p_free_subpic->i_width = 0;
437 p_free_subpic->i_height = 0;
438 p_free_subpic->i_horizontal_align = CENTER_RALIGN;
439 p_free_subpic->i_vertical_align = CENTER_RALIGN;
443 /* Memory allocation failed : set subpicture as empty */
444 p_free_subpic->i_type = EMPTY_SUBPICTURE;
445 p_free_subpic->i_status = FREE_SUBPICTURE;
446 p_free_subpic = NULL;
447 intf_ErrMsg( "vout error: spu allocation returned %s",
448 strerror( ENOMEM ) );
452 intf_DbgMsg("subpicture %p (in free subpicture slot)", p_free_subpic );
454 vlc_mutex_unlock( &p_vout->subpicture_lock );
455 return( p_free_subpic );
458 /* No free or destroyed subpicture could be found */
459 intf_DbgMsg( "warning: subpicture heap is full" );
460 vlc_mutex_unlock( &p_vout->subpicture_lock );
464 /*****************************************************************************
465 * vout_DestroySubPicture: remove a subpicture from the heap
466 *****************************************************************************
467 * This function frees a previously reserved subpicture.
468 * It is meant to be used when the construction of a picture aborted.
469 * This function does not need locking since reserved subpictures are ignored
470 * by the output thread.
471 *****************************************************************************/
472 void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
475 /* Check if status is valid */
476 if( p_subpic->i_status != RESERVED_SUBPICTURE )
478 intf_ErrMsg("error: subpicture %p has invalid status %d",
479 p_subpic, p_subpic->i_status );
483 p_subpic->i_status = DESTROYED_SUBPICTURE;
486 intf_DbgMsg("subpicture %p", p_subpic);
490 /*****************************************************************************
491 * vout_DisplayPicture: display a picture
492 *****************************************************************************
493 * Remove the reservation flag of a picture, which will cause it to be ready for
494 * display. The picture won't be displayed until vout_DatePicture has been
496 *****************************************************************************/
497 void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
499 vlc_mutex_lock( &p_vout->picture_lock );
500 switch( p_pic->i_status )
502 case RESERVED_PICTURE:
503 p_pic->i_status = RESERVED_DISP_PICTURE;
505 case RESERVED_DATED_PICTURE:
506 p_pic->i_status = READY_PICTURE;
510 intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
516 intf_DbgMsg("picture %p", p_pic);
518 vlc_mutex_unlock( &p_vout->picture_lock );
521 /*****************************************************************************
522 * vout_DatePicture: date a picture
523 *****************************************************************************
524 * Remove the reservation flag of a picture, which will cause it to be ready for
525 * display. The picture won't be displayed until vout_DisplayPicture has been
527 *****************************************************************************/
528 void vout_DatePicture( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date )
531 char psz_date[MSTRTIME_MAX_SIZE]; /* date */
534 vlc_mutex_lock( &p_vout->picture_lock );
536 switch( p_pic->i_status )
538 case RESERVED_PICTURE:
539 p_pic->i_status = RESERVED_DATED_PICTURE;
541 case RESERVED_DISP_PICTURE:
542 p_pic->i_status = READY_PICTURE;
546 intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
552 intf_DbgMsg("picture %p, display date: %s", p_pic, mstrtime( psz_date, p_pic->date) );
554 vlc_mutex_unlock( &p_vout->picture_lock );
557 /*****************************************************************************
558 * vout_CreatePicture: allocate a picture in the video output heap.
559 *****************************************************************************
560 * This function create a reserved image in the video output heap.
561 * A null pointer is returned if the function fails. This method provides an
562 * already allocated zone of memory in the picture data fields. It needs locking
563 * since several pictures can be created by several producers threads.
564 *****************************************************************************/
565 picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
566 int i_width, int i_height )
568 int i_picture; /* picture index */
569 int i_chroma_width = 0; /* chroma width */
570 picture_t * p_free_picture = NULL; /* first free picture */
571 picture_t * p_destroyed_picture = NULL; /* first destroyed picture */
574 vlc_mutex_lock( &p_vout->picture_lock );
577 * Look for an empty place
579 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
581 if( p_vout->p_picture[i_picture].i_status == DESTROYED_PICTURE )
583 /* Picture is marked for destruction, but is still allocated - note
584 * that if width and type are the same for two pictures, chroma_width
585 * should also be the same */
586 if( (p_vout->p_picture[i_picture].i_type == i_type) &&
587 (p_vout->p_picture[i_picture].i_height == i_height) &&
588 (p_vout->p_picture[i_picture].i_width == i_width) )
590 /* Memory size do match : memory will not be reallocated, and function
591 * can end immediately - this is the best possible case, since no
592 * memory allocation needs to be done */
593 p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
594 p_vout->i_pictures++;
596 intf_DbgMsg("picture %p (in destroyed picture slot)",
597 &p_vout->p_picture[i_picture] );
599 vlc_mutex_unlock( &p_vout->picture_lock );
600 return( &p_vout->p_picture[i_picture] );
602 else if( p_destroyed_picture == NULL )
604 /* Memory size do not match, but picture index will be kept in
605 * case no other place are left */
606 p_destroyed_picture = &p_vout->p_picture[i_picture];
609 else if( (p_free_picture == NULL) &&
610 (p_vout->p_picture[i_picture].i_status == FREE_PICTURE ))
612 /* Picture is empty and ready for allocation */
613 p_free_picture = &p_vout->p_picture[i_picture];
617 /* If no free picture is available, use a destroyed picture */
618 if( (p_free_picture == NULL) && (p_destroyed_picture != NULL ) )
620 /* No free picture or matching destroyed picture has been found, but
621 * a destroyed picture is still avalaible */
622 free( p_destroyed_picture->p_data );
623 p_free_picture = p_destroyed_picture;
629 if( p_free_picture != NULL )
631 /* Allocate memory */
634 case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
635 i_chroma_width = i_width / 2;
636 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
637 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
638 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*4/2;
639 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*5/2;
641 case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
642 i_chroma_width = i_width / 2;
643 p_free_picture->p_data = malloc( i_height * i_chroma_width * 4 * sizeof( yuv_data_t ) );
644 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
645 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
646 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*3;
648 case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
649 i_chroma_width = i_width;
650 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
651 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
652 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width;
653 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
657 intf_ErrMsg("error: unknown picture type %d", i_type );
658 p_free_picture->p_data = NULL;
663 if( p_free_picture->p_data != NULL )
665 /* Copy picture information, set some default values */
666 p_free_picture->i_type = i_type;
667 p_free_picture->i_status = RESERVED_PICTURE;
668 p_free_picture->i_matrix_coefficients = 1;
669 p_free_picture->i_width = i_width;
670 p_free_picture->i_height = i_height;
671 p_free_picture->i_chroma_width = i_chroma_width;
672 p_free_picture->i_size = i_width * i_height;
673 p_free_picture->i_chroma_size = i_chroma_width
675 p_free_picture->i_display_horizontal_offset = 0;
676 p_free_picture->i_display_vertical_offset = 0;
677 p_free_picture->i_display_width = i_width;
678 p_free_picture->i_display_height = i_height;
679 p_free_picture->i_aspect_ratio = AR_SQUARE_PICTURE;
680 p_free_picture->i_refcount = 0;
681 p_vout->i_pictures++;
685 /* Memory allocation failed : set picture as empty */
686 p_free_picture->i_type = EMPTY_PICTURE;
687 p_free_picture->i_status = FREE_PICTURE;
688 p_free_picture = NULL;
689 intf_ErrMsg( "vout error: picture allocation returned %s",
690 strerror( ENOMEM ) );
694 intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
696 vlc_mutex_unlock( &p_vout->picture_lock );
698 /* Initialize mutex */
699 vlc_mutex_init( &(p_free_picture->lock_deccount) );
701 return( p_free_picture );
704 /* No free or destroyed picture could be found */
705 intf_DbgMsg( "warning: picture heap is full" );
706 vlc_mutex_unlock( &p_vout->picture_lock );
710 /*****************************************************************************
711 * vout_DestroyPicture: remove a permanent or reserved picture from the heap
712 *****************************************************************************
713 * This function frees a previously reserved picture or a permanent
714 * picture. It is meant to be used when the construction of a picture aborted.
715 * Note that the picture will be destroyed even if it is linked !
716 *****************************************************************************/
717 void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
719 vlc_mutex_lock( &p_vout->picture_lock );
722 /* Check if picture status is valid */
723 if( (p_pic->i_status != RESERVED_PICTURE) &&
724 (p_pic->i_status != RESERVED_DATED_PICTURE) &&
725 (p_pic->i_status != RESERVED_DISP_PICTURE) )
727 intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
731 p_pic->i_status = DESTROYED_PICTURE;
732 p_vout->i_pictures--;
735 intf_DbgMsg("picture %p", p_pic);
738 /* destroy the lock that had been initialized in CreatePicture */
739 vlc_mutex_destroy( &(p_pic->lock_deccount) );
741 vlc_mutex_unlock( &p_vout->picture_lock );
744 /*****************************************************************************
745 * vout_LinkPicture: increment reference counter of a picture
746 *****************************************************************************
747 * This function increment the reference counter of a picture in the video
748 * heap. It needs a lock since several producer threads can access the picture.
749 *****************************************************************************/
750 void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
752 vlc_mutex_lock( &p_vout->picture_lock );
756 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
759 vlc_mutex_unlock( &p_vout->picture_lock );
762 /*****************************************************************************
763 * vout_UnlinkPicture: decrement reference counter of a picture
764 *****************************************************************************
765 * This function decrement the reference counter of a picture in the video heap.
766 *****************************************************************************/
767 void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
769 vlc_mutex_lock( &p_vout->picture_lock );
773 if( p_pic->i_refcount < 0 )
775 intf_DbgMsg("error: refcount < 0");
776 p_pic->i_refcount = 0;
780 if( (p_pic->i_refcount == 0) && (p_pic->i_status == DISPLAYED_PICTURE) )
782 p_pic->i_status = DESTROYED_PICTURE;
783 p_vout->i_pictures--;
787 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
790 vlc_mutex_unlock( &p_vout->picture_lock );
793 /*****************************************************************************
794 * vout_SetBuffers: set buffers adresses
795 *****************************************************************************
796 * This function is called by system drivers to set buffers video memory
798 *****************************************************************************/
799 void vout_SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
801 /* No picture previously */
802 p_vout->p_buffer[0].i_pic_x = 0;
803 p_vout->p_buffer[0].i_pic_y = 0;
804 p_vout->p_buffer[0].i_pic_width = 0;
805 p_vout->p_buffer[0].i_pic_height = 0;
806 p_vout->p_buffer[1].i_pic_x = 0;
807 p_vout->p_buffer[1].i_pic_y = 0;
808 p_vout->p_buffer[1].i_pic_width = 0;
809 p_vout->p_buffer[1].i_pic_height = 0;
811 /* The first area covers all the screen */
812 p_vout->p_buffer[0].i_areas = 1;
813 p_vout->p_buffer[0].pi_area_begin[0] = 0;
814 p_vout->p_buffer[0].pi_area_end[0] = p_vout->i_height - 1;
815 p_vout->p_buffer[1].i_areas = 1;
816 p_vout->p_buffer[1].pi_area_begin[0] = 0;
817 p_vout->p_buffer[1].pi_area_end[0] = p_vout->i_height - 1;
820 p_vout->p_buffer[0].p_data = p_buf1;
821 p_vout->p_buffer[1].p_data = p_buf2;
824 /*****************************************************************************
825 * vout_Pixel2RGB: return red, green and blue from pixel value
826 *****************************************************************************
827 * Return color values, in 0-255 range, of the decomposition of a pixel. This
828 * is a slow routine and should only be used for initialization phase.
829 *****************************************************************************/
830 void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
832 *pi_red = i_pixel & p_vout->i_red_mask;
833 *pi_green = i_pixel & p_vout->i_green_mask;
834 *pi_blue = i_pixel & p_vout->i_blue_mask;
837 /* following functions are local */
839 /*****************************************************************************
840 * BinaryLog: computes the base 2 log of a binary value
841 *****************************************************************************
842 * This functions is used by MaskToShift, to get a bit index from a binary
844 *****************************************************************************/
845 static int BinaryLog(u32 i)
870 if (i != ((u32)1 << i_log))
872 intf_DbgMsg("internal error: binary log overflow");
878 /*****************************************************************************
879 * MaskToShift: transform a color mask into right and left shifts
880 *****************************************************************************
881 * This function is used for obtaining color shifts from masks.
882 *****************************************************************************/
883 static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
885 u32 i_low, i_high; /* lower hand higher bits of the mask */
888 i_low = i_mask & (- i_mask); /* lower bit of the mask */
889 i_high = i_mask + i_low; /* higher bit of the mask */
891 /* Transform bits into an index */
892 i_low = BinaryLog (i_low);
893 i_high = BinaryLog (i_high);
895 /* Update pointers and return */
897 *pi_right = (8 - i_high + i_low);
900 /*****************************************************************************
901 * InitThread: initialize video output thread
902 *****************************************************************************
903 * This function is called from RunThread and performs the second step of the
904 * initialization. It returns 0 on success. Note that the thread's flag are not
905 * modified inside this function.
906 *****************************************************************************/
907 static int InitThread( vout_thread_t *p_vout )
910 *p_vout->pi_status = THREAD_START;
912 vlc_mutex_lock( &p_vout->change_lock );
918 /* Initialize output method - this function issues its own error messages */
919 if( p_vout->pf_init( p_vout ) )
924 /* Initialize convertion tables and functions */
925 if( vout_InitYUV( p_vout ) )
927 intf_ErrMsg("vout error: can't allocate YUV translation tables");
931 /* Mark thread as running and return */
932 p_vout->b_active = 1;
933 *p_vout->pi_status = THREAD_READY;
936 intf_DbgMsg("thread ready");
940 /*****************************************************************************
941 * RunThread: video output thread
942 *****************************************************************************
943 * Video output thread. This function does only returns when the thread is
944 * terminated. It handles the pictures arriving in the video heap and the
945 * display device events.
946 *****************************************************************************/
947 static void RunThread( vout_thread_t *p_vout)
949 int i_index; /* index in heap */
950 mtime_t current_date; /* current date */
951 mtime_t display_date; /* display date */
952 boolean_t b_display; /* display flag */
953 picture_t * p_pic; /* picture pointer */
954 subpicture_t * p_subpic; /* subpicture pointer */
959 p_vout->b_error = InitThread( p_vout );
960 if( p_vout->b_error )
962 DestroyThread( p_vout, THREAD_ERROR );
967 * Main loop - it is not executed if an error occured during
970 while( (!p_vout->b_die) && (!p_vout->b_error) )
972 /* Initialize loop variables */
976 current_date = mdate();
979 if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
981 intf_Msg("vout stats: picture heap: %d/%d",
982 p_vout->i_pictures, VOUT_MAX_PICTURES);
987 * Find the picture to display - this operation does not need lock,
988 * since only READY_PICTUREs are handled
990 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
992 if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) &&
994 (p_vout->p_picture[i_index].date < display_date) ) )
996 p_pic = &p_vout->p_picture[i_index];
997 display_date = p_pic->date;
1003 /* Computes FPS rate */
1004 p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ] = display_date;
1006 if( display_date < current_date - p_vout->render_time )
1008 /* Picture is late: it will be destroyed and the thread
1009 * will sleep and go to next picture */
1011 vlc_mutex_lock( &p_vout->picture_lock );
1012 if( p_pic->i_refcount )
1014 p_pic->i_status = DISPLAYED_PICTURE;
1018 p_pic->i_status = DESTROYED_PICTURE;
1019 p_vout->i_pictures--;
1022 "warning: late picture skipped (%p)", p_pic );
1023 vlc_mutex_unlock( &p_vout->picture_lock );
1027 else if( display_date > current_date + VOUT_DISPLAY_DELAY )
1029 /* A picture is ready to be rendered, but its rendering date
1030 * is far from the current one so the thread will perform an
1031 * empty loop as if no picture were found. The picture state
1038 * Find the subpictures to display - this operation does not need
1039 * lock, since only READY_SUBPICTURE are handled. If no picture
1040 * has been selected, display_date will depend on the subpicture.
1041 * We get an easily parsable chained list of subpictures which
1042 * ends with NULL since p_subpic was initialized to NULL.
1044 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1046 if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
1048 p_vout->p_subpicture[i_index].p_next = p_subpic;
1049 p_subpic = &p_vout->p_subpicture[i_index];
1054 * Perform rendering, sleep and display rendered picture
1056 if( p_pic ) /* picture and perhaps subpicture */
1058 b_display = p_vout->b_active;
1059 p_vout->last_display_date = display_date;
1060 p_vout->p_rendered_pic = p_pic;
1065 /* Set picture dimensions and clear buffer */
1066 SetBufferPicture( p_vout, p_pic );
1068 /* FIXME: if b_need_render == 0 we need to do something with
1069 * the subpictures one day. */
1071 if( p_vout->b_need_render && b_display )
1073 /* Render picture and information */
1074 RenderPicture( p_vout, p_pic );
1075 if( p_vout->b_info )
1077 RenderPictureInfo( p_vout, p_pic );
1078 RenderInfo( p_vout );
1082 RenderSubPicture( p_vout, p_subpic );
1086 /* Render interface and subpicture */
1087 if( b_display && p_vout->b_interface && p_vout->b_need_render )
1089 RenderInterface( p_vout );
1093 else if( p_vout->b_active && p_vout->b_need_render
1094 && p_vout->init_display_date == 0)
1096 /* Idle or interface screen alone */
1098 if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
1100 /* Interface has changed, so a new rendering is required - force
1101 * it by setting last idle date to 0 */
1102 p_vout->last_idle_date = 0;
1105 /* Render idle screen and update idle date, then render interface if
1107 b_display = RenderIdle( p_vout );
1110 p_vout->last_idle_date = current_date;
1111 if( p_vout->b_interface )
1113 RenderInterface( p_vout );
1125 * Check for the current time and
1126 * display splash screen if everything is on time
1128 if( p_vout->init_display_date > 0 && p_vout->b_need_render )
1130 if( p_vout->b_active &&
1131 mdate()-p_vout->init_display_date < 5000000)
1133 /* there is something to display ! */
1135 RenderSplash( p_vout );
1138 /* no splash screen ! */
1139 p_vout->init_display_date=0;
1145 * Sleep, wake up and display rendered picture
1148 if( display_date != 0 )
1150 /* Store render time using Bresenham algorithm */
1151 p_vout->render_time += mdate() - current_date;
1152 p_vout->render_time >>= 1;
1155 /* Give back change lock */
1156 vlc_mutex_unlock( &p_vout->change_lock );
1158 /* Sleep a while or until a given date */
1159 if( display_date != 0 )
1161 mwait( display_date - VOUT_MWAIT_TOLERANCE );
1165 msleep( VOUT_IDLE_SLEEP );
1168 /* On awakening, take back lock and send immediately picture to display,
1169 * then swap buffers */
1170 vlc_mutex_lock( &p_vout->change_lock );
1172 intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d", p_pic, p_subpic,
1173 p_vout->i_buffer_index, b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ );
1175 if( b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ )
1177 p_vout->pf_display( p_vout );
1179 p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;
1185 /* Remove picture from heap */
1186 vlc_mutex_lock( &p_vout->picture_lock );
1187 if( p_pic->i_refcount )
1189 p_pic->i_status = DISPLAYED_PICTURE;
1193 p_pic->i_status = DESTROYED_PICTURE;
1194 p_vout->i_pictures--;
1196 vlc_mutex_unlock( &p_vout->picture_lock );
1201 * Check events and manage thread
1203 if( p_vout->pf_manage( p_vout ) | Manage( p_vout ) )
1205 /* A fatal error occured, and the thread must terminate immediately,
1206 * without displaying anything - setting b_error to 1 cause the
1207 * immediate end of the main while() loop. */
1208 p_vout->b_error = 1;
1213 * Error loop - wait until the thread destruction is requested
1215 if( p_vout->b_error )
1217 ErrorThread( p_vout );
1221 EndThread( p_vout );
1222 DestroyThread( p_vout, THREAD_OVER );
1223 intf_DbgMsg( "thread end" );
1226 /*****************************************************************************
1227 * ErrorThread: RunThread() error loop
1228 *****************************************************************************
1229 * This function is called when an error occured during thread main's loop. The
1230 * thread can still receive feed, but must be ready to terminate as soon as
1232 *****************************************************************************/
1233 static void ErrorThread( vout_thread_t *p_vout )
1235 /* Wait until a `die' order */
1236 while( !p_vout->b_die )
1239 msleep( VOUT_IDLE_SLEEP );
1243 /*****************************************************************************
1244 * EndThread: thread destruction
1245 *****************************************************************************
1246 * This function is called when the thread ends after a sucessful
1247 * initialization. It frees all ressources allocated by InitThread.
1248 *****************************************************************************/
1249 static void EndThread( vout_thread_t *p_vout )
1251 int i_index; /* index in heap */
1254 *p_vout->pi_status = THREAD_END;
1258 struct tms cpu_usage;
1259 times( &cpu_usage );
1261 intf_Msg( "vout stats: cpu usage (user: %d, system: %d)",
1262 cpu_usage.tms_utime, cpu_usage.tms_stime );
1266 /* Destroy all remaining pictures and subpictures */
1267 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
1269 if( p_vout->p_picture[i_index].i_status != FREE_PICTURE )
1271 free( p_vout->p_picture[i_index].p_data );
1275 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1277 if( p_vout->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
1279 free( p_vout->p_subpicture[i_index].p_data );
1283 /* Destroy translation tables */
1284 vout_EndYUV( p_vout );
1285 p_vout->pf_end( p_vout );
1287 /* Release the change lock */
1288 vlc_mutex_unlock( &p_vout->change_lock );
1291 /*****************************************************************************
1292 * DestroyThread: thread destruction
1293 *****************************************************************************
1294 * This function is called when the thread ends. It frees all ressources
1295 * allocated by CreateThread. Status is available at this stage.
1296 *****************************************************************************/
1297 static void DestroyThread( vout_thread_t *p_vout, int i_status )
1299 int *pi_status; /* status adress */
1301 /* Store status adress */
1302 pi_status = p_vout->pi_status;
1304 /* Destroy thread structures allocated by Create and InitThread */
1305 vout_UnloadFont( p_vout->p_default_font );
1306 vout_UnloadFont( p_vout->p_large_font );
1307 p_vout->pf_destroy( p_vout );
1309 /* Destroy the locks */
1310 vlc_mutex_destroy( &p_vout->picture_lock );
1311 vlc_mutex_destroy( &p_vout->subpicture_lock );
1312 vlc_mutex_destroy( &p_vout->change_lock );
1314 /* Release the module */
1315 module_Unneed( p_main->p_bank, p_vout->p_module );
1317 /* Free structure */
1319 *pi_status = i_status;
1322 /*****************************************************************************
1323 * Print: print simple text on a picture
1324 *****************************************************************************
1325 * This function will print a simple text on the picture. It is designed to
1326 * print debugging or general information.
1327 *****************************************************************************/
1328 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 )
1330 int i_text_height; /* total text height */
1331 int i_text_width; /* total text width */
1333 /* Update upper left coordinates according to alignment */
1334 vout_TextSize( p_vout->p_default_font, 0, psz_text, &i_text_width, &i_text_height );
1335 if( !Align( p_vout, &i_x, &i_y, i_text_width, i_text_height, i_h_align, i_v_align ) )
1337 /* Set area and print text */
1338 SetBufferArea( p_vout, i_x, i_y, i_text_width, i_text_height );
1339 vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1340 i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
1341 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1342 p_vout->i_white_pixel, 0, 0,
1347 /*****************************************************************************
1348 * SetBufferArea: activate an area in current buffer
1349 *****************************************************************************
1350 * This function is called when something is rendered on the current buffer.
1351 * It set the area as active and prepare it to be cleared on next rendering.
1352 * Pay attention to the fact that in this functions, i_h is in fact the end y
1353 * coordinate of the new area.
1354 *****************************************************************************/
1355 static void SetBufferArea( vout_thread_t *p_vout, int i_x, int i_y, int i_w, int i_h )
1357 vout_buffer_t * p_buffer; /* current buffer */
1358 int i_area_begin, i_area_end; /* area vertical extension */
1359 int i_area, i_area_copy; /* area index */
1360 int i_area_shift; /* shift distance for areas */
1362 /* Choose buffer and modify h to end of area position */
1363 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1367 * Remove part of the area which is inside the picture - this is done
1368 * by calling again SetBufferArea with the correct areas dimensions.
1370 if( (i_x >= p_buffer->i_pic_x) && (i_x + i_w <= p_buffer->i_pic_x + p_buffer->i_pic_width) )
1372 i_area_begin = p_buffer->i_pic_y;
1373 i_area_end = i_area_begin + p_buffer->i_pic_height - 1;
1375 if( ((i_y >= i_area_begin) && (i_y <= i_area_end)) ||
1376 ((i_h >= i_area_begin) && (i_h <= i_area_end)) ||
1377 ((i_y < i_area_begin) && (i_h > i_area_end)) )
1379 /* Keep the stripe above the picture, if any */
1380 if( i_y < i_area_begin )
1382 SetBufferArea( p_vout, i_x, i_y, i_w, i_area_begin - i_y );
1384 /* Keep the stripe below the picture, if any */
1385 if( i_h > i_area_end )
1387 SetBufferArea( p_vout, i_x, i_area_end, i_w, i_h - i_area_end );
1393 /* Skip some extensions until interesting areas */
1395 (i_area < p_buffer->i_areas) &&
1396 (p_buffer->pi_area_end[i_area] + 1 <= i_y);
1402 if( i_area == p_buffer->i_areas )
1404 /* New area is below all existing ones: just add it at the end of the
1405 * array, if possible - otherwise, append it to the last one */
1406 if( i_area < VOUT_MAX_AREAS )
1408 p_buffer->pi_area_begin[i_area] = i_y;
1409 p_buffer->pi_area_end[i_area] = i_h;
1410 p_buffer->i_areas++;
1415 intf_DbgMsg("area overflow");
1417 p_buffer->pi_area_end[VOUT_MAX_AREAS - 1] = i_h;
1422 i_area_begin = p_buffer->pi_area_begin[i_area];
1423 i_area_end = p_buffer->pi_area_end[i_area];
1425 if( i_y < i_area_begin )
1427 if( i_h >= i_area_begin - 1 )
1429 /* Extend area above */
1430 p_buffer->pi_area_begin[i_area] = i_y;
1434 /* Create a new area above : merge last area if overflow, then
1435 * move all old areas down */
1436 if( p_buffer->i_areas == VOUT_MAX_AREAS )
1439 intf_DbgMsg("areas overflow");
1441 p_buffer->pi_area_end[VOUT_MAX_AREAS - 2] = p_buffer->pi_area_end[VOUT_MAX_AREAS - 1];
1445 p_buffer->i_areas++;
1447 for( i_area_copy = p_buffer->i_areas - 1; i_area_copy > i_area; i_area_copy-- )
1449 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy - 1];
1450 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy - 1];
1452 p_buffer->pi_area_begin[i_area] = i_y;
1453 p_buffer->pi_area_end[i_area] = i_h;
1457 if( i_h > i_area_end )
1459 /* Find further areas which can be merged with the new one */
1460 for( i_area_copy = i_area + 1;
1461 (i_area_copy < p_buffer->i_areas) &&
1462 (p_buffer->pi_area_begin[i_area] <= i_h);
1469 if( i_area_copy != i_area )
1471 /* Merge with last possible areas */
1472 //p_buffer->pi_area_end[i_area] = MAX( i_h, p_buffer->pi_area_end[i_area_copy] );
1474 /* Shift lower areas upward */
1475 i_area_shift = i_area_copy - i_area;
1476 p_buffer->i_areas -= i_area_shift;
1477 for( i_area_copy = i_area + 1; i_area_copy < p_buffer->i_areas; i_area_copy++ )
1479 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy + i_area_shift];
1480 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy + i_area_shift];
1485 /* Extend area below */
1486 p_buffer->pi_area_end[i_area] = i_h;
1492 /*****************************************************************************
1493 * SetBufferPicture: clear buffer and set picture area
1494 *****************************************************************************
1495 * This function is called before any rendering. It clears the current
1496 * rendering buffer and set the new picture area. If the picture pointer is
1497 * NULL, then no picture area is defined. Floating operations are avoided since
1498 * some MMX calculations may follow.
1499 *****************************************************************************/
1500 static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
1502 vout_buffer_t * p_buffer; /* current buffer */
1503 int i_pic_x, i_pic_y; /* picture position */
1504 int i_pic_width, i_pic_height; /* picture dimensions */
1505 int i_old_pic_y, i_old_pic_height; /* old picture area */
1506 int i_vout_width, i_vout_height; /* display dimensions */
1507 int i_area; /* area index */
1508 int i_data_index; /* area data index */
1509 int i_data_size; /* area data size, in 256 bytes blocs */
1510 u64 * p_data; /* area data, for clearing */
1511 byte_t * p_data8; /* area data, for clearing (slow) */
1513 /* Choose buffer and set display dimensions */
1514 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1515 i_vout_width = p_vout->i_width;
1516 i_vout_height = p_vout->i_height;
1519 * Computes new picture size
1523 /* Try horizontal scaling first - width must be a mutiple of 16 */
1524 i_pic_width = (( p_vout->b_scale || (p_pic->i_width > i_vout_width)) ?
1525 i_vout_width : p_pic->i_width) & ~0xf;
1526 switch( p_pic->i_aspect_ratio )
1528 case AR_3_4_PICTURE:
1529 i_pic_height = i_pic_width * 3 / 4;
1531 case AR_16_9_PICTURE:
1532 i_pic_height = i_pic_width * 9 / 16;
1534 case AR_221_1_PICTURE:
1535 i_pic_height = i_pic_width * 100 / 221;
1537 case AR_SQUARE_PICTURE:
1539 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1543 /* If picture dimensions using horizontal scaling are too large, use
1544 * vertical scaling. Since width must be a multiple of 16, height is
1545 * adjusted again after. */
1546 if( i_pic_height > i_vout_height )
1548 i_pic_height = ( p_vout->b_scale || (p_pic->i_height > i_vout_height)) ?
1549 i_vout_height : p_pic->i_height;
1550 switch( p_pic->i_aspect_ratio )
1552 case AR_3_4_PICTURE:
1553 i_pic_width = (i_pic_height * 4 / 3) & ~0xf;
1554 i_pic_height = i_pic_width * 3 / 4;
1556 case AR_16_9_PICTURE:
1557 i_pic_width = (i_pic_height * 16 / 9) & ~0xf;
1558 i_pic_height = i_pic_width * 9 / 16;
1560 case AR_221_1_PICTURE:
1561 i_pic_width = (i_pic_height * 221 / 100) & ~0xf;
1562 i_pic_height = i_pic_width * 100 / 221;
1564 case AR_SQUARE_PICTURE:
1566 i_pic_width = (p_pic->i_width * i_pic_height / p_pic->i_height) & ~0xf;
1567 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1572 /* Set picture position */
1573 i_pic_x = (p_vout->i_width - i_pic_width) / 2;
1574 i_pic_y = (p_vout->i_height - i_pic_height) / 2;
1579 /* No picture: size is 0 */
1587 * Set new picture size - if it is smaller than the previous one, clear
1588 * around it. Since picture are centered, only their size is tested.
1590 if( (p_buffer->i_pic_width > i_pic_width) || (p_buffer->i_pic_height > i_pic_height) )
1592 i_old_pic_y = p_buffer->i_pic_y;
1593 i_old_pic_height = p_buffer->i_pic_height;
1594 p_buffer->i_pic_x = i_pic_x;
1595 p_buffer->i_pic_y = i_pic_y;
1596 p_buffer->i_pic_width = i_pic_width;
1597 p_buffer->i_pic_height = i_pic_height;
1598 SetBufferArea( p_vout, 0, i_old_pic_y, p_vout->i_width, i_old_pic_height );
1602 p_buffer->i_pic_x = i_pic_x;
1603 p_buffer->i_pic_y = i_pic_y;
1604 p_buffer->i_pic_width = i_pic_width;
1605 p_buffer->i_pic_height = i_pic_height;
1611 for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
1614 intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d", p_pic,
1615 p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
1617 i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
1618 p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
1620 for( i_data_index = i_data_size / 256; i_data_index-- ; )
1622 /* Clear 256 bytes block */
1623 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1624 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1625 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1626 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1627 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1628 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1629 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1630 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1632 for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
1634 /* Clear remaining 16 bytes blocks */
1635 *p_data++ = 0; *p_data++ = 0;
1637 p_data8 = (byte_t *)p_data;
1638 for( i_data_index = i_data_size % 16; i_data_index--; )
1640 /* Clear remaining bytes */
1648 p_buffer->i_areas = 0;
1651 /*****************************************************************************
1652 * RenderPicture: render a picture
1653 *****************************************************************************
1654 * This function converts a picture from a video heap to a pixel-encoded image
1655 * and copies it to the current rendering buffer. No lock is required, since
1656 * the * rendered picture has been determined as existant, and will only be
1657 * destroyed by the vout thread later.
1658 *****************************************************************************/
1659 static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
1662 char psz_date[MSTRTIME_MAX_SIZE]; /* picture date */
1663 mtime_t render_time; /* picture rendering time */
1665 vout_buffer_t * p_buffer; /* rendering buffer */
1666 byte_t * p_pic_data; /* convertion destination */
1668 /* Get and set rendering information */
1669 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1670 p_pic_data = p_buffer->p_data +
1671 p_buffer->i_pic_x * p_vout->i_bytes_per_pixel +
1672 p_buffer->i_pic_y * p_vout->i_bytes_per_line;
1674 render_time = mdate();
1680 * Choose appropriate rendering function and render picture
1682 switch( p_pic->i_type )
1684 case YUV_420_PICTURE:
1685 p_vout->yuv.pf_yuv420( p_vout, p_pic_data,
1686 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1687 p_pic->i_width, p_pic->i_height,
1688 p_buffer->i_pic_width, p_buffer->i_pic_height,
1689 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1690 p_pic->i_matrix_coefficients );
1692 case YUV_422_PICTURE:
1693 p_vout->yuv.pf_yuv422( p_vout, p_pic_data,
1694 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1695 p_pic->i_width, p_pic->i_height,
1696 p_buffer->i_pic_width, p_buffer->i_pic_height,
1697 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1698 p_pic->i_matrix_coefficients );
1700 case YUV_444_PICTURE:
1701 p_vout->yuv.pf_yuv444( p_vout, p_pic_data,
1702 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1703 p_pic->i_width, p_pic->i_height,
1704 p_buffer->i_pic_width, p_buffer->i_pic_height,
1705 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1706 p_pic->i_matrix_coefficients );
1710 intf_ErrMsg("error: unknown picture type %d", p_pic->i_type );
1716 /* Print picture date and rendering time */
1717 intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s", p_pic,
1718 p_vout->i_buffer_index, (long) (mdate() - render_time),
1719 mstrtime( psz_date, p_pic->date ));
1723 /*****************************************************************************
1724 * RenderPictureInfo: print additionnal information on a picture
1725 *****************************************************************************
1726 * This function will print information such as fps and other picture
1727 * dependant information.
1728 *****************************************************************************/
1729 static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
1731 char psz_buffer[256]; /* string buffer */
1734 * Print FPS rate in upper right corner
1736 if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
1738 long i_fps = VOUT_FPS_SAMPLES * 1000000 * 10 /
1739 ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1)
1740 % VOUT_FPS_SAMPLES ] -
1741 p_vout->p_fps_sample[ p_vout->c_fps_samples
1742 % VOUT_FPS_SAMPLES ] );
1743 sprintf( psz_buffer, "%li.%i fps", i_fps / 10, (int)i_fps % 10 );
1744 Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
1748 * Print frames count and loop time in upper left corner
1750 sprintf( psz_buffer, "%ld frames, render: %ldus",
1751 (long) p_vout->c_fps_samples, (long) p_vout->render_time );
1752 Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
1756 * Print picture information in lower right corner
1758 sprintf( psz_buffer, "%s picture %dx%d (%dx%d%+d%+d %s) -> %dx%d+%d+%d",
1759 (p_pic->i_type == YUV_420_PICTURE) ? "4:2:0" :
1760 ((p_pic->i_type == YUV_422_PICTURE) ? "4:2:2" :
1761 ((p_pic->i_type == YUV_444_PICTURE) ? "4:4:4" : "ukn-type")),
1762 p_pic->i_width, p_pic->i_height,
1763 p_pic->i_display_width, p_pic->i_display_height,
1764 p_pic->i_display_horizontal_offset, p_pic->i_display_vertical_offset,
1765 (p_pic->i_aspect_ratio == AR_SQUARE_PICTURE) ? "sq" :
1766 ((p_pic->i_aspect_ratio == AR_3_4_PICTURE) ? "4:3" :
1767 ((p_pic->i_aspect_ratio == AR_16_9_PICTURE) ? "16:9" :
1768 ((p_pic->i_aspect_ratio == AR_221_1_PICTURE) ? "2.21:1" : "ukn-ar" ))),
1769 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_width,
1770 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height,
1771 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_x,
1772 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y );
1773 Print( p_vout, 0, 0, RIGHT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1777 /*****************************************************************************
1778 * RenderSplash: render splash picture
1779 *****************************************************************************
1780 * This function will print something on the screen. It will return 0 if
1781 * nothing has been rendered, or 1 if something has been changed on the screen.
1782 * Note that if you absolutely want something to be printed, you will have
1783 * to force it by setting the last idle date to 0.
1784 * Unlike other rendering functions, this one calls the SetBufferPicture
1785 * function when needed.
1786 *****************************************************************************/
1787 int RenderSplash( vout_thread_t *p_vout )
1789 int i_x = 0, i_y = 0; /* text position */
1790 int i_width, i_height; /* text size */
1791 char *psz_text = "VideoLAN Client (" VERSION ")"; /* text to display */
1793 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1794 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1796 // SetBufferPicture( p_vout, NULL );
1797 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1798 &i_width, &i_height );
1799 if( !Align( p_vout, &i_x, &i_y, i_width, i_height, CENTER_RALIGN, CENTER_RALIGN ) )
1801 vout_Print( p_vout->p_large_font,
1802 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1803 i_x * p_vout->i_bytes_per_pixel + (i_y - 16 ) * p_vout->i_bytes_per_line,
1804 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1805 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1806 WIDE_TEXT | OUTLINED_TEXT, psz_text, 100);
1807 SetBufferArea( p_vout, i_x, i_y, i_width, i_height);
1813 /*****************************************************************************
1814 * RenderIdle: render idle picture
1815 *****************************************************************************
1816 * This function will print something on the screen. It will return 0 if
1817 * nothing has been rendered, or 1 if something has been changed on the screen.
1818 * Note that if you absolutely want something to be printed, you will have
1819 * to force it by setting the last idle date to 0.
1820 * Unlike other rendering functions, this one calls the SetBufferPicture
1821 * function when needed.
1822 *****************************************************************************/
1823 int RenderIdle( vout_thread_t *p_vout )
1826 int i_x = 0, i_y = 0; /* text position */
1827 int i_width, i_height; /* text size */
1828 int i_amount = 0; /* amount to draw */
1829 char *psz_text = "Waiting for stream"; /* text to display */
1830 char *psz_wtext = "[................]";
1832 mtime_t current_date; /* current date */
1835 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1836 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1839 current_date = mdate();
1840 if( (current_date - p_vout->last_display_date) > VOUT_IDLE_DELAY
1841 // && (current_date - p_vout->last_idle_date) > VOUT_IDLE_DELAY
1844 /* FIXME: idle screen disabled */
1846 SetBufferPicture( p_vout, NULL );
1847 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1848 &i_width, &i_height );
1849 if( !Align( p_vout, &i_x, &i_y, i_width, i_height * 2, CENTER_RALIGN, CENTER_RALIGN ) )
1851 i_amount = (int) ((current_date - p_vout->last_display_date ) / 5000LL);
1852 vout_Print( p_vout->p_large_font,
1853 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1854 i_x * p_vout->i_bytes_per_pixel + i_y * p_vout->i_bytes_per_line,
1855 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1856 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1857 WIDE_TEXT | OUTLINED_TEXT, psz_text, (i_amount / 3 ) %110);
1859 vout_Print( p_vout->p_large_font,
1860 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1861 i_x * p_vout->i_bytes_per_pixel + (i_y + 16) * p_vout->i_bytes_per_line,
1862 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1863 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1864 WIDE_TEXT | OUTLINED_TEXT, psz_wtext, (i_amount/5)%110 );
1867 SetBufferArea( p_vout, i_x, i_y, i_width, i_height * 2 );
1875 /*****************************************************************************
1876 * RenderInfo: render additionnal information
1877 *****************************************************************************
1878 * This function renders information which do not depend on the current
1880 *****************************************************************************/
1881 static void RenderInfo( vout_thread_t *p_vout )
1884 char psz_buffer[256]; /* string buffer */
1885 int i_ready_pic = 0; /* ready pictures */
1886 int i_reserved_pic = 0; /* reserved pictures */
1887 int i_picture; /* picture index */
1892 * Print thread state in lower left corner
1894 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
1896 switch( p_vout->p_picture[i_picture].i_status )
1898 case RESERVED_PICTURE:
1899 case RESERVED_DATED_PICTURE:
1900 case RESERVED_DISP_PICTURE:
1908 sprintf( psz_buffer, "pic: %d (%d/%d)/%d",
1909 p_vout->i_pictures, i_reserved_pic, i_ready_pic, VOUT_MAX_PICTURES );
1910 Print( p_vout, 0, 0, LEFT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1914 /*****************************************************************************
1915 * RenderSubPicture: render a subpicture
1916 *****************************************************************************
1917 * This function renders a sub picture unit.
1918 *****************************************************************************/
1919 static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
1921 p_vout_font_t p_font; /* text font */
1922 int i_width, i_height; /* subpicture dimensions */
1924 while( p_subpic != NULL )
1926 switch( p_subpic->i_type )
1928 case DVD_SUBPICTURE: /* DVD subpicture unit */
1929 /* test if the picture really has to be displayed */
1930 if( mdate() < p_subpic->begin_date )
1932 /* not yet, see you later */
1935 if( mdate() > p_subpic->end_date )
1937 /* too late, destroying the subpic */
1938 vout_DestroySubPicture( p_vout, p_subpic );
1941 vout_RenderSPU( &p_vout->p_buffer[ p_vout->i_buffer_index ],
1942 p_subpic, p_vout->i_bytes_per_pixel,
1943 p_vout->i_bytes_per_line );
1945 case TEXT_SUBPICTURE: /* single line text */
1946 /* Select default font if not specified */
1947 p_font = p_subpic->type.text.p_font;
1948 if( p_font == NULL )
1950 p_font = p_vout->p_default_font;
1953 /* Compute text size (width and height fields are ignored)
1955 vout_TextSize( p_font, p_subpic->type.text.i_style,
1956 p_subpic->p_data, &i_width, &i_height );
1957 if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y,
1958 i_width, i_height, p_subpic->i_horizontal_align,
1959 p_subpic->i_vertical_align ) )
1962 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1963 p_subpic->i_x * p_vout->i_bytes_per_pixel +
1964 p_subpic->i_y * p_vout->i_bytes_per_line,
1965 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1966 p_subpic->type.text.i_char_color,
1967 p_subpic->type.text.i_border_color,
1968 p_subpic->type.text.i_bg_color,
1969 p_subpic->type.text.i_style, p_subpic->p_data, 100 );
1970 SetBufferArea( p_vout, p_subpic->i_x, p_subpic->i_y,
1971 i_width, i_height );
1977 intf_ErrMsg( "error: unknown subpicture %p type %d",
1978 p_subpic, p_subpic->i_type );
1982 p_subpic = p_subpic->p_next;
1986 /*****************************************************************************
1987 * RenderInterface: render the interface
1988 *****************************************************************************
1989 * This function renders the interface, if any.
1990 *****************************************************************************/
1991 static void RenderInterface( vout_thread_t *p_vout )
1993 int i_height, i_text_height; /* total and text height */
1994 int i_width_1, i_width_2; /* text width */
1995 int i_byte; /* byte index */
1996 const char *psz_text_1 = "[1-9] Channel [i]nfo [c]olor [g/G]amma";
1997 const char *psz_text_2 = "[+/-] Volume [m]ute [s]caling [Q]uit";
2000 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_1, &i_width_1, &i_height );
2001 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_2, &i_width_2, &i_text_height );
2002 i_height += i_text_height;
2004 /* Render background */
2005 for( i_byte = (p_vout->i_height - i_height) * p_vout->i_bytes_per_line;
2006 i_byte < p_vout->i_height * p_vout->i_bytes_per_line;
2010 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = p_vout->i_blue_pixel;
2013 /* Render text, if not larger than screen */
2014 if( i_width_1 < p_vout->i_width )
2016 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2017 (p_vout->i_height - i_height) * p_vout->i_bytes_per_line,
2018 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2019 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2020 OUTLINED_TEXT, psz_text_1, 100 );
2022 if( i_width_2 < p_vout->i_width )
2024 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2025 (p_vout->i_height - i_height + i_text_height) * p_vout->i_bytes_per_line,
2026 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2027 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2028 OUTLINED_TEXT, psz_text_2, 100 );
2031 /* Activate modified area */
2032 SetBufferArea( p_vout, 0, p_vout->i_height - i_height, p_vout->i_width, i_height );
2035 /*****************************************************************************
2036 * Manage: manage thread
2037 *****************************************************************************
2038 * This function will handle changes in thread configuration.
2039 *****************************************************************************/
2040 static int Manage( vout_thread_t *p_vout )
2043 if( p_vout->i_changes )
2045 intf_DbgMsg("changes: 0x%x (no display: 0x%x)", p_vout->i_changes,
2046 0 /* p_vout->i_changes & VOUT_NODISPLAY_CHANGE */ );
2050 /* On gamma or grayscale change, rebuild tables */
2051 if( p_vout->i_changes & (VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2054 if( vout_ResetYUV( p_vout ) )
2056 intf_ErrMsg( "vout error: can't rebuild conversion tables" );
2061 /* Clear changes flags which does not need management or have been
2063 p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2064 VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
2065 VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE |
2066 VOUT_CURSOR_CHANGE | VOUT_FULLSCREEN_CHANGE );
2068 /* Detect unauthorized changes */
2069 if( p_vout->i_changes )
2071 /* Some changes were not acknowledged by p_vout->pf_manage or this
2072 * function, it means they should not be authorized */
2073 intf_ErrMsg( "vout error: unauthorized changes in the vout thread" );
2080 /*****************************************************************************
2081 * Align: align a subpicture in the screen
2082 *****************************************************************************
2083 * This function is used for rendering text or subpictures. It returns non 0
2084 * it the final aera is not fully included in display area. Return coordinates
2086 *****************************************************************************/
2087 static int Align( vout_thread_t *p_vout, int *pi_x, int *pi_y,
2088 int i_width, int i_height, int i_h_align, int i_v_align )
2090 /* Align horizontally */
2094 *pi_x -= i_width / 2;
2097 *pi_x += (p_vout->i_width - i_width) / 2;
2103 *pi_x += p_vout->i_width - i_width;
2107 /* Align vertically */
2111 *pi_y -= i_height / 2;
2114 *pi_y += (p_vout->i_height - i_height) / 2;
2120 *pi_y += p_vout->i_height - i_height;
2122 case SUBTITLE_RALIGN:
2123 *pi_y += (p_vout->i_height + p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y +
2124 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height - i_height) / 2;
2128 /* Return non 0 if clipping failed */
2129 return( (*pi_x < 0) || (*pi_y < 0) ||
2130 (*pi_x + i_width > p_vout->i_width) || (*pi_y + i_height > p_vout->i_height) );
2133 /*****************************************************************************
2134 * SetPalette: sets an 8 bpp palette
2135 *****************************************************************************
2136 * This function is just a prototype that does nothing. Architectures that
2137 * support palette allocation should override it.
2138 *****************************************************************************/
2139 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
2140 u16 *green, u16 *blue, u16 *transp )
2142 intf_ErrMsg( "vout error: method does not support palette changing" );