1 /*****************************************************************************
2 * video_output.c : video output thread
3 * This module describes the programming interface for video output threads.
4 * It includes functions allowing to open a new thread, send pictures to a
5 * thread, and destroy a previously oppened video output thread.
6 *****************************************************************************
7 * Copyright (C) 2000 VideoLAN
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
31 #include <errno.h> /* ENOMEM */
32 #include <stdlib.h> /* free() */
33 #include <stdio.h> /* sprintf() */
34 #include <string.h> /* strerror() */
37 # include <sys/times.h>
47 #include "video_output.h"
48 #include "video_text.h"
49 #include "video_spu.h"
50 #include "video_yuv.h"
56 /*****************************************************************************
58 *****************************************************************************/
59 static int BinaryLog ( u32 i );
60 static void MaskToShift ( int *pi_left, int *pi_right, u32 i_mask );
61 static int InitThread ( vout_thread_t *p_vout );
62 static void RunThread ( vout_thread_t *p_vout );
63 static void ErrorThread ( vout_thread_t *p_vout );
64 static void EndThread ( vout_thread_t *p_vout );
65 static void DestroyThread ( vout_thread_t *p_vout, int i_status );
66 static void Print ( vout_thread_t *p_vout, int i_x, int i_y,
67 int i_h_align, int i_v_align,
68 unsigned char *psz_text );
69 static void SetBufferArea ( vout_thread_t *p_vout, int i_x, int i_y,
71 static void SetBufferPicture ( vout_thread_t *p_vout, picture_t *p_pic );
72 static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
73 static void RenderPictureInfo ( vout_thread_t *p_vout, picture_t *p_pic );
74 static void RenderSubPicture ( vout_thread_t *p_vout,
75 subpicture_t *p_subpic );
76 static void RenderInterface ( vout_thread_t *p_vout );
77 static int RenderIdle ( vout_thread_t *p_vout );
78 static int RenderSplash ( vout_thread_t *p_vout );
79 static void RenderInfo ( vout_thread_t *p_vout );
80 static int Manage ( vout_thread_t *p_vout );
81 static int Align ( vout_thread_t *p_vout, int *pi_x,
82 int *pi_y, int i_width, int i_height,
83 int i_h_align, int i_v_align );
84 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
85 u16 *green, u16 *blue, u16 *transp );
87 /*****************************************************************************
88 * vout_CreateThread: creates a new video output thread
89 *****************************************************************************
90 * This function creates a new video output thread, and returns a pointer
91 * to its description. On error, it returns NULL.
92 * If pi_status is NULL, then the function will block until the thread is ready.
93 * If not, it will be updated using one of the THREAD_* constants.
94 *****************************************************************************/
95 vout_thread_t * vout_CreateThread ( int *pi_status )
97 vout_thread_t * p_vout; /* thread descriptor */
98 int i_status; /* thread status */
99 int i_index; /* index for array initialization */
101 /* Allocate descriptor */
102 p_vout = (vout_thread_t *) malloc( sizeof(vout_thread_t) );
105 intf_ErrMsg( "vout error: vout thread creation returned %s",
110 /* Choose the best module */
111 p_vout->p_module = module_Need( p_main->p_bank,
112 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_main->p_bank, 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" );
230 p_vout->pf_destroy( p_vout );
235 p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
236 if( p_vout->p_large_font == NULL )
238 intf_ErrMsg( "vout error: could not load large font" );
239 vout_UnloadFont( p_vout->p_default_font );
240 p_vout->pf_destroy( p_vout );
245 /* Create thread and set locks */
246 vlc_mutex_init( &p_vout->picture_lock );
247 vlc_mutex_init( &p_vout->subpicture_lock );
248 vlc_mutex_init( &p_vout->change_lock );
250 if( vlc_thread_create( &p_vout->thread_id, "video output",
251 (void *) RunThread, (void *) p_vout) )
253 intf_ErrMsg("vout error: %s", strerror(ENOMEM));
254 vout_UnloadFont( p_vout->p_default_font );
255 vout_UnloadFont( p_vout->p_large_font );
256 p_vout->pf_destroy( p_vout );
261 intf_Msg( "vout: video display initialized (%dx%d, %d/%d bpp)",
262 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
263 p_vout->i_bytes_per_pixel * 8 );
265 /* If status is NULL, wait until the thread is created */
266 if( pi_status == NULL )
270 msleep( THREAD_SLEEP );
271 }while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
272 && (i_status != THREAD_FATAL) );
273 if( i_status != THREAD_READY )
281 /*****************************************************************************
282 * vout_DestroyThread: destroys a previously created thread
283 *****************************************************************************
284 * Destroy a terminated thread.
285 * The function will request a destruction of the specified thread. If pi_error
286 * is NULL, it will return once the thread is destroyed. Else, it will be
287 * update using one of the THREAD_* constants.
288 *****************************************************************************/
289 void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
291 int i_status; /* thread status */
295 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
296 *p_vout->pi_status = THREAD_DESTROY;
298 /* Request thread destruction */
301 /* If status is NULL, wait until thread has been destroyed */
302 if( pi_status == NULL )
306 msleep( THREAD_SLEEP );
307 }while( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
308 && (i_status != THREAD_FATAL) );
312 /*****************************************************************************
313 * vout_DisplaySubPicture: display a subpicture unit
314 *****************************************************************************
315 * Remove the reservation flag of an subpicture, which will cause it to be ready
316 * for display. The picture does not need to be locked, since it is ignored by
317 * the output thread if is reserved.
318 *****************************************************************************/
319 void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
322 char psz_begin_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
323 char psz_end_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
327 /* Check if status is valid */
328 if( p_subpic->i_status != RESERVED_SUBPICTURE )
330 intf_DbgMsg("error: subpicture %p has invalid status %d", p_subpic,
331 p_subpic->i_status );
335 /* Remove reservation flag */
336 p_subpic->i_status = READY_SUBPICTURE;
339 /* Send subpicture information */
340 intf_DbgMsg("subpicture %p: type=%d, begin date=%s, end date=%s",
341 p_subpic, p_subpic->i_type,
342 mstrtime( psz_begin_date, p_subpic->begin_date ),
343 mstrtime( psz_end_date, p_subpic->end_date ) );
347 /*****************************************************************************
348 * vout_CreateSubPicture: allocate a subpicture in the video output heap.
349 *****************************************************************************
350 * This function create a reserved subpicture in the video output heap.
351 * A null pointer is returned if the function fails. This method provides an
352 * already allocated zone of memory in the spu data fields. It needs locking
353 * since several pictures can be created by several producers threads.
354 *****************************************************************************/
355 subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
358 int i_subpic; /* subpicture index */
359 subpicture_t * p_free_subpic = NULL; /* first free subpicture */
360 subpicture_t * p_destroyed_subpic = NULL; /* first destroyed subpic */
363 vlc_mutex_lock( &p_vout->subpicture_lock );
366 * Look for an empty place
368 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
370 if( p_vout->p_subpicture[i_subpic].i_status == DESTROYED_SUBPICTURE )
372 /* Subpicture is marked for destruction, but is still allocated */
373 if( (p_vout->p_subpicture[i_subpic].i_type == i_type) &&
374 (p_vout->p_subpicture[i_subpic].i_size >= i_size) )
376 /* Memory size do match or is smaller : memory will not be
377 * reallocated, and function can end immediately - this is
378 * the best possible case, since no memory allocation needs
380 p_vout->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
382 intf_DbgMsg("subpicture %p (in destroyed subpicture slot)",
383 &p_vout->p_subpicture[i_subpic] );
385 vlc_mutex_unlock( &p_vout->subpicture_lock );
386 return( &p_vout->p_subpicture[i_subpic] );
388 else if( p_destroyed_subpic == NULL )
390 /* Memory size do not match, but subpicture index will be kept in
391 * case no other place are left */
392 p_destroyed_subpic = &p_vout->p_subpicture[i_subpic];
395 else if( (p_free_subpic == NULL) &&
396 (p_vout->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE ))
398 /* Subpicture is empty and ready for allocation */
399 p_free_subpic = &p_vout->p_subpicture[i_subpic];
403 /* If no free subpictures are available, use a destroyed subpicture */
404 if( (p_free_subpic == NULL) && (p_destroyed_subpic != NULL ) )
406 /* No free subpicture or matching destroyed subpictures have been
407 * found, but a destroyed subpicture is still avalaible */
408 free( p_destroyed_subpic->p_data );
409 p_free_subpic = p_destroyed_subpic;
415 if( p_free_subpic != NULL )
417 /* Allocate memory */
420 case TEXT_SUBPICTURE: /* text subpicture */
421 p_free_subpic->p_data = malloc( i_size + 1 );
423 case DVD_SUBPICTURE: /* DVD subpicture unit */
424 p_free_subpic->p_data = malloc( i_size );
428 intf_DbgMsg("error: unknown subpicture type %d", i_type );
429 p_free_subpic->p_data = NULL;
434 if( p_free_subpic->p_data != NULL )
436 /* Copy subpicture information, set some default values */
437 p_free_subpic->i_type = i_type;
438 p_free_subpic->i_status = RESERVED_SUBPICTURE;
439 p_free_subpic->i_size = i_size;
440 p_free_subpic->i_x = 0;
441 p_free_subpic->i_y = 0;
442 p_free_subpic->i_width = 0;
443 p_free_subpic->i_height = 0;
444 p_free_subpic->i_horizontal_align = CENTER_RALIGN;
445 p_free_subpic->i_vertical_align = CENTER_RALIGN;
449 /* Memory allocation failed : set subpicture as empty */
450 p_free_subpic->i_type = EMPTY_SUBPICTURE;
451 p_free_subpic->i_status = FREE_SUBPICTURE;
452 p_free_subpic = NULL;
453 intf_ErrMsg( "vout error: spu allocation returned %s",
454 strerror( ENOMEM ) );
458 intf_DbgMsg("subpicture %p (in free subpicture slot)", p_free_subpic );
460 vlc_mutex_unlock( &p_vout->subpicture_lock );
461 return( p_free_subpic );
464 /* No free or destroyed subpicture could be found */
465 intf_DbgMsg( "warning: subpicture heap is full" );
466 vlc_mutex_unlock( &p_vout->subpicture_lock );
470 /*****************************************************************************
471 * vout_DestroySubPicture: remove a subpicture from the heap
472 *****************************************************************************
473 * This function frees a previously reserved subpicture.
474 * It is meant to be used when the construction of a picture aborted.
475 * This function does not need locking since reserved subpictures are ignored
476 * by the output thread.
477 *****************************************************************************/
478 void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
481 /* Check if status is valid */
482 if( p_subpic->i_status != RESERVED_SUBPICTURE )
484 intf_DbgMsg("error: subpicture %p has invalid status %d",
485 p_subpic, p_subpic->i_status );
489 p_subpic->i_status = DESTROYED_SUBPICTURE;
492 intf_DbgMsg("subpicture %p", p_subpic);
496 /*****************************************************************************
497 * vout_DisplayPicture: display a picture
498 *****************************************************************************
499 * Remove the reservation flag of a picture, which will cause it to be ready for
500 * display. The picture won't be displayed until vout_DatePicture has been
502 *****************************************************************************/
503 void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
505 vlc_mutex_lock( &p_vout->picture_lock );
506 switch( p_pic->i_status )
508 case RESERVED_PICTURE:
509 p_pic->i_status = RESERVED_DISP_PICTURE;
511 case RESERVED_DATED_PICTURE:
512 p_pic->i_status = READY_PICTURE;
516 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
522 intf_DbgMsg("picture %p", p_pic);
524 vlc_mutex_unlock( &p_vout->picture_lock );
527 /*****************************************************************************
528 * vout_DatePicture: date a picture
529 *****************************************************************************
530 * Remove the reservation flag of a picture, which will cause it to be ready for
531 * display. The picture won't be displayed until vout_DisplayPicture has been
533 *****************************************************************************/
534 void vout_DatePicture( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date )
537 char psz_date[MSTRTIME_MAX_SIZE]; /* date */
540 vlc_mutex_lock( &p_vout->picture_lock );
542 switch( p_pic->i_status )
544 case RESERVED_PICTURE:
545 p_pic->i_status = RESERVED_DATED_PICTURE;
547 case RESERVED_DISP_PICTURE:
548 p_pic->i_status = READY_PICTURE;
552 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
558 intf_DbgMsg("picture %p, display date: %s", p_pic, mstrtime( psz_date, p_pic->date) );
560 vlc_mutex_unlock( &p_vout->picture_lock );
563 /*****************************************************************************
564 * vout_CreatePicture: allocate a picture in the video output heap.
565 *****************************************************************************
566 * This function create a reserved image in the video output heap.
567 * A null pointer is returned if the function fails. This method provides an
568 * already allocated zone of memory in the picture data fields. It needs locking
569 * since several pictures can be created by several producers threads.
570 *****************************************************************************/
571 picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
572 int i_width, int i_height )
574 int i_picture; /* picture index */
575 int i_chroma_width = 0; /* chroma width */
576 picture_t * p_free_picture = NULL; /* first free picture */
577 picture_t * p_destroyed_picture = NULL; /* first destroyed picture */
580 vlc_mutex_lock( &p_vout->picture_lock );
583 * Look for an empty place
585 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
587 if( p_vout->p_picture[i_picture].i_status == DESTROYED_PICTURE )
589 /* Picture is marked for destruction, but is still allocated - note
590 * that if width and type are the same for two pictures, chroma_width
591 * should also be the same */
592 if( (p_vout->p_picture[i_picture].i_type == i_type) &&
593 (p_vout->p_picture[i_picture].i_height == i_height) &&
594 (p_vout->p_picture[i_picture].i_width == i_width) )
596 /* Memory size do match : memory will not be reallocated, and function
597 * can end immediately - this is the best possible case, since no
598 * memory allocation needs to be done */
599 p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
600 p_vout->i_pictures++;
602 intf_DbgMsg("picture %p (in destroyed picture slot)",
603 &p_vout->p_picture[i_picture] );
605 vlc_mutex_unlock( &p_vout->picture_lock );
606 return( &p_vout->p_picture[i_picture] );
608 else if( p_destroyed_picture == NULL )
610 /* Memory size do not match, but picture index will be kept in
611 * case no other place are left */
612 p_destroyed_picture = &p_vout->p_picture[i_picture];
615 else if( (p_free_picture == NULL) &&
616 (p_vout->p_picture[i_picture].i_status == FREE_PICTURE ))
618 /* Picture is empty and ready for allocation */
619 p_free_picture = &p_vout->p_picture[i_picture];
623 /* If no free picture is available, use a destroyed picture */
624 if( (p_free_picture == NULL) && (p_destroyed_picture != NULL ) )
626 /* No free picture or matching destroyed picture has been found, but
627 * a destroyed picture is still avalaible */
628 free( p_destroyed_picture->p_data );
629 p_free_picture = p_destroyed_picture;
635 if( p_free_picture != NULL )
637 /* Allocate memory */
640 case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
641 i_chroma_width = i_width / 2;
642 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * 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*4/2;
645 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*5/2;
647 case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
648 i_chroma_width = i_width / 2;
649 p_free_picture->p_data = malloc( i_height * i_chroma_width * 4 * 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*2;
652 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*3;
654 case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
655 i_chroma_width = i_width;
656 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
657 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
658 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width;
659 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
663 intf_DbgMsg("error: unknown picture type %d", i_type );
664 p_free_picture->p_data = NULL;
669 if( p_free_picture->p_data != NULL )
671 /* Copy picture information, set some default values */
672 p_free_picture->i_type = i_type;
673 p_free_picture->i_status = RESERVED_PICTURE;
674 p_free_picture->i_matrix_coefficients = 1;
675 p_free_picture->i_width = i_width;
676 p_free_picture->i_height = i_height;
677 p_free_picture->i_chroma_width = i_chroma_width;
678 p_free_picture->i_size = i_width * i_height;
679 p_free_picture->i_chroma_size = i_chroma_width
681 p_free_picture->i_display_horizontal_offset = 0;
682 p_free_picture->i_display_vertical_offset = 0;
683 p_free_picture->i_display_width = i_width;
684 p_free_picture->i_display_height = i_height;
685 p_free_picture->i_aspect_ratio = AR_SQUARE_PICTURE;
686 p_free_picture->i_refcount = 0;
687 p_vout->i_pictures++;
691 /* Memory allocation failed : set picture as empty */
692 p_free_picture->i_type = EMPTY_PICTURE;
693 p_free_picture->i_status = FREE_PICTURE;
694 p_free_picture = NULL;
695 intf_ErrMsg( "vout error: picture allocation returned %s",
696 strerror( ENOMEM ) );
700 intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
702 vlc_mutex_unlock( &p_vout->picture_lock );
704 /* Initialize mutex */
705 vlc_mutex_init( &(p_free_picture->lock_deccount) );
707 return( p_free_picture );
710 /* No free or destroyed picture could be found */
711 intf_DbgMsg( "warning: picture heap is full" );
712 vlc_mutex_unlock( &p_vout->picture_lock );
716 /*****************************************************************************
717 * vout_DestroyPicture: remove a permanent or reserved picture from the heap
718 *****************************************************************************
719 * This function frees a previously reserved picture or a permanent
720 * picture. It is meant to be used when the construction of a picture aborted.
721 * Note that the picture will be destroyed even if it is linked !
722 *****************************************************************************/
723 void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
725 vlc_mutex_lock( &p_vout->picture_lock );
728 /* Check if picture status is valid */
729 if( (p_pic->i_status != RESERVED_PICTURE) &&
730 (p_pic->i_status != RESERVED_DATED_PICTURE) &&
731 (p_pic->i_status != RESERVED_DISP_PICTURE) )
733 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
737 p_pic->i_status = DESTROYED_PICTURE;
738 p_vout->i_pictures--;
741 intf_DbgMsg("picture %p", p_pic);
744 /* destroy the lock that had been initialized in CreatePicture */
745 vlc_mutex_destroy( &(p_pic->lock_deccount) );
747 vlc_mutex_unlock( &p_vout->picture_lock );
750 /*****************************************************************************
751 * vout_LinkPicture: increment reference counter of a picture
752 *****************************************************************************
753 * This function increment the reference counter of a picture in the video
754 * heap. It needs a lock since several producer threads can access the picture.
755 *****************************************************************************/
756 void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
758 vlc_mutex_lock( &p_vout->picture_lock );
762 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
765 vlc_mutex_unlock( &p_vout->picture_lock );
768 /*****************************************************************************
769 * vout_UnlinkPicture: decrement reference counter of a picture
770 *****************************************************************************
771 * This function decrement the reference counter of a picture in the video heap.
772 *****************************************************************************/
773 void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
775 vlc_mutex_lock( &p_vout->picture_lock );
779 if( p_pic->i_refcount < 0 )
781 intf_DbgMsg("error: refcount < 0");
782 p_pic->i_refcount = 0;
786 if( (p_pic->i_refcount == 0) && (p_pic->i_status == DISPLAYED_PICTURE) )
788 p_pic->i_status = DESTROYED_PICTURE;
789 p_vout->i_pictures--;
793 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
796 vlc_mutex_unlock( &p_vout->picture_lock );
799 /*****************************************************************************
800 * vout_SetBuffers: set buffers adresses
801 *****************************************************************************
802 * This function is called by system drivers to set buffers video memory
804 *****************************************************************************/
805 void vout_SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
807 /* No picture previously */
808 p_vout->p_buffer[0].i_pic_x = 0;
809 p_vout->p_buffer[0].i_pic_y = 0;
810 p_vout->p_buffer[0].i_pic_width = 0;
811 p_vout->p_buffer[0].i_pic_height = 0;
812 p_vout->p_buffer[1].i_pic_x = 0;
813 p_vout->p_buffer[1].i_pic_y = 0;
814 p_vout->p_buffer[1].i_pic_width = 0;
815 p_vout->p_buffer[1].i_pic_height = 0;
817 /* The first area covers all the screen */
818 p_vout->p_buffer[0].i_areas = 1;
819 p_vout->p_buffer[0].pi_area_begin[0] = 0;
820 p_vout->p_buffer[0].pi_area_end[0] = p_vout->i_height - 1;
821 p_vout->p_buffer[1].i_areas = 1;
822 p_vout->p_buffer[1].pi_area_begin[0] = 0;
823 p_vout->p_buffer[1].pi_area_end[0] = p_vout->i_height - 1;
826 p_vout->p_buffer[0].p_data = p_buf1;
827 p_vout->p_buffer[1].p_data = p_buf2;
830 /*****************************************************************************
831 * vout_Pixel2RGB: return red, green and blue from pixel value
832 *****************************************************************************
833 * Return color values, in 0-255 range, of the decomposition of a pixel. This
834 * is a slow routine and should only be used for initialization phase.
835 *****************************************************************************/
836 void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
838 *pi_red = i_pixel & p_vout->i_red_mask;
839 *pi_green = i_pixel & p_vout->i_green_mask;
840 *pi_blue = i_pixel & p_vout->i_blue_mask;
843 /* following functions are local */
845 /*****************************************************************************
846 * BinaryLog: computes the base 2 log of a binary value
847 *****************************************************************************
848 * This functions is used by MaskToShift, to get a bit index from a binary
850 *****************************************************************************/
851 static int BinaryLog(u32 i)
876 if (i != ((u32)1 << i_log))
878 intf_DbgMsg("internal error: binary log overflow");
884 /*****************************************************************************
885 * MaskToShift: transform a color mask into right and left shifts
886 *****************************************************************************
887 * This function is used for obtaining color shifts from masks.
888 *****************************************************************************/
889 static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
891 u32 i_low, i_high; /* lower hand higher bits of the mask */
894 i_low = i_mask & (- i_mask); /* lower bit of the mask */
895 i_high = i_mask + i_low; /* higher bit of the mask */
897 /* Transform bits into an index */
898 i_low = BinaryLog (i_low);
899 i_high = BinaryLog (i_high);
901 /* Update pointers and return */
903 *pi_right = (8 - i_high + i_low);
906 /*****************************************************************************
907 * InitThread: initialize video output thread
908 *****************************************************************************
909 * This function is called from RunThread and performs the second step of the
910 * initialization. It returns 0 on success. Note that the thread's flag are not
911 * modified inside this function.
912 *****************************************************************************/
913 static int InitThread( vout_thread_t *p_vout )
916 *p_vout->pi_status = THREAD_START;
918 vlc_mutex_lock( &p_vout->change_lock );
924 /* Initialize output method - this function issues its own error messages */
925 if( p_vout->pf_init( p_vout ) )
930 /* Initialize convertion tables and functions */
931 if( vout_InitYUV( p_vout ) )
933 intf_ErrMsg("vout error: can't allocate YUV translation tables");
937 /* Mark thread as running and return */
938 p_vout->b_active = 1;
939 *p_vout->pi_status = THREAD_READY;
942 intf_DbgMsg("thread ready");
946 /*****************************************************************************
947 * RunThread: video output thread
948 *****************************************************************************
949 * Video output thread. This function does only returns when the thread is
950 * terminated. It handles the pictures arriving in the video heap and the
951 * display device events.
952 *****************************************************************************/
953 static void RunThread( vout_thread_t *p_vout)
955 int i_index; /* index in heap */
956 mtime_t current_date; /* current date */
957 mtime_t display_date; /* display date */
958 boolean_t b_display; /* display flag */
959 picture_t * p_pic; /* picture pointer */
960 subpicture_t * p_subpic; /* subpicture pointer */
965 p_vout->b_error = InitThread( p_vout );
966 if( p_vout->b_error )
968 DestroyThread( p_vout, THREAD_ERROR );
973 * Main loop - it is not executed if an error occured during
976 while( (!p_vout->b_die) && (!p_vout->b_error) )
978 /* Initialize loop variables */
982 current_date = mdate();
985 if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
987 intf_Msg("vout stats: picture heap: %d/%d",
988 p_vout->i_pictures, VOUT_MAX_PICTURES);
993 * Find the picture to display - this operation does not need lock,
994 * since only READY_PICTUREs are handled
996 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
998 if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) &&
1000 (p_vout->p_picture[i_index].date < display_date) ) )
1002 p_pic = &p_vout->p_picture[i_index];
1003 display_date = p_pic->date;
1009 /* Computes FPS rate */
1010 p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ] = display_date;
1012 if( display_date < current_date - p_vout->render_time )
1014 /* Picture is late: it will be destroyed and the thread
1015 * will sleep and go to next picture */
1017 vlc_mutex_lock( &p_vout->picture_lock );
1018 if( p_pic->i_refcount )
1020 p_pic->i_status = DISPLAYED_PICTURE;
1024 p_pic->i_status = DESTROYED_PICTURE;
1025 p_vout->i_pictures--;
1028 "warning: late picture skipped (%p)", p_pic );
1029 vlc_mutex_unlock( &p_vout->picture_lock );
1033 else if( display_date > current_date + VOUT_DISPLAY_DELAY )
1035 /* A picture is ready to be rendered, but its rendering date
1036 * is far from the current one so the thread will perform an
1037 * empty loop as if no picture were found. The picture state
1044 * Find the subpictures to display - this operation does not need
1045 * lock, since only READY_SUBPICTURE are handled. If no picture
1046 * has been selected, display_date will depend on the subpicture.
1047 * We get an easily parsable chained list of subpictures which
1048 * ends with NULL since p_subpic was initialized to NULL.
1050 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1052 if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
1054 p_vout->p_subpicture[i_index].p_next = p_subpic;
1055 p_subpic = &p_vout->p_subpicture[i_index];
1060 * Perform rendering, sleep and display rendered picture
1062 if( p_pic ) /* picture and perhaps subpicture */
1064 b_display = p_vout->b_active;
1065 p_vout->last_display_date = display_date;
1066 p_vout->p_rendered_pic = p_pic;
1071 /* Set picture dimensions and clear buffer */
1072 SetBufferPicture( p_vout, p_pic );
1074 /* FIXME: if b_need_render == 0 we need to do something with
1075 * the subpictures one day. */
1077 if( p_vout->b_need_render && b_display )
1079 /* Render picture and information */
1080 RenderPicture( p_vout, p_pic );
1081 if( p_vout->b_info )
1083 RenderPictureInfo( p_vout, p_pic );
1084 RenderInfo( p_vout );
1088 RenderSubPicture( p_vout, p_subpic );
1092 /* Render interface and subpicture */
1093 if( b_display && p_vout->b_interface && p_vout->b_need_render )
1095 RenderInterface( p_vout );
1099 else if( p_vout->b_active && p_vout->b_need_render
1100 && p_vout->init_display_date == 0)
1102 /* Idle or interface screen alone */
1104 if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
1106 /* Interface has changed, so a new rendering is required - force
1107 * it by setting last idle date to 0 */
1108 p_vout->last_idle_date = 0;
1111 /* Render idle screen and update idle date, then render interface if
1113 b_display = RenderIdle( p_vout );
1116 p_vout->last_idle_date = current_date;
1117 if( p_vout->b_interface )
1119 RenderInterface( p_vout );
1131 * Check for the current time and
1132 * display splash screen if everything is on time
1134 if( p_vout->init_display_date > 0 && p_vout->b_need_render )
1136 if( p_vout->b_active &&
1137 mdate()-p_vout->init_display_date < 5000000)
1139 /* there is something to display ! */
1141 RenderSplash( p_vout );
1144 /* no splash screen ! */
1145 p_vout->init_display_date=0;
1151 * Sleep, wake up and display rendered picture
1154 if( display_date != 0 )
1156 /* Store render time using Bresenham algorithm */
1157 p_vout->render_time += mdate() - current_date;
1158 p_vout->render_time >>= 1;
1161 /* Give back change lock */
1162 vlc_mutex_unlock( &p_vout->change_lock );
1164 /* Sleep a while or until a given date */
1165 if( display_date != 0 )
1167 mwait( display_date - VOUT_MWAIT_TOLERANCE );
1171 msleep( VOUT_IDLE_SLEEP );
1174 /* On awakening, take back lock and send immediately picture to display,
1175 * then swap buffers */
1176 vlc_mutex_lock( &p_vout->change_lock );
1178 intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d", p_pic, p_subpic,
1179 p_vout->i_buffer_index, b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ );
1181 if( b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ )
1183 p_vout->pf_display( p_vout );
1185 p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;
1191 /* Remove picture from heap */
1192 vlc_mutex_lock( &p_vout->picture_lock );
1193 if( p_pic->i_refcount )
1195 p_pic->i_status = DISPLAYED_PICTURE;
1199 p_pic->i_status = DESTROYED_PICTURE;
1200 p_vout->i_pictures--;
1202 vlc_mutex_unlock( &p_vout->picture_lock );
1207 * Check events and manage thread
1209 if( p_vout->pf_manage( p_vout ) | Manage( p_vout ) )
1211 /* A fatal error occured, and the thread must terminate immediately,
1212 * without displaying anything - setting b_error to 1 cause the
1213 * immediate end of the main while() loop. */
1214 p_vout->b_error = 1;
1219 * Error loop - wait until the thread destruction is requested
1221 if( p_vout->b_error )
1223 ErrorThread( p_vout );
1227 EndThread( p_vout );
1228 DestroyThread( p_vout, THREAD_OVER );
1229 intf_DbgMsg( "thread end" );
1232 /*****************************************************************************
1233 * ErrorThread: RunThread() error loop
1234 *****************************************************************************
1235 * This function is called when an error occured during thread main's loop. The
1236 * thread can still receive feed, but must be ready to terminate as soon as
1238 *****************************************************************************/
1239 static void ErrorThread( vout_thread_t *p_vout )
1241 /* Wait until a `die' order */
1242 while( !p_vout->b_die )
1245 msleep( VOUT_IDLE_SLEEP );
1249 /*****************************************************************************
1250 * EndThread: thread destruction
1251 *****************************************************************************
1252 * This function is called when the thread ends after a sucessful
1253 * initialization. It frees all ressources allocated by InitThread.
1254 *****************************************************************************/
1255 static void EndThread( vout_thread_t *p_vout )
1257 int i_index; /* index in heap */
1260 *p_vout->pi_status = THREAD_END;
1264 struct tms cpu_usage;
1265 times( &cpu_usage );
1267 intf_Msg( "vout stats: cpu usage (user: %d, system: %d)",
1268 cpu_usage.tms_utime, cpu_usage.tms_stime );
1272 /* Destroy all remaining pictures and subpictures */
1273 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
1275 if( p_vout->p_picture[i_index].i_status != FREE_PICTURE )
1277 free( p_vout->p_picture[i_index].p_data );
1281 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1283 if( p_vout->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
1285 free( p_vout->p_subpicture[i_index].p_data );
1289 /* Destroy translation tables */
1290 vout_EndYUV( p_vout );
1291 p_vout->pf_end( p_vout );
1293 /* Release the change lock */
1294 vlc_mutex_unlock( &p_vout->change_lock );
1297 /*****************************************************************************
1298 * DestroyThread: thread destruction
1299 *****************************************************************************
1300 * This function is called when the thread ends. It frees all ressources
1301 * allocated by CreateThread. Status is available at this stage.
1302 *****************************************************************************/
1303 static void DestroyThread( vout_thread_t *p_vout, int i_status )
1305 int *pi_status; /* status adress */
1307 /* Store status adress */
1308 pi_status = p_vout->pi_status;
1310 /* Destroy thread structures allocated by Create and InitThread */
1311 vout_UnloadFont( p_vout->p_default_font );
1312 vout_UnloadFont( p_vout->p_large_font );
1313 p_vout->pf_destroy( p_vout );
1315 /* Destroy the locks */
1316 vlc_mutex_destroy( &p_vout->picture_lock );
1317 vlc_mutex_destroy( &p_vout->subpicture_lock );
1318 vlc_mutex_destroy( &p_vout->change_lock );
1320 /* Release the module */
1321 module_Unneed( p_main->p_bank, p_vout->p_module );
1323 /* Free structure */
1325 *pi_status = i_status;
1328 /*****************************************************************************
1329 * Print: print simple text on a picture
1330 *****************************************************************************
1331 * This function will print a simple text on the picture. It is designed to
1332 * print debugging or general information.
1333 *****************************************************************************/
1334 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 )
1336 int i_text_height; /* total text height */
1337 int i_text_width; /* total text width */
1339 /* Update upper left coordinates according to alignment */
1340 vout_TextSize( p_vout->p_default_font, 0, psz_text, &i_text_width, &i_text_height );
1341 if( !Align( p_vout, &i_x, &i_y, i_text_width, i_text_height, i_h_align, i_v_align ) )
1343 /* Set area and print text */
1344 SetBufferArea( p_vout, i_x, i_y, i_text_width, i_text_height );
1345 vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1346 i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
1347 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1348 p_vout->i_white_pixel, 0, 0,
1353 /*****************************************************************************
1354 * SetBufferArea: activate an area in current buffer
1355 *****************************************************************************
1356 * This function is called when something is rendered on the current buffer.
1357 * It set the area as active and prepare it to be cleared on next rendering.
1358 * Pay attention to the fact that in this functions, i_h is in fact the end y
1359 * coordinate of the new area.
1360 *****************************************************************************/
1361 static void SetBufferArea( vout_thread_t *p_vout, int i_x, int i_y, int i_w, int i_h )
1363 vout_buffer_t * p_buffer; /* current buffer */
1364 int i_area_begin, i_area_end; /* area vertical extension */
1365 int i_area, i_area_copy; /* area index */
1366 int i_area_shift; /* shift distance for areas */
1368 /* Choose buffer and modify h to end of area position */
1369 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1373 * Remove part of the area which is inside the picture - this is done
1374 * by calling again SetBufferArea with the correct areas dimensions.
1376 if( (i_x >= p_buffer->i_pic_x) && (i_x + i_w <= p_buffer->i_pic_x + p_buffer->i_pic_width) )
1378 i_area_begin = p_buffer->i_pic_y;
1379 i_area_end = i_area_begin + p_buffer->i_pic_height - 1;
1381 if( ((i_y >= i_area_begin) && (i_y <= i_area_end)) ||
1382 ((i_h >= i_area_begin) && (i_h <= i_area_end)) ||
1383 ((i_y < i_area_begin) && (i_h > i_area_end)) )
1385 /* Keep the stripe above the picture, if any */
1386 if( i_y < i_area_begin )
1388 SetBufferArea( p_vout, i_x, i_y, i_w, i_area_begin - i_y );
1390 /* Keep the stripe below the picture, if any */
1391 if( i_h > i_area_end )
1393 SetBufferArea( p_vout, i_x, i_area_end, i_w, i_h - i_area_end );
1399 /* Skip some extensions until interesting areas */
1401 (i_area < p_buffer->i_areas) &&
1402 (p_buffer->pi_area_end[i_area] + 1 <= i_y);
1408 if( i_area == p_buffer->i_areas )
1410 /* New area is below all existing ones: just add it at the end of the
1411 * array, if possible - otherwise, append it to the last one */
1412 if( i_area < VOUT_MAX_AREAS )
1414 p_buffer->pi_area_begin[i_area] = i_y;
1415 p_buffer->pi_area_end[i_area] = i_h;
1416 p_buffer->i_areas++;
1421 intf_DbgMsg("area overflow");
1423 p_buffer->pi_area_end[VOUT_MAX_AREAS - 1] = i_h;
1428 i_area_begin = p_buffer->pi_area_begin[i_area];
1429 i_area_end = p_buffer->pi_area_end[i_area];
1431 if( i_y < i_area_begin )
1433 if( i_h >= i_area_begin - 1 )
1435 /* Extend area above */
1436 p_buffer->pi_area_begin[i_area] = i_y;
1440 /* Create a new area above : merge last area if overflow, then
1441 * move all old areas down */
1442 if( p_buffer->i_areas == VOUT_MAX_AREAS )
1445 intf_DbgMsg("areas overflow");
1447 p_buffer->pi_area_end[VOUT_MAX_AREAS - 2] = p_buffer->pi_area_end[VOUT_MAX_AREAS - 1];
1451 p_buffer->i_areas++;
1453 for( i_area_copy = p_buffer->i_areas - 1; i_area_copy > i_area; i_area_copy-- )
1455 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy - 1];
1456 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy - 1];
1458 p_buffer->pi_area_begin[i_area] = i_y;
1459 p_buffer->pi_area_end[i_area] = i_h;
1463 if( i_h > i_area_end )
1465 /* Find further areas which can be merged with the new one */
1466 for( i_area_copy = i_area + 1;
1467 (i_area_copy < p_buffer->i_areas) &&
1468 (p_buffer->pi_area_begin[i_area] <= i_h);
1475 if( i_area_copy != i_area )
1477 /* Merge with last possible areas */
1478 //p_buffer->pi_area_end[i_area] = MAX( i_h, p_buffer->pi_area_end[i_area_copy] );
1480 /* Shift lower areas upward */
1481 i_area_shift = i_area_copy - i_area;
1482 p_buffer->i_areas -= i_area_shift;
1483 for( i_area_copy = i_area + 1; i_area_copy < p_buffer->i_areas; i_area_copy++ )
1485 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy + i_area_shift];
1486 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy + i_area_shift];
1491 /* Extend area below */
1492 p_buffer->pi_area_end[i_area] = i_h;
1498 /*****************************************************************************
1499 * SetBufferPicture: clear buffer and set picture area
1500 *****************************************************************************
1501 * This function is called before any rendering. It clears the current
1502 * rendering buffer and set the new picture area. If the picture pointer is
1503 * NULL, then no picture area is defined. Floating operations are avoided since
1504 * some MMX calculations may follow.
1505 *****************************************************************************/
1506 static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
1508 vout_buffer_t * p_buffer; /* current buffer */
1509 int i_pic_x, i_pic_y; /* picture position */
1510 int i_pic_width, i_pic_height; /* picture dimensions */
1511 int i_old_pic_y, i_old_pic_height; /* old picture area */
1512 int i_vout_width, i_vout_height; /* display dimensions */
1513 int i_area; /* area index */
1514 int i_data_index; /* area data index */
1515 int i_data_size; /* area data size, in 256 bytes blocs */
1516 u64 * p_data; /* area data, for clearing */
1517 byte_t * p_data8; /* area data, for clearing (slow) */
1519 /* Choose buffer and set display dimensions */
1520 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1521 i_vout_width = p_vout->i_width;
1522 i_vout_height = p_vout->i_height;
1525 * Computes new picture size
1529 /* Try horizontal scaling first - width must be a mutiple of 16 */
1530 i_pic_width = (( p_vout->b_scale || (p_pic->i_width > i_vout_width)) ?
1531 i_vout_width : p_pic->i_width) & ~0xf;
1532 switch( p_pic->i_aspect_ratio )
1534 case AR_3_4_PICTURE:
1535 i_pic_height = i_pic_width * 3 / 4;
1537 case AR_16_9_PICTURE:
1538 i_pic_height = i_pic_width * 9 / 16;
1540 case AR_221_1_PICTURE:
1541 i_pic_height = i_pic_width * 100 / 221;
1543 case AR_SQUARE_PICTURE:
1545 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1549 /* If picture dimensions using horizontal scaling are too large, use
1550 * vertical scaling. Since width must be a multiple of 16, height is
1551 * adjusted again after. */
1552 if( i_pic_height > i_vout_height )
1554 i_pic_height = ( p_vout->b_scale || (p_pic->i_height > i_vout_height)) ?
1555 i_vout_height : p_pic->i_height;
1556 switch( p_pic->i_aspect_ratio )
1558 case AR_3_4_PICTURE:
1559 i_pic_width = (i_pic_height * 4 / 3) & ~0xf;
1560 i_pic_height = i_pic_width * 3 / 4;
1562 case AR_16_9_PICTURE:
1563 i_pic_width = (i_pic_height * 16 / 9) & ~0xf;
1564 i_pic_height = i_pic_width * 9 / 16;
1566 case AR_221_1_PICTURE:
1567 i_pic_width = (i_pic_height * 221 / 100) & ~0xf;
1568 i_pic_height = i_pic_width * 100 / 221;
1570 case AR_SQUARE_PICTURE:
1572 i_pic_width = (p_pic->i_width * i_pic_height / p_pic->i_height) & ~0xf;
1573 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1578 /* Set picture position */
1579 i_pic_x = (p_vout->i_width - i_pic_width) / 2;
1580 i_pic_y = (p_vout->i_height - i_pic_height) / 2;
1585 /* No picture: size is 0 */
1593 * Set new picture size - if it is smaller than the previous one, clear
1594 * around it. Since picture are centered, only their size is tested.
1596 if( (p_buffer->i_pic_width > i_pic_width) || (p_buffer->i_pic_height > i_pic_height) )
1598 i_old_pic_y = p_buffer->i_pic_y;
1599 i_old_pic_height = p_buffer->i_pic_height;
1600 p_buffer->i_pic_x = i_pic_x;
1601 p_buffer->i_pic_y = i_pic_y;
1602 p_buffer->i_pic_width = i_pic_width;
1603 p_buffer->i_pic_height = i_pic_height;
1604 SetBufferArea( p_vout, 0, i_old_pic_y, p_vout->i_width, i_old_pic_height );
1608 p_buffer->i_pic_x = i_pic_x;
1609 p_buffer->i_pic_y = i_pic_y;
1610 p_buffer->i_pic_width = i_pic_width;
1611 p_buffer->i_pic_height = i_pic_height;
1617 for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
1620 intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d", p_pic,
1621 p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
1623 i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
1624 p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
1625 for( i_data_index = i_data_size / 256; i_data_index-- ; )
1627 /* Clear 256 bytes block */
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;
1631 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1632 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1633 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1634 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1635 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1637 for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
1639 /* Clear remaining 16 bytes blocks */
1640 *p_data++ = 0; *p_data++ = 0;
1642 p_data8 = (byte_t *)p_data;
1643 for( i_data_index = i_data_size % 16; i_data_index--; )
1645 /* Clear remaining bytes */
1653 p_buffer->i_areas = 0;
1656 /*****************************************************************************
1657 * RenderPicture: render a picture
1658 *****************************************************************************
1659 * This function converts a picture from a video heap to a pixel-encoded image
1660 * and copies it to the current rendering buffer. No lock is required, since
1661 * the * rendered picture has been determined as existant, and will only be
1662 * destroyed by the vout thread later.
1663 *****************************************************************************/
1664 static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
1667 char psz_date[MSTRTIME_MAX_SIZE]; /* picture date */
1668 mtime_t render_time; /* picture rendering time */
1670 vout_buffer_t * p_buffer; /* rendering buffer */
1671 byte_t * p_pic_data; /* convertion destination */
1673 /* Get and set rendering information */
1674 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1675 p_pic_data = p_buffer->p_data +
1676 p_buffer->i_pic_x * p_vout->i_bytes_per_pixel +
1677 p_buffer->i_pic_y * p_vout->i_bytes_per_line;
1679 render_time = mdate();
1685 * Choose appropriate rendering function and render picture
1687 switch( p_pic->i_type )
1689 case YUV_420_PICTURE:
1690 p_vout->yuv.pf_yuv420( p_vout, p_pic_data,
1691 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1692 p_pic->i_width, p_pic->i_height,
1693 p_buffer->i_pic_width, p_buffer->i_pic_height,
1694 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1695 p_pic->i_matrix_coefficients );
1697 case YUV_422_PICTURE:
1698 p_vout->yuv.pf_yuv422( p_vout, p_pic_data,
1699 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1700 p_pic->i_width, p_pic->i_height,
1701 p_buffer->i_pic_width, p_buffer->i_pic_height,
1702 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1703 p_pic->i_matrix_coefficients );
1705 case YUV_444_PICTURE:
1706 p_vout->yuv.pf_yuv444( p_vout, p_pic_data,
1707 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1708 p_pic->i_width, p_pic->i_height,
1709 p_buffer->i_pic_width, p_buffer->i_pic_height,
1710 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1711 p_pic->i_matrix_coefficients );
1715 intf_DbgMsg("error: unknown picture type %d", p_pic->i_type );
1721 /* Print picture date and rendering time */
1722 intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s", p_pic,
1723 p_vout->i_buffer_index, (long) (mdate() - render_time),
1724 mstrtime( psz_date, p_pic->date ));
1728 /*****************************************************************************
1729 * RenderPictureInfo: print additionnal information on a picture
1730 *****************************************************************************
1731 * This function will print information such as fps and other picture
1732 * dependant information.
1733 *****************************************************************************/
1734 static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
1736 char psz_buffer[256]; /* string buffer */
1739 * Print FPS rate in upper right corner
1741 if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
1743 long i_fps = VOUT_FPS_SAMPLES * 1000000 * 10 /
1744 ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1)
1745 % VOUT_FPS_SAMPLES ] -
1746 p_vout->p_fps_sample[ p_vout->c_fps_samples
1747 % VOUT_FPS_SAMPLES ] );
1748 sprintf( psz_buffer, "%li.%i fps", i_fps / 10, (int)i_fps % 10 );
1749 Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
1753 * Print frames count and loop time in upper left corner
1755 sprintf( psz_buffer, "%ld frames, render: %ldus",
1756 (long) p_vout->c_fps_samples, (long) p_vout->render_time );
1757 Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
1761 * Print picture information in lower right corner
1763 sprintf( psz_buffer, "%s picture %dx%d (%dx%d%+d%+d %s) -> %dx%d+%d+%d",
1764 (p_pic->i_type == YUV_420_PICTURE) ? "4:2:0" :
1765 ((p_pic->i_type == YUV_422_PICTURE) ? "4:2:2" :
1766 ((p_pic->i_type == YUV_444_PICTURE) ? "4:4:4" : "ukn-type")),
1767 p_pic->i_width, p_pic->i_height,
1768 p_pic->i_display_width, p_pic->i_display_height,
1769 p_pic->i_display_horizontal_offset, p_pic->i_display_vertical_offset,
1770 (p_pic->i_aspect_ratio == AR_SQUARE_PICTURE) ? "sq" :
1771 ((p_pic->i_aspect_ratio == AR_3_4_PICTURE) ? "4:3" :
1772 ((p_pic->i_aspect_ratio == AR_16_9_PICTURE) ? "16:9" :
1773 ((p_pic->i_aspect_ratio == AR_221_1_PICTURE) ? "2.21:1" : "ukn-ar" ))),
1774 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_width,
1775 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height,
1776 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_x,
1777 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y );
1778 Print( p_vout, 0, 0, RIGHT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1782 /*****************************************************************************
1783 * RenderSplash: render splash picture
1784 *****************************************************************************
1785 * This function will print something on the screen. It will return 0 if
1786 * nothing has been rendered, or 1 if something has been changed on the screen.
1787 * Note that if you absolutely want something to be printed, you will have
1788 * to force it by setting the last idle date to 0.
1789 * Unlike other rendering functions, this one calls the SetBufferPicture
1790 * function when needed.
1791 *****************************************************************************/
1792 int RenderSplash( vout_thread_t *p_vout )
1794 int i_x = 0, i_y = 0; /* text position */
1795 int i_width, i_height; /* text size */
1796 char *psz_text = "VideoLAN Client (" VERSION ")"; /* text to display */
1798 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1799 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1801 // SetBufferPicture( p_vout, NULL );
1802 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1803 &i_width, &i_height );
1804 if( !Align( p_vout, &i_x, &i_y, i_width, i_height, CENTER_RALIGN, CENTER_RALIGN ) )
1806 vout_Print( p_vout->p_large_font,
1807 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1808 i_x * p_vout->i_bytes_per_pixel + (i_y - 16 ) * p_vout->i_bytes_per_line,
1809 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1810 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1811 WIDE_TEXT | OUTLINED_TEXT, psz_text, 100);
1812 SetBufferArea( p_vout, i_x, i_y, i_width, i_height);
1818 /*****************************************************************************
1819 * RenderIdle: render idle picture
1820 *****************************************************************************
1821 * This function will print something on the screen. It will return 0 if
1822 * nothing has been rendered, or 1 if something has been changed on the screen.
1823 * Note that if you absolutely want something to be printed, you will have
1824 * to force it by setting the last idle date to 0.
1825 * Unlike other rendering functions, this one calls the SetBufferPicture
1826 * function when needed.
1827 *****************************************************************************/
1828 int RenderIdle( vout_thread_t *p_vout )
1831 int i_x = 0, i_y = 0; /* text position */
1832 int i_width, i_height; /* text size */
1833 int i_amount = 0; /* amount to draw */
1834 char *psz_text = "Waiting for stream"; /* text to display */
1835 char *psz_wtext = "[................]";
1837 mtime_t current_date; /* current date */
1840 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1841 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1844 current_date = mdate();
1845 if( (current_date - p_vout->last_display_date) > VOUT_IDLE_DELAY
1846 // && (current_date - p_vout->last_idle_date) > VOUT_IDLE_DELAY
1849 /* FIXME: idle screen disabled */
1851 SetBufferPicture( p_vout, NULL );
1852 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1853 &i_width, &i_height );
1854 if( !Align( p_vout, &i_x, &i_y, i_width, i_height * 2, CENTER_RALIGN, CENTER_RALIGN ) )
1856 i_amount = (int) ((current_date - p_vout->last_display_date ) / 5000LL);
1857 vout_Print( p_vout->p_large_font,
1858 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1859 i_x * p_vout->i_bytes_per_pixel + i_y * p_vout->i_bytes_per_line,
1860 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1861 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1862 WIDE_TEXT | OUTLINED_TEXT, psz_text, (i_amount / 3 ) %110);
1864 vout_Print( p_vout->p_large_font,
1865 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1866 i_x * p_vout->i_bytes_per_pixel + (i_y + 16) * p_vout->i_bytes_per_line,
1867 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1868 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1869 WIDE_TEXT | OUTLINED_TEXT, psz_wtext, (i_amount/5)%110 );
1872 SetBufferArea( p_vout, i_x, i_y, i_width, i_height * 2 );
1880 /*****************************************************************************
1881 * RenderInfo: render additionnal information
1882 *****************************************************************************
1883 * This function renders information which do not depend on the current
1885 *****************************************************************************/
1886 static void RenderInfo( vout_thread_t *p_vout )
1889 char psz_buffer[256]; /* string buffer */
1890 int i_ready_pic = 0; /* ready pictures */
1891 int i_reserved_pic = 0; /* reserved pictures */
1892 int i_picture; /* picture index */
1897 * Print thread state in lower left corner
1899 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
1901 switch( p_vout->p_picture[i_picture].i_status )
1903 case RESERVED_PICTURE:
1904 case RESERVED_DATED_PICTURE:
1905 case RESERVED_DISP_PICTURE:
1913 sprintf( psz_buffer, "pic: %d (%d/%d)/%d",
1914 p_vout->i_pictures, i_reserved_pic, i_ready_pic, VOUT_MAX_PICTURES );
1915 Print( p_vout, 0, 0, LEFT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1919 /*****************************************************************************
1920 * RenderSubPicture: render a subpicture
1921 *****************************************************************************
1922 * This function renders a sub picture unit.
1923 *****************************************************************************/
1924 static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
1926 p_vout_font_t p_font; /* text font */
1927 int i_width, i_height; /* subpicture dimensions */
1929 while( p_subpic != NULL )
1931 switch( p_subpic->i_type )
1933 case DVD_SUBPICTURE: /* DVD subpicture unit */
1934 /* test if the picture really has to be displayed */
1935 if( mdate() < p_subpic->begin_date )
1937 /* not yet, see you later */
1940 if( mdate() > p_subpic->end_date )
1942 /* too late, destroying the subpic */
1943 vout_DestroySubPicture( p_vout, p_subpic );
1946 vout_RenderSPU( &p_vout->p_buffer[ p_vout->i_buffer_index ],
1947 p_subpic, p_vout->i_bytes_per_pixel,
1948 p_vout->i_bytes_per_line );
1950 case TEXT_SUBPICTURE: /* single line text */
1951 /* Select default font if not specified */
1952 p_font = p_subpic->type.text.p_font;
1953 if( p_font == NULL )
1955 p_font = p_vout->p_default_font;
1958 /* Compute text size (width and height fields are ignored)
1960 vout_TextSize( p_font, p_subpic->type.text.i_style,
1961 p_subpic->p_data, &i_width, &i_height );
1962 if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y,
1963 i_width, i_height, p_subpic->i_horizontal_align,
1964 p_subpic->i_vertical_align ) )
1967 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1968 p_subpic->i_x * p_vout->i_bytes_per_pixel +
1969 p_subpic->i_y * p_vout->i_bytes_per_line,
1970 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1971 p_subpic->type.text.i_char_color,
1972 p_subpic->type.text.i_border_color,
1973 p_subpic->type.text.i_bg_color,
1974 p_subpic->type.text.i_style, p_subpic->p_data, 100 );
1975 SetBufferArea( p_vout, p_subpic->i_x, p_subpic->i_y,
1976 i_width, i_height );
1982 intf_DbgMsg( "error: unknown subpicture %p type %d",
1983 p_subpic, p_subpic->i_type );
1987 p_subpic = p_subpic->p_next;
1991 /*****************************************************************************
1992 * RenderInterface: render the interface
1993 *****************************************************************************
1994 * This function renders the interface, if any.
1995 *****************************************************************************/
1996 static void RenderInterface( vout_thread_t *p_vout )
1998 int i_height, i_text_height; /* total and text height */
1999 int i_width_1, i_width_2; /* text width */
2000 int i_byte; /* byte index */
2001 const char *psz_text_1 = "[1-9] Channel [i]nfo [c]olor [g/G]amma";
2002 const char *psz_text_2 = "[+/-] Volume [m]ute [s]caling [Q]uit";
2005 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_1, &i_width_1, &i_height );
2006 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_2, &i_width_2, &i_text_height );
2007 i_height += i_text_height;
2009 /* Render background */
2010 for( i_byte = (p_vout->i_height - i_height) * p_vout->i_bytes_per_line;
2011 i_byte < p_vout->i_height * p_vout->i_bytes_per_line;
2015 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = p_vout->i_blue_pixel;
2018 /* Render text, if not larger than screen */
2019 if( i_width_1 < p_vout->i_width )
2021 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2022 (p_vout->i_height - i_height) * p_vout->i_bytes_per_line,
2023 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2024 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2025 OUTLINED_TEXT, psz_text_1, 100 );
2027 if( i_width_2 < p_vout->i_width )
2029 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2030 (p_vout->i_height - i_height + i_text_height) * p_vout->i_bytes_per_line,
2031 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2032 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2033 OUTLINED_TEXT, psz_text_2, 100 );
2036 /* Activate modified area */
2037 SetBufferArea( p_vout, 0, p_vout->i_height - i_height, p_vout->i_width, i_height );
2040 /*****************************************************************************
2041 * Manage: manage thread
2042 *****************************************************************************
2043 * This function will handle changes in thread configuration.
2044 *****************************************************************************/
2045 static int Manage( vout_thread_t *p_vout )
2048 if( p_vout->i_changes )
2050 intf_DbgMsg("changes: 0x%x (no display: 0x%x)", p_vout->i_changes,
2051 0 /* p_vout->i_changes & VOUT_NODISPLAY_CHANGE */ );
2055 /* On gamma or grayscale change, rebuild tables */
2056 if( p_vout->i_changes & (VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2059 if( vout_ResetYUV( p_vout ) )
2061 intf_ErrMsg( "vout error: can't rebuild conversion tables" );
2066 /* Clear changes flags which does not need management or have been
2068 p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2069 VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
2070 VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE |
2071 VOUT_CURSOR_CHANGE | VOUT_FULLSCREEN_CHANGE );
2073 /* Detect unauthorized changes */
2074 if( p_vout->i_changes )
2076 /* Some changes were not acknowledged by p_vout->pf_manage or this
2077 * function, it means they should not be authorized */
2078 intf_ErrMsg( "vout error: unauthorized changes in the vout thread" );
2085 /*****************************************************************************
2086 * Align: align a subpicture in the screen
2087 *****************************************************************************
2088 * This function is used for rendering text or subpictures. It returns non 0
2089 * it the final aera is not fully included in display area. Return coordinates
2091 *****************************************************************************/
2092 static int Align( vout_thread_t *p_vout, int *pi_x, int *pi_y,
2093 int i_width, int i_height, int i_h_align, int i_v_align )
2095 /* Align horizontally */
2099 *pi_x -= i_width / 2;
2102 *pi_x += (p_vout->i_width - i_width) / 2;
2108 *pi_x += p_vout->i_width - i_width;
2112 /* Align vertically */
2116 *pi_y -= i_height / 2;
2119 *pi_y += (p_vout->i_height - i_height) / 2;
2125 *pi_y += p_vout->i_height - i_height;
2127 case SUBTITLE_RALIGN:
2128 *pi_y += (p_vout->i_height + p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y +
2129 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height - i_height) / 2;
2133 /* Return non 0 if clipping failed */
2134 return( (*pi_x < 0) || (*pi_y < 0) ||
2135 (*pi_x + i_width > p_vout->i_width) || (*pi_y + i_height > p_vout->i_height) );
2138 /*****************************************************************************
2139 * SetPalette: sets an 8 bpp palette
2140 *****************************************************************************
2141 * This function is just a prototype that does nothing. Architectures that
2142 * support palette allocation should override it.
2143 *****************************************************************************/
2144 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
2145 u16 *green, u16 *blue, u16 *transp )
2147 intf_ErrMsg( "vout error: method does not support palette changing" );