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.122 2001/05/01 04:18:18 sam 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( MODULE_CAPABILITY_VOUT, NULL );
114 if( p_vout->p_module == NULL )
116 intf_ErrMsg( "vout error: no suitable vout module" );
121 #define f p_vout->p_module->p_functions->vout.functions.vout
122 p_vout->pf_create = f.pf_create;
123 p_vout->pf_init = f.pf_init;
124 p_vout->pf_end = f.pf_end;
125 p_vout->pf_destroy = f.pf_destroy;
126 p_vout->pf_manage = f.pf_manage;
127 p_vout->pf_display = f.pf_display;
128 p_vout->pf_setpalette = f.pf_setpalette;
131 if( p_vout->pf_setpalette == NULL )
133 p_vout->pf_setpalette = SetPalette;
136 /* Initialize thread properties - thread id and locks will be initialized
140 p_vout->b_active = 0;
141 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
142 *p_vout->pi_status = THREAD_CREATE;
144 /* Initialize some fields used by the system-dependant method - these
145 * fields will probably be modified by the method, and are only
147 p_vout->i_changes = 0;
148 p_vout->i_width = main_GetIntVariable( VOUT_WIDTH_VAR,
149 VOUT_WIDTH_DEFAULT );
150 p_vout->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR,
151 VOUT_HEIGHT_DEFAULT );
152 p_vout->i_bytes_per_line = p_vout->i_width * 2;
153 p_vout->i_screen_depth = 15;
154 p_vout->i_bytes_per_pixel = 2;
155 p_vout->f_gamma = VOUT_GAMMA;
156 p_vout->b_need_render = 1;
159 p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
160 VOUT_GRAYSCALE_DEFAULT );
162 p_vout->b_interface = 0;
165 intf_WarnMsg( 1, "wished configuration: %dx%d, %d/%d bpp (%d Bpl)",
166 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
167 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
169 /* Initialize idle screen */
170 p_vout->last_display_date = 0;
171 p_vout->last_idle_date = 0;
172 p_vout->init_display_date = mdate();
173 p_vout->render_time = 10000;
175 /* Initialize statistics fields */
176 p_vout->c_fps_samples = 0;
178 /* Initialize buffer index */
179 p_vout->i_buffer_index = 0;
181 /* Initialize pictures and subpictures - translation tables and functions
182 * will be initialized later in InitThread */
183 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
185 p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
186 p_vout->p_picture[i_index].i_status = FREE_PICTURE;
188 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
190 p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
191 p_vout->p_subpicture[i_index].i_status= FREE_SUBPICTURE;
193 p_vout->i_pictures = 0;
195 /* Create and initialize system-dependant method - this function issues its
196 * own error messages */
197 if( p_vout->pf_create( p_vout ) )
199 module_Unneed( p_vout->p_module );
203 intf_WarnMsg( 1, "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
204 "masks: 0x%x/0x%x/0x%x",
205 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
206 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
207 p_vout->i_red_mask, p_vout->i_green_mask,
208 p_vout->i_blue_mask );
210 /* Calculate shifts from system-updated masks */
211 MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
212 p_vout->i_red_mask );
213 MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
214 p_vout->i_green_mask );
215 MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
216 p_vout->i_blue_mask );
218 /* Set some useful colors */
219 p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
220 p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
221 p_vout->i_gray_pixel = RGB2PIXEL( p_vout, 128, 128, 128 );
222 p_vout->i_blue_pixel = RGB2PIXEL( p_vout, 0, 0, 50 );
224 /* Load fonts - fonts must be initialized after the system method since
225 * they may be dependant on screen depth and other thread properties */
226 p_vout->p_default_font = vout_LoadFont( VOUT_DEFAULT_FONT );
227 if( p_vout->p_default_font == NULL )
229 intf_ErrMsg( "vout error: could not load default font" );
232 p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
233 if( p_vout->p_large_font == NULL )
235 intf_ErrMsg( "vout error: could not load large font" );
238 /* Create thread and set locks */
239 vlc_mutex_init( &p_vout->picture_lock );
240 vlc_mutex_init( &p_vout->subpicture_lock );
241 vlc_mutex_init( &p_vout->change_lock );
243 if( vlc_thread_create( &p_vout->thread_id, "video output",
244 (void *) RunThread, (void *) p_vout) )
246 intf_ErrMsg("vout error: %s", strerror(ENOMEM));
247 vout_UnloadFont( p_vout->p_default_font );
248 vout_UnloadFont( p_vout->p_large_font );
249 p_vout->pf_destroy( p_vout );
254 intf_Msg( "vout: video display initialized (%dx%d, %d/%d bpp)",
255 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
256 p_vout->i_bytes_per_pixel * 8 );
258 /* If status is NULL, wait until the thread is created */
259 if( pi_status == NULL )
263 msleep( THREAD_SLEEP );
264 }while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
265 && (i_status != THREAD_FATAL) );
266 if( i_status != THREAD_READY )
274 /*****************************************************************************
275 * vout_DestroyThread: destroys a previously created thread
276 *****************************************************************************
277 * Destroy a terminated thread.
278 * The function will request a destruction of the specified thread. If pi_error
279 * is NULL, it will return once the thread is destroyed. Else, it will be
280 * update using one of the THREAD_* constants.
281 *****************************************************************************/
282 void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
284 int i_status; /* thread status */
288 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
289 *p_vout->pi_status = THREAD_DESTROY;
291 /* Request thread destruction */
294 /* If status is NULL, wait until thread has been destroyed */
295 if( pi_status == NULL )
299 msleep( THREAD_SLEEP );
300 }while( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
301 && (i_status != THREAD_FATAL) );
305 /*****************************************************************************
306 * vout_DisplaySubPicture: display a subpicture unit
307 *****************************************************************************
308 * Remove the reservation flag of an subpicture, which will cause it to be ready
309 * for display. The picture does not need to be locked, since it is ignored by
310 * the output thread if is reserved.
311 *****************************************************************************/
312 void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
315 char psz_begin_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
316 char psz_end_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
320 /* Check if status is valid */
321 if( p_subpic->i_status != RESERVED_SUBPICTURE )
323 intf_ErrMsg("error: subpicture %p has invalid status %d", p_subpic,
324 p_subpic->i_status );
328 /* Remove reservation flag */
329 p_subpic->i_status = READY_SUBPICTURE;
332 /* Send subpicture information */
333 intf_DbgMsg("subpicture %p: type=%d, begin date=%s, end date=%s",
334 p_subpic, p_subpic->i_type,
335 mstrtime( psz_begin_date, p_subpic->begin_date ),
336 mstrtime( psz_end_date, p_subpic->end_date ) );
340 /*****************************************************************************
341 * vout_CreateSubPicture: allocate a subpicture in the video output heap.
342 *****************************************************************************
343 * This function create a reserved subpicture in the video output heap.
344 * A null pointer is returned if the function fails. This method provides an
345 * already allocated zone of memory in the spu data fields. It needs locking
346 * since several pictures can be created by several producers threads.
347 *****************************************************************************/
348 subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
351 int i_subpic; /* subpicture index */
352 subpicture_t * p_free_subpic = NULL; /* first free subpicture */
353 subpicture_t * p_destroyed_subpic = NULL; /* first destroyed subpic */
356 vlc_mutex_lock( &p_vout->subpicture_lock );
359 * Look for an empty place
361 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
363 if( p_vout->p_subpicture[i_subpic].i_status == DESTROYED_SUBPICTURE )
365 /* Subpicture is marked for destruction, but is still allocated */
366 if( (p_vout->p_subpicture[i_subpic].i_type == i_type) &&
367 (p_vout->p_subpicture[i_subpic].i_size >= i_size) )
369 /* Memory size do match or is smaller : memory will not be
370 * reallocated, and function can end immediately - this is
371 * the best possible case, since no memory allocation needs
373 p_vout->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
375 intf_DbgMsg("subpicture %p (in destroyed subpicture slot)",
376 &p_vout->p_subpicture[i_subpic] );
378 vlc_mutex_unlock( &p_vout->subpicture_lock );
379 return( &p_vout->p_subpicture[i_subpic] );
381 else if( p_destroyed_subpic == NULL )
383 /* Memory size do not match, but subpicture index will be kept in
384 * case no other place are left */
385 p_destroyed_subpic = &p_vout->p_subpicture[i_subpic];
388 else if( (p_free_subpic == NULL) &&
389 (p_vout->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE ))
391 /* Subpicture is empty and ready for allocation */
392 p_free_subpic = &p_vout->p_subpicture[i_subpic];
396 /* If no free subpictures are available, use a destroyed subpicture */
397 if( (p_free_subpic == NULL) && (p_destroyed_subpic != NULL ) )
399 /* No free subpicture or matching destroyed subpictures have been
400 * found, but a destroyed subpicture is still avalaible */
401 free( p_destroyed_subpic->p_data );
402 p_free_subpic = p_destroyed_subpic;
408 if( p_free_subpic != NULL )
410 /* Allocate memory */
413 case TEXT_SUBPICTURE: /* text subpicture */
414 p_free_subpic->p_data = malloc( i_size + 1 );
416 case DVD_SUBPICTURE: /* DVD subpicture unit */
417 p_free_subpic->p_data = malloc( i_size );
421 intf_ErrMsg("error: unknown subpicture type %d", i_type );
422 p_free_subpic->p_data = NULL;
427 if( p_free_subpic->p_data != NULL )
429 /* Copy subpicture information, set some default values */
430 p_free_subpic->i_type = i_type;
431 p_free_subpic->i_status = RESERVED_SUBPICTURE;
432 p_free_subpic->i_size = i_size;
433 p_free_subpic->i_x = 0;
434 p_free_subpic->i_y = 0;
435 p_free_subpic->i_width = 0;
436 p_free_subpic->i_height = 0;
437 p_free_subpic->i_horizontal_align = CENTER_RALIGN;
438 p_free_subpic->i_vertical_align = CENTER_RALIGN;
442 /* Memory allocation failed : set subpicture as empty */
443 p_free_subpic->i_type = EMPTY_SUBPICTURE;
444 p_free_subpic->i_status = FREE_SUBPICTURE;
445 p_free_subpic = NULL;
446 intf_ErrMsg( "vout error: spu allocation returned %s",
447 strerror( ENOMEM ) );
451 intf_DbgMsg("subpicture %p (in free subpicture slot)", p_free_subpic );
453 vlc_mutex_unlock( &p_vout->subpicture_lock );
454 return( p_free_subpic );
457 /* No free or destroyed subpicture could be found */
458 intf_DbgMsg( "warning: subpicture heap is full" );
459 vlc_mutex_unlock( &p_vout->subpicture_lock );
463 /*****************************************************************************
464 * vout_DestroySubPicture: remove a subpicture from the heap
465 *****************************************************************************
466 * This function frees a previously reserved subpicture.
467 * It is meant to be used when the construction of a picture aborted.
468 * This function does not need locking since reserved subpictures are ignored
469 * by the output thread.
470 *****************************************************************************/
471 void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
474 /* Check if status is valid */
475 if( p_subpic->i_status != RESERVED_SUBPICTURE )
477 intf_ErrMsg("error: subpicture %p has invalid status %d",
478 p_subpic, p_subpic->i_status );
482 p_subpic->i_status = DESTROYED_SUBPICTURE;
485 intf_DbgMsg("subpicture %p", p_subpic);
489 /*****************************************************************************
490 * vout_DisplayPicture: display a picture
491 *****************************************************************************
492 * Remove the reservation flag of a picture, which will cause it to be ready for
493 * display. The picture won't be displayed until vout_DatePicture has been
495 *****************************************************************************/
496 void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
498 vlc_mutex_lock( &p_vout->picture_lock );
499 switch( p_pic->i_status )
501 case RESERVED_PICTURE:
502 p_pic->i_status = RESERVED_DISP_PICTURE;
504 case RESERVED_DATED_PICTURE:
505 p_pic->i_status = READY_PICTURE;
509 intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
515 intf_DbgMsg("picture %p", p_pic);
517 vlc_mutex_unlock( &p_vout->picture_lock );
520 /*****************************************************************************
521 * vout_DatePicture: date a picture
522 *****************************************************************************
523 * Remove the reservation flag of a picture, which will cause it to be ready for
524 * display. The picture won't be displayed until vout_DisplayPicture has been
526 *****************************************************************************/
527 void vout_DatePicture( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date )
530 char psz_date[MSTRTIME_MAX_SIZE]; /* date */
533 vlc_mutex_lock( &p_vout->picture_lock );
535 switch( p_pic->i_status )
537 case RESERVED_PICTURE:
538 p_pic->i_status = RESERVED_DATED_PICTURE;
540 case RESERVED_DISP_PICTURE:
541 p_pic->i_status = READY_PICTURE;
545 intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
551 intf_DbgMsg("picture %p, display date: %s", p_pic, mstrtime( psz_date, p_pic->date) );
553 vlc_mutex_unlock( &p_vout->picture_lock );
556 /*****************************************************************************
557 * vout_CreatePicture: allocate a picture in the video output heap.
558 *****************************************************************************
559 * This function create a reserved image in the video output heap.
560 * A null pointer is returned if the function fails. This method provides an
561 * already allocated zone of memory in the picture data fields. It needs locking
562 * since several pictures can be created by several producers threads.
563 *****************************************************************************/
564 picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
565 int i_width, int i_height )
567 int i_picture; /* picture index */
568 int i_chroma_width = 0; /* chroma width */
569 picture_t * p_free_picture = NULL; /* first free picture */
570 picture_t * p_destroyed_picture = NULL; /* first destroyed picture */
573 vlc_mutex_lock( &p_vout->picture_lock );
576 * Look for an empty place
578 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
580 if( p_vout->p_picture[i_picture].i_status == DESTROYED_PICTURE )
582 /* Picture is marked for destruction, but is still allocated - note
583 * that if width and type are the same for two pictures, chroma_width
584 * should also be the same */
585 if( (p_vout->p_picture[i_picture].i_type == i_type) &&
586 (p_vout->p_picture[i_picture].i_height == i_height) &&
587 (p_vout->p_picture[i_picture].i_width == i_width) )
589 /* Memory size do match : memory will not be reallocated, and function
590 * can end immediately - this is the best possible case, since no
591 * memory allocation needs to be done */
592 p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
593 p_vout->i_pictures++;
595 intf_DbgMsg("picture %p (in destroyed picture slot)",
596 &p_vout->p_picture[i_picture] );
598 vlc_mutex_unlock( &p_vout->picture_lock );
599 return( &p_vout->p_picture[i_picture] );
601 else if( p_destroyed_picture == NULL )
603 /* Memory size do not match, but picture index will be kept in
604 * case no other place are left */
605 p_destroyed_picture = &p_vout->p_picture[i_picture];
608 else if( (p_free_picture == NULL) &&
609 (p_vout->p_picture[i_picture].i_status == FREE_PICTURE ))
611 /* Picture is empty and ready for allocation */
612 p_free_picture = &p_vout->p_picture[i_picture];
616 /* If no free picture is available, use a destroyed picture */
617 if( (p_free_picture == NULL) && (p_destroyed_picture != NULL ) )
619 /* No free picture or matching destroyed picture has been found, but
620 * a destroyed picture is still avalaible */
621 free( p_destroyed_picture->p_data );
622 p_free_picture = p_destroyed_picture;
628 if( p_free_picture != NULL )
630 /* Allocate memory */
633 case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
634 i_chroma_width = i_width / 2;
635 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
636 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
637 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*4/2;
638 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*5/2;
640 case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
641 i_chroma_width = i_width / 2;
642 p_free_picture->p_data = malloc( i_height * i_chroma_width * 4 * sizeof( yuv_data_t ) );
643 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
644 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
645 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*3;
647 case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
648 i_chroma_width = i_width;
649 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
650 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
651 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width;
652 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
656 intf_ErrMsg("error: unknown picture type %d", i_type );
657 p_free_picture->p_data = NULL;
662 if( p_free_picture->p_data != NULL )
664 /* Copy picture information, set some default values */
665 p_free_picture->i_type = i_type;
666 p_free_picture->i_status = RESERVED_PICTURE;
667 p_free_picture->i_matrix_coefficients = 1;
668 p_free_picture->i_width = i_width;
669 p_free_picture->i_height = i_height;
670 p_free_picture->i_chroma_width = i_chroma_width;
671 p_free_picture->i_size = i_width * i_height;
672 p_free_picture->i_chroma_size = i_chroma_width
674 p_free_picture->i_display_horizontal_offset = 0;
675 p_free_picture->i_display_vertical_offset = 0;
676 p_free_picture->i_display_width = i_width;
677 p_free_picture->i_display_height = i_height;
678 p_free_picture->i_aspect_ratio = AR_SQUARE_PICTURE;
679 p_free_picture->i_refcount = 0;
680 p_vout->i_pictures++;
684 /* Memory allocation failed : set picture as empty */
685 p_free_picture->i_type = EMPTY_PICTURE;
686 p_free_picture->i_status = FREE_PICTURE;
687 p_free_picture = NULL;
688 intf_ErrMsg( "vout error: picture allocation returned %s",
689 strerror( ENOMEM ) );
693 intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
695 vlc_mutex_unlock( &p_vout->picture_lock );
697 /* Initialize mutex */
698 vlc_mutex_init( &(p_free_picture->lock_deccount) );
700 return( p_free_picture );
703 /* No free or destroyed picture could be found */
704 intf_DbgMsg( "warning: picture heap is full" );
705 vlc_mutex_unlock( &p_vout->picture_lock );
709 /*****************************************************************************
710 * vout_DestroyPicture: remove a permanent or reserved picture from the heap
711 *****************************************************************************
712 * This function frees a previously reserved picture or a permanent
713 * picture. It is meant to be used when the construction of a picture aborted.
714 * Note that the picture will be destroyed even if it is linked !
715 *****************************************************************************/
716 void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
718 vlc_mutex_lock( &p_vout->picture_lock );
721 /* Check if picture status is valid */
722 if( (p_pic->i_status != RESERVED_PICTURE) &&
723 (p_pic->i_status != RESERVED_DATED_PICTURE) &&
724 (p_pic->i_status != RESERVED_DISP_PICTURE) )
726 intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
730 p_pic->i_status = DESTROYED_PICTURE;
731 p_vout->i_pictures--;
734 intf_DbgMsg("picture %p", p_pic);
737 /* destroy the lock that had been initialized in CreatePicture */
738 vlc_mutex_destroy( &(p_pic->lock_deccount) );
740 vlc_mutex_unlock( &p_vout->picture_lock );
743 /*****************************************************************************
744 * vout_LinkPicture: increment reference counter of a picture
745 *****************************************************************************
746 * This function increment the reference counter of a picture in the video
747 * heap. It needs a lock since several producer threads can access the picture.
748 *****************************************************************************/
749 void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
751 vlc_mutex_lock( &p_vout->picture_lock );
755 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
758 vlc_mutex_unlock( &p_vout->picture_lock );
761 /*****************************************************************************
762 * vout_UnlinkPicture: decrement reference counter of a picture
763 *****************************************************************************
764 * This function decrement the reference counter of a picture in the video heap.
765 *****************************************************************************/
766 void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
768 vlc_mutex_lock( &p_vout->picture_lock );
772 if( p_pic->i_refcount < 0 )
774 intf_DbgMsg("error: refcount < 0");
775 p_pic->i_refcount = 0;
779 if( (p_pic->i_refcount == 0) && (p_pic->i_status == DISPLAYED_PICTURE) )
781 p_pic->i_status = DESTROYED_PICTURE;
782 p_vout->i_pictures--;
786 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
789 vlc_mutex_unlock( &p_vout->picture_lock );
792 /*****************************************************************************
793 * vout_SetBuffers: set buffers adresses
794 *****************************************************************************
795 * This function is called by system drivers to set buffers video memory
797 *****************************************************************************/
798 void vout_SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
800 /* No picture previously */
801 p_vout->p_buffer[0].i_pic_x = 0;
802 p_vout->p_buffer[0].i_pic_y = 0;
803 p_vout->p_buffer[0].i_pic_width = 0;
804 p_vout->p_buffer[0].i_pic_height = 0;
805 p_vout->p_buffer[1].i_pic_x = 0;
806 p_vout->p_buffer[1].i_pic_y = 0;
807 p_vout->p_buffer[1].i_pic_width = 0;
808 p_vout->p_buffer[1].i_pic_height = 0;
810 /* The first area covers all the screen */
811 p_vout->p_buffer[0].i_areas = 1;
812 p_vout->p_buffer[0].pi_area_begin[0] = 0;
813 p_vout->p_buffer[0].pi_area_end[0] = p_vout->i_height - 1;
814 p_vout->p_buffer[1].i_areas = 1;
815 p_vout->p_buffer[1].pi_area_begin[0] = 0;
816 p_vout->p_buffer[1].pi_area_end[0] = p_vout->i_height - 1;
819 p_vout->p_buffer[0].p_data = p_buf1;
820 p_vout->p_buffer[1].p_data = p_buf2;
823 /*****************************************************************************
824 * vout_Pixel2RGB: return red, green and blue from pixel value
825 *****************************************************************************
826 * Return color values, in 0-255 range, of the decomposition of a pixel. This
827 * is a slow routine and should only be used for initialization phase.
828 *****************************************************************************/
829 void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
831 *pi_red = i_pixel & p_vout->i_red_mask;
832 *pi_green = i_pixel & p_vout->i_green_mask;
833 *pi_blue = i_pixel & p_vout->i_blue_mask;
836 /* following functions are local */
838 /*****************************************************************************
839 * BinaryLog: computes the base 2 log of a binary value
840 *****************************************************************************
841 * This functions is used by MaskToShift, to get a bit index from a binary
843 *****************************************************************************/
844 static int BinaryLog(u32 i)
869 if (i != ((u32)1 << i_log))
871 intf_DbgMsg("internal error: binary log overflow");
877 /*****************************************************************************
878 * MaskToShift: transform a color mask into right and left shifts
879 *****************************************************************************
880 * This function is used for obtaining color shifts from masks.
881 *****************************************************************************/
882 static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
884 u32 i_low, i_high; /* lower hand higher bits of the mask */
887 i_low = i_mask & (- i_mask); /* lower bit of the mask */
888 i_high = i_mask + i_low; /* higher bit of the mask */
890 /* Transform bits into an index */
891 i_low = BinaryLog (i_low);
892 i_high = BinaryLog (i_high);
894 /* Update pointers and return */
896 *pi_right = (8 - i_high + i_low);
899 /*****************************************************************************
900 * InitThread: initialize video output thread
901 *****************************************************************************
902 * This function is called from RunThread and performs the second step of the
903 * initialization. It returns 0 on success. Note that the thread's flag are not
904 * modified inside this function.
905 *****************************************************************************/
906 static int InitThread( vout_thread_t *p_vout )
909 *p_vout->pi_status = THREAD_START;
911 vlc_mutex_lock( &p_vout->change_lock );
917 /* Initialize output method - this function issues its own error messages */
918 if( p_vout->pf_init( p_vout ) )
923 /* Initialize convertion tables and functions */
924 if( vout_InitYUV( p_vout ) )
926 intf_ErrMsg("vout error: can't allocate YUV translation tables");
930 /* Mark thread as running and return */
931 p_vout->b_active = 1;
932 *p_vout->pi_status = THREAD_READY;
935 intf_DbgMsg("thread ready");
939 /*****************************************************************************
940 * RunThread: video output thread
941 *****************************************************************************
942 * Video output thread. This function does only returns when the thread is
943 * terminated. It handles the pictures arriving in the video heap and the
944 * display device events.
945 *****************************************************************************/
946 static void RunThread( vout_thread_t *p_vout)
948 int i_index; /* index in heap */
949 mtime_t current_date; /* current date */
950 mtime_t display_date; /* display date */
951 boolean_t b_display; /* display flag */
952 picture_t * p_pic; /* picture pointer */
953 subpicture_t * p_subpic; /* subpicture pointer */
958 p_vout->b_error = InitThread( p_vout );
959 if( p_vout->b_error )
961 DestroyThread( p_vout, THREAD_ERROR );
966 * Main loop - it is not executed if an error occured during
969 while( (!p_vout->b_die) && (!p_vout->b_error) )
971 /* Initialize loop variables */
975 current_date = mdate();
978 if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
980 intf_Msg("vout stats: picture heap: %d/%d",
981 p_vout->i_pictures, VOUT_MAX_PICTURES);
986 * Find the picture to display - this operation does not need lock,
987 * since only READY_PICTUREs are handled
989 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
991 if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) &&
993 (p_vout->p_picture[i_index].date < display_date) ) )
995 p_pic = &p_vout->p_picture[i_index];
996 display_date = p_pic->date;
1002 /* Computes FPS rate */
1003 p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ] = display_date;
1005 if( display_date < current_date - p_vout->render_time )
1007 /* Picture is late: it will be destroyed and the thread
1008 * will sleep and go to next picture */
1010 vlc_mutex_lock( &p_vout->picture_lock );
1011 if( p_pic->i_refcount )
1013 p_pic->i_status = DISPLAYED_PICTURE;
1017 p_pic->i_status = DESTROYED_PICTURE;
1018 p_vout->i_pictures--;
1021 "warning: late picture skipped (%p)", p_pic );
1022 vlc_mutex_unlock( &p_vout->picture_lock );
1026 else if( display_date > current_date + VOUT_DISPLAY_DELAY )
1028 /* A picture is ready to be rendered, but its rendering date
1029 * is far from the current one so the thread will perform an
1030 * empty loop as if no picture were found. The picture state
1037 * Find the subpictures to display - this operation does not need
1038 * lock, since only READY_SUBPICTURE are handled. If no picture
1039 * has been selected, display_date will depend on the subpicture.
1040 * We get an easily parsable chained list of subpictures which
1041 * ends with NULL since p_subpic was initialized to NULL.
1043 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1045 if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
1047 p_vout->p_subpicture[i_index].p_next = p_subpic;
1048 p_subpic = &p_vout->p_subpicture[i_index];
1053 * Perform rendering, sleep and display rendered picture
1055 if( p_pic ) /* picture and perhaps subpicture */
1057 b_display = p_vout->b_active;
1058 p_vout->last_display_date = display_date;
1059 p_vout->p_rendered_pic = p_pic;
1064 /* Set picture dimensions and clear buffer */
1065 SetBufferPicture( p_vout, p_pic );
1067 /* FIXME: if b_need_render == 0 we need to do something with
1068 * the subpictures one day. */
1070 if( p_vout->b_need_render && b_display )
1072 /* Render picture and information */
1073 RenderPicture( p_vout, p_pic );
1074 if( p_vout->b_info )
1076 RenderPictureInfo( p_vout, p_pic );
1077 RenderInfo( p_vout );
1081 RenderSubPicture( p_vout, p_subpic );
1085 /* Render interface and subpicture */
1086 if( b_display && p_vout->b_interface && p_vout->b_need_render )
1088 RenderInterface( p_vout );
1092 else if( p_vout->b_active && p_vout->b_need_render
1093 && p_vout->init_display_date == 0)
1095 /* Idle or interface screen alone */
1097 if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
1099 /* Interface has changed, so a new rendering is required - force
1100 * it by setting last idle date to 0 */
1101 p_vout->last_idle_date = 0;
1104 /* Render idle screen and update idle date, then render interface if
1106 b_display = RenderIdle( p_vout );
1109 p_vout->last_idle_date = current_date;
1110 if( p_vout->b_interface )
1112 RenderInterface( p_vout );
1124 * Check for the current time and
1125 * display splash screen if everything is on time
1127 if( p_vout->init_display_date > 0 && p_vout->b_need_render )
1129 if( p_vout->b_active &&
1130 mdate()-p_vout->init_display_date < 5000000)
1132 /* there is something to display ! */
1134 RenderSplash( p_vout );
1137 /* no splash screen ! */
1138 p_vout->init_display_date=0;
1144 * Sleep, wake up and display rendered picture
1147 if( display_date != 0 )
1149 /* Store render time using Bresenham algorithm */
1150 p_vout->render_time += mdate() - current_date;
1151 p_vout->render_time >>= 1;
1154 /* Give back change lock */
1155 vlc_mutex_unlock( &p_vout->change_lock );
1157 /* Sleep a while or until a given date */
1158 if( display_date != 0 )
1160 mwait( display_date - VOUT_MWAIT_TOLERANCE );
1164 msleep( VOUT_IDLE_SLEEP );
1167 /* On awakening, take back lock and send immediately picture to display,
1168 * then swap buffers */
1169 vlc_mutex_lock( &p_vout->change_lock );
1171 intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d", p_pic, p_subpic,
1172 p_vout->i_buffer_index, b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ );
1174 if( b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ )
1176 p_vout->pf_display( p_vout );
1178 p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;
1184 /* Remove picture from heap */
1185 vlc_mutex_lock( &p_vout->picture_lock );
1186 if( p_pic->i_refcount )
1188 p_pic->i_status = DISPLAYED_PICTURE;
1192 p_pic->i_status = DESTROYED_PICTURE;
1193 p_vout->i_pictures--;
1195 vlc_mutex_unlock( &p_vout->picture_lock );
1200 * Check events and manage thread
1202 if( p_vout->pf_manage( p_vout ) | Manage( p_vout ) )
1204 /* A fatal error occured, and the thread must terminate immediately,
1205 * without displaying anything - setting b_error to 1 cause the
1206 * immediate end of the main while() loop. */
1207 p_vout->b_error = 1;
1212 * Error loop - wait until the thread destruction is requested
1214 if( p_vout->b_error )
1216 ErrorThread( p_vout );
1220 EndThread( p_vout );
1221 DestroyThread( p_vout, THREAD_OVER );
1222 intf_DbgMsg( "thread end" );
1225 /*****************************************************************************
1226 * ErrorThread: RunThread() error loop
1227 *****************************************************************************
1228 * This function is called when an error occured during thread main's loop. The
1229 * thread can still receive feed, but must be ready to terminate as soon as
1231 *****************************************************************************/
1232 static void ErrorThread( vout_thread_t *p_vout )
1234 /* Wait until a `die' order */
1235 while( !p_vout->b_die )
1238 msleep( VOUT_IDLE_SLEEP );
1242 /*****************************************************************************
1243 * EndThread: thread destruction
1244 *****************************************************************************
1245 * This function is called when the thread ends after a sucessful
1246 * initialization. It frees all ressources allocated by InitThread.
1247 *****************************************************************************/
1248 static void EndThread( vout_thread_t *p_vout )
1250 int i_index; /* index in heap */
1253 *p_vout->pi_status = THREAD_END;
1257 struct tms cpu_usage;
1258 times( &cpu_usage );
1260 intf_Msg( "vout stats: cpu usage (user: %d, system: %d)",
1261 cpu_usage.tms_utime, cpu_usage.tms_stime );
1265 /* Destroy all remaining pictures and subpictures */
1266 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
1268 if( p_vout->p_picture[i_index].i_status != FREE_PICTURE )
1270 free( p_vout->p_picture[i_index].p_data );
1274 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1276 if( p_vout->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
1278 free( p_vout->p_subpicture[i_index].p_data );
1282 /* Destroy translation tables */
1283 vout_EndYUV( p_vout );
1284 p_vout->pf_end( p_vout );
1286 /* Release the change lock */
1287 vlc_mutex_unlock( &p_vout->change_lock );
1290 /*****************************************************************************
1291 * DestroyThread: thread destruction
1292 *****************************************************************************
1293 * This function is called when the thread ends. It frees all ressources
1294 * allocated by CreateThread. Status is available at this stage.
1295 *****************************************************************************/
1296 static void DestroyThread( vout_thread_t *p_vout, int i_status )
1298 int *pi_status; /* status adress */
1300 /* Store status adress */
1301 pi_status = p_vout->pi_status;
1303 /* Destroy thread structures allocated by Create and InitThread */
1304 vout_UnloadFont( p_vout->p_default_font );
1305 vout_UnloadFont( p_vout->p_large_font );
1306 p_vout->pf_destroy( p_vout );
1308 /* Destroy the locks */
1309 vlc_mutex_destroy( &p_vout->picture_lock );
1310 vlc_mutex_destroy( &p_vout->subpicture_lock );
1311 vlc_mutex_destroy( &p_vout->change_lock );
1313 /* Release the module */
1314 module_Unneed( p_vout->p_module );
1316 /* Free structure */
1318 *pi_status = i_status;
1321 /*****************************************************************************
1322 * Print: print simple text on a picture
1323 *****************************************************************************
1324 * This function will print a simple text on the picture. It is designed to
1325 * print debugging or general information.
1326 *****************************************************************************/
1327 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 )
1329 int i_text_height; /* total text height */
1330 int i_text_width; /* total text width */
1332 /* Update upper left coordinates according to alignment */
1333 vout_TextSize( p_vout->p_default_font, 0, psz_text, &i_text_width, &i_text_height );
1334 if( !Align( p_vout, &i_x, &i_y, i_text_width, i_text_height, i_h_align, i_v_align ) )
1336 /* Set area and print text */
1337 SetBufferArea( p_vout, i_x, i_y, i_text_width, i_text_height );
1338 vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1339 i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
1340 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1341 p_vout->i_white_pixel, 0, 0,
1346 /*****************************************************************************
1347 * SetBufferArea: activate an area in current buffer
1348 *****************************************************************************
1349 * This function is called when something is rendered on the current buffer.
1350 * It set the area as active and prepare it to be cleared on next rendering.
1351 * Pay attention to the fact that in this functions, i_h is in fact the end y
1352 * coordinate of the new area.
1353 *****************************************************************************/
1354 static void SetBufferArea( vout_thread_t *p_vout, int i_x, int i_y, int i_w, int i_h )
1356 vout_buffer_t * p_buffer; /* current buffer */
1357 int i_area_begin, i_area_end; /* area vertical extension */
1358 int i_area, i_area_copy; /* area index */
1359 int i_area_shift; /* shift distance for areas */
1361 /* Choose buffer and modify h to end of area position */
1362 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1366 * Remove part of the area which is inside the picture - this is done
1367 * by calling again SetBufferArea with the correct areas dimensions.
1369 if( (i_x >= p_buffer->i_pic_x) && (i_x + i_w <= p_buffer->i_pic_x + p_buffer->i_pic_width) )
1371 i_area_begin = p_buffer->i_pic_y;
1372 i_area_end = i_area_begin + p_buffer->i_pic_height - 1;
1374 if( ((i_y >= i_area_begin) && (i_y <= i_area_end)) ||
1375 ((i_h >= i_area_begin) && (i_h <= i_area_end)) ||
1376 ((i_y < i_area_begin) && (i_h > i_area_end)) )
1378 /* Keep the stripe above the picture, if any */
1379 if( i_y < i_area_begin )
1381 SetBufferArea( p_vout, i_x, i_y, i_w, i_area_begin - i_y );
1383 /* Keep the stripe below the picture, if any */
1384 if( i_h > i_area_end )
1386 SetBufferArea( p_vout, i_x, i_area_end, i_w, i_h - i_area_end );
1392 /* Skip some extensions until interesting areas */
1394 (i_area < p_buffer->i_areas) &&
1395 (p_buffer->pi_area_end[i_area] + 1 <= i_y);
1401 if( i_area == p_buffer->i_areas )
1403 /* New area is below all existing ones: just add it at the end of the
1404 * array, if possible - otherwise, append it to the last one */
1405 if( i_area < VOUT_MAX_AREAS )
1407 p_buffer->pi_area_begin[i_area] = i_y;
1408 p_buffer->pi_area_end[i_area] = i_h;
1409 p_buffer->i_areas++;
1414 intf_DbgMsg("area overflow");
1416 p_buffer->pi_area_end[VOUT_MAX_AREAS - 1] = i_h;
1421 i_area_begin = p_buffer->pi_area_begin[i_area];
1422 i_area_end = p_buffer->pi_area_end[i_area];
1424 if( i_y < i_area_begin )
1426 if( i_h >= i_area_begin - 1 )
1428 /* Extend area above */
1429 p_buffer->pi_area_begin[i_area] = i_y;
1433 /* Create a new area above : merge last area if overflow, then
1434 * move all old areas down */
1435 if( p_buffer->i_areas == VOUT_MAX_AREAS )
1438 intf_DbgMsg("areas overflow");
1440 p_buffer->pi_area_end[VOUT_MAX_AREAS - 2] = p_buffer->pi_area_end[VOUT_MAX_AREAS - 1];
1444 p_buffer->i_areas++;
1446 for( i_area_copy = p_buffer->i_areas - 1; i_area_copy > i_area; i_area_copy-- )
1448 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy - 1];
1449 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy - 1];
1451 p_buffer->pi_area_begin[i_area] = i_y;
1452 p_buffer->pi_area_end[i_area] = i_h;
1456 if( i_h > i_area_end )
1458 /* Find further areas which can be merged with the new one */
1459 for( i_area_copy = i_area + 1;
1460 (i_area_copy < p_buffer->i_areas) &&
1461 (p_buffer->pi_area_begin[i_area] <= i_h);
1468 if( i_area_copy != i_area )
1470 /* Merge with last possible areas */
1471 //p_buffer->pi_area_end[i_area] = MAX( i_h, p_buffer->pi_area_end[i_area_copy] );
1473 /* Shift lower areas upward */
1474 i_area_shift = i_area_copy - i_area;
1475 p_buffer->i_areas -= i_area_shift;
1476 for( i_area_copy = i_area + 1; i_area_copy < p_buffer->i_areas; i_area_copy++ )
1478 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy + i_area_shift];
1479 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy + i_area_shift];
1484 /* Extend area below */
1485 p_buffer->pi_area_end[i_area] = i_h;
1491 /*****************************************************************************
1492 * SetBufferPicture: clear buffer and set picture area
1493 *****************************************************************************
1494 * This function is called before any rendering. It clears the current
1495 * rendering buffer and set the new picture area. If the picture pointer is
1496 * NULL, then no picture area is defined. Floating operations are avoided since
1497 * some MMX calculations may follow.
1498 *****************************************************************************/
1499 static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
1501 vout_buffer_t * p_buffer; /* current buffer */
1502 int i_pic_x, i_pic_y; /* picture position */
1503 int i_pic_width, i_pic_height; /* picture dimensions */
1504 int i_old_pic_y, i_old_pic_height; /* old picture area */
1505 int i_vout_width, i_vout_height; /* display dimensions */
1506 int i_area; /* area index */
1507 int i_data_index; /* area data index */
1508 int i_data_size; /* area data size, in 256 bytes blocs */
1509 u64 * p_data; /* area data, for clearing */
1510 byte_t * p_data8; /* area data, for clearing (slow) */
1512 /* Choose buffer and set display dimensions */
1513 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1514 i_vout_width = p_vout->i_width;
1515 i_vout_height = p_vout->i_height;
1518 * Computes new picture size
1522 /* Try horizontal scaling first - width must be a mutiple of 16 */
1523 i_pic_width = (( p_vout->b_scale || (p_pic->i_width > i_vout_width)) ?
1524 i_vout_width : p_pic->i_width) & ~0xf;
1525 switch( p_pic->i_aspect_ratio )
1527 case AR_3_4_PICTURE:
1528 i_pic_height = i_pic_width * 3 / 4;
1530 case AR_16_9_PICTURE:
1531 i_pic_height = i_pic_width * 9 / 16;
1533 case AR_221_1_PICTURE:
1534 i_pic_height = i_pic_width * 100 / 221;
1536 case AR_SQUARE_PICTURE:
1538 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1542 /* If picture dimensions using horizontal scaling are too large, use
1543 * vertical scaling. Since width must be a multiple of 16, height is
1544 * adjusted again after. */
1545 if( i_pic_height > i_vout_height )
1547 i_pic_height = ( p_vout->b_scale || (p_pic->i_height > i_vout_height)) ?
1548 i_vout_height : p_pic->i_height;
1549 switch( p_pic->i_aspect_ratio )
1551 case AR_3_4_PICTURE:
1552 i_pic_width = (i_pic_height * 4 / 3) & ~0xf;
1553 i_pic_height = i_pic_width * 3 / 4;
1555 case AR_16_9_PICTURE:
1556 i_pic_width = (i_pic_height * 16 / 9) & ~0xf;
1557 i_pic_height = i_pic_width * 9 / 16;
1559 case AR_221_1_PICTURE:
1560 i_pic_width = (i_pic_height * 221 / 100) & ~0xf;
1561 i_pic_height = i_pic_width * 100 / 221;
1563 case AR_SQUARE_PICTURE:
1565 i_pic_width = (p_pic->i_width * i_pic_height / p_pic->i_height) & ~0xf;
1566 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1571 /* Set picture position */
1572 i_pic_x = (p_vout->i_width - i_pic_width) / 2;
1573 i_pic_y = (p_vout->i_height - i_pic_height) / 2;
1578 /* No picture: size is 0 */
1586 * Set new picture size - if it is smaller than the previous one, clear
1587 * around it. Since picture are centered, only their size is tested.
1589 if( (p_buffer->i_pic_width > i_pic_width) || (p_buffer->i_pic_height > i_pic_height) )
1591 i_old_pic_y = p_buffer->i_pic_y;
1592 i_old_pic_height = p_buffer->i_pic_height;
1593 p_buffer->i_pic_x = i_pic_x;
1594 p_buffer->i_pic_y = i_pic_y;
1595 p_buffer->i_pic_width = i_pic_width;
1596 p_buffer->i_pic_height = i_pic_height;
1597 SetBufferArea( p_vout, 0, i_old_pic_y, p_vout->i_width, i_old_pic_height );
1601 p_buffer->i_pic_x = i_pic_x;
1602 p_buffer->i_pic_y = i_pic_y;
1603 p_buffer->i_pic_width = i_pic_width;
1604 p_buffer->i_pic_height = i_pic_height;
1610 for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
1613 intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d", p_pic,
1614 p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
1616 i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
1617 p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
1619 for( i_data_index = i_data_size / 256; i_data_index-- ; )
1621 /* Clear 256 bytes block */
1622 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
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;
1631 for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
1633 /* Clear remaining 16 bytes blocks */
1634 *p_data++ = 0; *p_data++ = 0;
1636 p_data8 = (byte_t *)p_data;
1637 for( i_data_index = i_data_size % 16; i_data_index--; )
1639 /* Clear remaining bytes */
1647 p_buffer->i_areas = 0;
1650 /*****************************************************************************
1651 * RenderPicture: render a picture
1652 *****************************************************************************
1653 * This function converts a picture from a video heap to a pixel-encoded image
1654 * and copies it to the current rendering buffer. No lock is required, since
1655 * the * rendered picture has been determined as existant, and will only be
1656 * destroyed by the vout thread later.
1657 *****************************************************************************/
1658 static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
1661 char psz_date[MSTRTIME_MAX_SIZE]; /* picture date */
1662 mtime_t render_time; /* picture rendering time */
1664 vout_buffer_t * p_buffer; /* rendering buffer */
1665 byte_t * p_pic_data; /* convertion destination */
1667 /* Get and set rendering information */
1668 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1669 p_pic_data = p_buffer->p_data +
1670 p_buffer->i_pic_x * p_vout->i_bytes_per_pixel +
1671 p_buffer->i_pic_y * p_vout->i_bytes_per_line;
1673 render_time = mdate();
1679 * Choose appropriate rendering function and render picture
1681 switch( p_pic->i_type )
1683 case YUV_420_PICTURE:
1684 p_vout->yuv.pf_yuv420( p_vout, p_pic_data,
1685 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1686 p_pic->i_width, p_pic->i_height,
1687 p_buffer->i_pic_width, p_buffer->i_pic_height,
1688 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1689 p_pic->i_matrix_coefficients );
1691 case YUV_422_PICTURE:
1692 p_vout->yuv.pf_yuv422( p_vout, p_pic_data,
1693 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1694 p_pic->i_width, p_pic->i_height,
1695 p_buffer->i_pic_width, p_buffer->i_pic_height,
1696 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1697 p_pic->i_matrix_coefficients );
1699 case YUV_444_PICTURE:
1700 p_vout->yuv.pf_yuv444( p_vout, p_pic_data,
1701 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1702 p_pic->i_width, p_pic->i_height,
1703 p_buffer->i_pic_width, p_buffer->i_pic_height,
1704 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1705 p_pic->i_matrix_coefficients );
1709 intf_ErrMsg("error: unknown picture type %d", p_pic->i_type );
1715 /* Print picture date and rendering time */
1716 intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s", p_pic,
1717 p_vout->i_buffer_index, (long) (mdate() - render_time),
1718 mstrtime( psz_date, p_pic->date ));
1722 /*****************************************************************************
1723 * RenderPictureInfo: print additionnal information on a picture
1724 *****************************************************************************
1725 * This function will print information such as fps and other picture
1726 * dependant information.
1727 *****************************************************************************/
1728 static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
1730 char psz_buffer[256]; /* string buffer */
1733 * Print FPS rate in upper right corner
1735 if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
1737 long i_fps = VOUT_FPS_SAMPLES * 1000000 * 10 /
1738 ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1)
1739 % VOUT_FPS_SAMPLES ] -
1740 p_vout->p_fps_sample[ p_vout->c_fps_samples
1741 % VOUT_FPS_SAMPLES ] );
1742 sprintf( psz_buffer, "%li.%i fps", i_fps / 10, (int)i_fps % 10 );
1743 Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
1747 * Print frames count and loop time in upper left corner
1749 sprintf( psz_buffer, "%ld frames, render: %ldus",
1750 (long) p_vout->c_fps_samples, (long) p_vout->render_time );
1751 Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
1755 * Print picture information in lower right corner
1757 sprintf( psz_buffer, "%s picture %dx%d (%dx%d%+d%+d %s) -> %dx%d+%d+%d",
1758 (p_pic->i_type == YUV_420_PICTURE) ? "4:2:0" :
1759 ((p_pic->i_type == YUV_422_PICTURE) ? "4:2:2" :
1760 ((p_pic->i_type == YUV_444_PICTURE) ? "4:4:4" : "ukn-type")),
1761 p_pic->i_width, p_pic->i_height,
1762 p_pic->i_display_width, p_pic->i_display_height,
1763 p_pic->i_display_horizontal_offset, p_pic->i_display_vertical_offset,
1764 (p_pic->i_aspect_ratio == AR_SQUARE_PICTURE) ? "sq" :
1765 ((p_pic->i_aspect_ratio == AR_3_4_PICTURE) ? "4:3" :
1766 ((p_pic->i_aspect_ratio == AR_16_9_PICTURE) ? "16:9" :
1767 ((p_pic->i_aspect_ratio == AR_221_1_PICTURE) ? "2.21:1" : "ukn-ar" ))),
1768 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_width,
1769 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height,
1770 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_x,
1771 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y );
1772 Print( p_vout, 0, 0, RIGHT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1776 /*****************************************************************************
1777 * RenderSplash: render splash picture
1778 *****************************************************************************
1779 * This function will print something on the screen. It will return 0 if
1780 * nothing has been rendered, or 1 if something has been changed on the screen.
1781 * Note that if you absolutely want something to be printed, you will have
1782 * to force it by setting the last idle date to 0.
1783 * Unlike other rendering functions, this one calls the SetBufferPicture
1784 * function when needed.
1785 *****************************************************************************/
1786 int RenderSplash( vout_thread_t *p_vout )
1788 int i_x = 0, i_y = 0; /* text position */
1789 int i_width, i_height; /* text size */
1790 char *psz_text = "VideoLAN Client (" VERSION ")"; /* text to display */
1792 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1793 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1795 // SetBufferPicture( p_vout, NULL );
1796 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1797 &i_width, &i_height );
1798 if( !Align( p_vout, &i_x, &i_y, i_width, i_height, CENTER_RALIGN, CENTER_RALIGN ) )
1800 vout_Print( p_vout->p_large_font,
1801 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1802 i_x * p_vout->i_bytes_per_pixel + (i_y - 16 ) * p_vout->i_bytes_per_line,
1803 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1804 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1805 WIDE_TEXT | OUTLINED_TEXT, psz_text, 100);
1806 SetBufferArea( p_vout, i_x, i_y, i_width, i_height);
1812 /*****************************************************************************
1813 * RenderIdle: render idle picture
1814 *****************************************************************************
1815 * This function will print something on the screen. It will return 0 if
1816 * nothing has been rendered, or 1 if something has been changed on the screen.
1817 * Note that if you absolutely want something to be printed, you will have
1818 * to force it by setting the last idle date to 0.
1819 * Unlike other rendering functions, this one calls the SetBufferPicture
1820 * function when needed.
1821 *****************************************************************************/
1822 int RenderIdle( vout_thread_t *p_vout )
1825 int i_x = 0, i_y = 0; /* text position */
1826 int i_width, i_height; /* text size */
1827 int i_amount = 0; /* amount to draw */
1828 char *psz_text = "Waiting for stream"; /* text to display */
1829 char *psz_wtext = "[................]";
1831 mtime_t current_date; /* current date */
1834 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1835 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1838 current_date = mdate();
1839 if( (current_date - p_vout->last_display_date) > VOUT_IDLE_DELAY
1840 // && (current_date - p_vout->last_idle_date) > VOUT_IDLE_DELAY
1843 /* FIXME: idle screen disabled */
1845 SetBufferPicture( p_vout, NULL );
1846 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1847 &i_width, &i_height );
1848 if( !Align( p_vout, &i_x, &i_y, i_width, i_height * 2, CENTER_RALIGN, CENTER_RALIGN ) )
1850 i_amount = (int) ((current_date - p_vout->last_display_date ) / 5000LL);
1851 vout_Print( p_vout->p_large_font,
1852 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1853 i_x * p_vout->i_bytes_per_pixel + i_y * p_vout->i_bytes_per_line,
1854 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1855 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1856 WIDE_TEXT | OUTLINED_TEXT, psz_text, (i_amount / 3 ) %110);
1858 vout_Print( p_vout->p_large_font,
1859 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1860 i_x * p_vout->i_bytes_per_pixel + (i_y + 16) * p_vout->i_bytes_per_line,
1861 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1862 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1863 WIDE_TEXT | OUTLINED_TEXT, psz_wtext, (i_amount/5)%110 );
1866 SetBufferArea( p_vout, i_x, i_y, i_width, i_height * 2 );
1874 /*****************************************************************************
1875 * RenderInfo: render additionnal information
1876 *****************************************************************************
1877 * This function renders information which do not depend on the current
1879 *****************************************************************************/
1880 static void RenderInfo( vout_thread_t *p_vout )
1883 char psz_buffer[256]; /* string buffer */
1884 int i_ready_pic = 0; /* ready pictures */
1885 int i_reserved_pic = 0; /* reserved pictures */
1886 int i_picture; /* picture index */
1891 * Print thread state in lower left corner
1893 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
1895 switch( p_vout->p_picture[i_picture].i_status )
1897 case RESERVED_PICTURE:
1898 case RESERVED_DATED_PICTURE:
1899 case RESERVED_DISP_PICTURE:
1907 sprintf( psz_buffer, "pic: %d (%d/%d)/%d",
1908 p_vout->i_pictures, i_reserved_pic, i_ready_pic, VOUT_MAX_PICTURES );
1909 Print( p_vout, 0, 0, LEFT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1913 /*****************************************************************************
1914 * RenderSubPicture: render a subpicture
1915 *****************************************************************************
1916 * This function renders a sub picture unit.
1917 *****************************************************************************/
1918 static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
1920 p_vout_font_t p_font; /* text font */
1921 int i_width, i_height; /* subpicture dimensions */
1923 while( p_subpic != NULL )
1925 switch( p_subpic->i_type )
1927 case DVD_SUBPICTURE: /* DVD subpicture unit */
1928 /* test if the picture really has to be displayed */
1929 if( mdate() < p_subpic->begin_date )
1931 /* not yet, see you later */
1934 if( mdate() > p_subpic->end_date )
1936 /* too late, destroying the subpic */
1937 vout_DestroySubPicture( p_vout, p_subpic );
1940 vout_RenderSPU( &p_vout->p_buffer[ p_vout->i_buffer_index ],
1941 p_subpic, p_vout->i_bytes_per_pixel,
1942 p_vout->i_bytes_per_line );
1944 case TEXT_SUBPICTURE: /* single line text */
1945 /* Select default font if not specified */
1946 p_font = p_subpic->type.text.p_font;
1947 if( p_font == NULL )
1949 p_font = p_vout->p_default_font;
1952 /* Compute text size (width and height fields are ignored)
1954 vout_TextSize( p_font, p_subpic->type.text.i_style,
1955 p_subpic->p_data, &i_width, &i_height );
1956 if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y,
1957 i_width, i_height, p_subpic->i_horizontal_align,
1958 p_subpic->i_vertical_align ) )
1961 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1962 p_subpic->i_x * p_vout->i_bytes_per_pixel +
1963 p_subpic->i_y * p_vout->i_bytes_per_line,
1964 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1965 p_subpic->type.text.i_char_color,
1966 p_subpic->type.text.i_border_color,
1967 p_subpic->type.text.i_bg_color,
1968 p_subpic->type.text.i_style, p_subpic->p_data, 100 );
1969 SetBufferArea( p_vout, p_subpic->i_x, p_subpic->i_y,
1970 i_width, i_height );
1976 intf_ErrMsg( "error: unknown subpicture %p type %d",
1977 p_subpic, p_subpic->i_type );
1981 p_subpic = p_subpic->p_next;
1985 /*****************************************************************************
1986 * RenderInterface: render the interface
1987 *****************************************************************************
1988 * This function renders the interface, if any.
1989 *****************************************************************************/
1990 static void RenderInterface( vout_thread_t *p_vout )
1992 int i_height, i_text_height; /* total and text height */
1993 int i_width_1, i_width_2; /* text width */
1994 int i_byte; /* byte index */
1995 const char *psz_text_1 = "[1-9] Channel [i]nfo [c]olor [g/G]amma";
1996 const char *psz_text_2 = "[+/-] Volume [m]ute [s]caling [Q]uit";
1999 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_1, &i_width_1, &i_height );
2000 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_2, &i_width_2, &i_text_height );
2001 i_height += i_text_height;
2003 /* Render background */
2004 for( i_byte = (p_vout->i_height - i_height) * p_vout->i_bytes_per_line;
2005 i_byte < p_vout->i_height * p_vout->i_bytes_per_line;
2009 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = p_vout->i_blue_pixel;
2012 /* Render text, if not larger than screen */
2013 if( i_width_1 < p_vout->i_width )
2015 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2016 (p_vout->i_height - i_height) * p_vout->i_bytes_per_line,
2017 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2018 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2019 OUTLINED_TEXT, psz_text_1, 100 );
2021 if( i_width_2 < p_vout->i_width )
2023 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2024 (p_vout->i_height - i_height + i_text_height) * p_vout->i_bytes_per_line,
2025 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2026 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2027 OUTLINED_TEXT, psz_text_2, 100 );
2030 /* Activate modified area */
2031 SetBufferArea( p_vout, 0, p_vout->i_height - i_height, p_vout->i_width, i_height );
2034 /*****************************************************************************
2035 * Manage: manage thread
2036 *****************************************************************************
2037 * This function will handle changes in thread configuration.
2038 *****************************************************************************/
2039 static int Manage( vout_thread_t *p_vout )
2042 if( p_vout->i_changes )
2044 intf_DbgMsg("changes: 0x%x (no display: 0x%x)", p_vout->i_changes,
2045 0 /* p_vout->i_changes & VOUT_NODISPLAY_CHANGE */ );
2049 /* On gamma or grayscale change, rebuild tables */
2050 if( p_vout->i_changes & (VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2053 if( vout_ResetYUV( p_vout ) )
2055 intf_ErrMsg( "vout error: can't rebuild conversion tables" );
2060 /* Clear changes flags which does not need management or have been
2062 p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2063 VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
2064 VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE |
2065 VOUT_CURSOR_CHANGE | VOUT_FULLSCREEN_CHANGE );
2067 /* Detect unauthorized changes */
2068 if( p_vout->i_changes )
2070 /* Some changes were not acknowledged by p_vout->pf_manage or this
2071 * function, it means they should not be authorized */
2072 intf_ErrMsg( "vout error: unauthorized changes in the vout thread" );
2079 /*****************************************************************************
2080 * Align: align a subpicture in the screen
2081 *****************************************************************************
2082 * This function is used for rendering text or subpictures. It returns non 0
2083 * it the final aera is not fully included in display area. Return coordinates
2085 *****************************************************************************/
2086 static int Align( vout_thread_t *p_vout, int *pi_x, int *pi_y,
2087 int i_width, int i_height, int i_h_align, int i_v_align )
2089 /* Align horizontally */
2093 *pi_x -= i_width / 2;
2096 *pi_x += (p_vout->i_width - i_width) / 2;
2102 *pi_x += p_vout->i_width - i_width;
2106 /* Align vertically */
2110 *pi_y -= i_height / 2;
2113 *pi_y += (p_vout->i_height - i_height) / 2;
2119 *pi_y += p_vout->i_height - i_height;
2121 case SUBTITLE_RALIGN:
2122 *pi_y += (p_vout->i_height + p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y +
2123 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height - i_height) / 2;
2127 /* Return non 0 if clipping failed */
2128 return( (*pi_x < 0) || (*pi_y < 0) ||
2129 (*pi_x + i_width > p_vout->i_width) || (*pi_y + i_height > p_vout->i_height) );
2132 /*****************************************************************************
2133 * SetPalette: sets an 8 bpp palette
2134 *****************************************************************************
2135 * This function is just a prototype that does nothing. Architectures that
2136 * support palette allocation should override it.
2137 *****************************************************************************/
2138 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
2139 u16 *green, u16 *blue, u16 *transp )
2141 intf_ErrMsg( "vout error: method does not support palette changing" );