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.117 2001/03/21 13:42:34 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( p_main->p_bank,
113 MODULE_CAPABILITY_VOUT, NULL );
115 if( p_vout->p_module == NULL )
117 intf_ErrMsg( "vout error: no suitable vout module" );
122 #define f p_vout->p_module->p_functions->vout.functions.vout
123 p_vout->pf_create = f.pf_create;
124 p_vout->pf_init = f.pf_init;
125 p_vout->pf_end = f.pf_end;
126 p_vout->pf_destroy = f.pf_destroy;
127 p_vout->pf_manage = f.pf_manage;
128 p_vout->pf_display = f.pf_display;
129 p_vout->pf_setpalette = f.pf_setpalette;
132 if( p_vout->pf_setpalette == NULL )
134 p_vout->pf_setpalette = SetPalette;
137 /* Initialize thread properties - thread id and locks will be initialized
141 p_vout->b_active = 0;
142 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
143 *p_vout->pi_status = THREAD_CREATE;
145 /* Initialize some fields used by the system-dependant method - these
146 * fields will probably be modified by the method, and are only
148 p_vout->i_changes = 0;
149 p_vout->i_width = main_GetIntVariable( VOUT_WIDTH_VAR,
150 VOUT_WIDTH_DEFAULT );
151 p_vout->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR,
152 VOUT_HEIGHT_DEFAULT );
153 p_vout->i_bytes_per_line = p_vout->i_width * 2;
154 p_vout->i_screen_depth = 15;
155 p_vout->i_bytes_per_pixel = 2;
156 p_vout->f_gamma = VOUT_GAMMA;
157 p_vout->b_need_render = 1;
160 p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
161 VOUT_GRAYSCALE_DEFAULT );
163 p_vout->b_interface = 0;
166 intf_WarnMsg( 1, "wished configuration: %dx%d, %d/%d bpp (%d Bpl)",
167 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
168 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
170 /* Initialize idle screen */
171 p_vout->last_display_date = 0;
172 p_vout->last_idle_date = 0;
173 p_vout->init_display_date = mdate();
174 p_vout->render_time = 10000;
176 /* Initialize statistics fields */
177 p_vout->c_fps_samples = 0;
179 /* Initialize buffer index */
180 p_vout->i_buffer_index = 0;
182 /* Initialize pictures and subpictures - translation tables and functions
183 * will be initialized later in InitThread */
184 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
186 p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
187 p_vout->p_picture[i_index].i_status = FREE_PICTURE;
189 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
191 p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
192 p_vout->p_subpicture[i_index].i_status= FREE_SUBPICTURE;
194 p_vout->i_pictures = 0;
196 /* Create and initialize system-dependant method - this function issues its
197 * own error messages */
198 if( p_vout->pf_create( p_vout ) )
200 module_Unneed( p_main->p_bank, p_vout->p_module );
204 intf_WarnMsg( 1, "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
205 "masks: 0x%x/0x%x/0x%x",
206 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
207 p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
208 p_vout->i_red_mask, p_vout->i_green_mask,
209 p_vout->i_blue_mask );
211 /* Calculate shifts from system-updated masks */
212 MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
213 p_vout->i_red_mask );
214 MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
215 p_vout->i_green_mask );
216 MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
217 p_vout->i_blue_mask );
219 /* Set some useful colors */
220 p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
221 p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
222 p_vout->i_gray_pixel = RGB2PIXEL( p_vout, 128, 128, 128 );
223 p_vout->i_blue_pixel = RGB2PIXEL( p_vout, 0, 0, 50 );
225 /* Load fonts - fonts must be initialized after the system method since
226 * they may be dependant on screen depth and other thread properties */
227 p_vout->p_default_font = vout_LoadFont( VOUT_DEFAULT_FONT );
228 if( p_vout->p_default_font == NULL )
230 intf_ErrMsg( "vout error: could not load default font" );
231 p_vout->pf_destroy( p_vout );
236 p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
237 if( p_vout->p_large_font == NULL )
239 intf_ErrMsg( "vout error: could not load large font" );
240 vout_UnloadFont( p_vout->p_default_font );
241 p_vout->pf_destroy( p_vout );
246 /* Create thread and set locks */
247 vlc_mutex_init( &p_vout->picture_lock );
248 vlc_mutex_init( &p_vout->subpicture_lock );
249 vlc_mutex_init( &p_vout->change_lock );
251 if( vlc_thread_create( &p_vout->thread_id, "video output",
252 (void *) RunThread, (void *) p_vout) )
254 intf_ErrMsg("vout error: %s", strerror(ENOMEM));
255 vout_UnloadFont( p_vout->p_default_font );
256 vout_UnloadFont( p_vout->p_large_font );
257 p_vout->pf_destroy( p_vout );
262 intf_Msg( "vout: video display initialized (%dx%d, %d/%d bpp)",
263 p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
264 p_vout->i_bytes_per_pixel * 8 );
266 /* If status is NULL, wait until the thread is created */
267 if( pi_status == NULL )
271 msleep( THREAD_SLEEP );
272 }while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
273 && (i_status != THREAD_FATAL) );
274 if( i_status != THREAD_READY )
282 /*****************************************************************************
283 * vout_DestroyThread: destroys a previously created thread
284 *****************************************************************************
285 * Destroy a terminated thread.
286 * The function will request a destruction of the specified thread. If pi_error
287 * is NULL, it will return once the thread is destroyed. Else, it will be
288 * update using one of the THREAD_* constants.
289 *****************************************************************************/
290 void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
292 int i_status; /* thread status */
296 p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
297 *p_vout->pi_status = THREAD_DESTROY;
299 /* Request thread destruction */
302 /* If status is NULL, wait until thread has been destroyed */
303 if( pi_status == NULL )
307 msleep( THREAD_SLEEP );
308 }while( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
309 && (i_status != THREAD_FATAL) );
313 /*****************************************************************************
314 * vout_DisplaySubPicture: display a subpicture unit
315 *****************************************************************************
316 * Remove the reservation flag of an subpicture, which will cause it to be ready
317 * for display. The picture does not need to be locked, since it is ignored by
318 * the output thread if is reserved.
319 *****************************************************************************/
320 void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
323 char psz_begin_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
324 char psz_end_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
328 /* Check if status is valid */
329 if( p_subpic->i_status != RESERVED_SUBPICTURE )
331 intf_DbgMsg("error: subpicture %p has invalid status %d", p_subpic,
332 p_subpic->i_status );
336 /* Remove reservation flag */
337 p_subpic->i_status = READY_SUBPICTURE;
340 /* Send subpicture information */
341 intf_DbgMsg("subpicture %p: type=%d, begin date=%s, end date=%s",
342 p_subpic, p_subpic->i_type,
343 mstrtime( psz_begin_date, p_subpic->begin_date ),
344 mstrtime( psz_end_date, p_subpic->end_date ) );
348 /*****************************************************************************
349 * vout_CreateSubPicture: allocate a subpicture in the video output heap.
350 *****************************************************************************
351 * This function create a reserved subpicture in the video output heap.
352 * A null pointer is returned if the function fails. This method provides an
353 * already allocated zone of memory in the spu data fields. It needs locking
354 * since several pictures can be created by several producers threads.
355 *****************************************************************************/
356 subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
359 int i_subpic; /* subpicture index */
360 subpicture_t * p_free_subpic = NULL; /* first free subpicture */
361 subpicture_t * p_destroyed_subpic = NULL; /* first destroyed subpic */
364 vlc_mutex_lock( &p_vout->subpicture_lock );
367 * Look for an empty place
369 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
371 if( p_vout->p_subpicture[i_subpic].i_status == DESTROYED_SUBPICTURE )
373 /* Subpicture is marked for destruction, but is still allocated */
374 if( (p_vout->p_subpicture[i_subpic].i_type == i_type) &&
375 (p_vout->p_subpicture[i_subpic].i_size >= i_size) )
377 /* Memory size do match or is smaller : memory will not be
378 * reallocated, and function can end immediately - this is
379 * the best possible case, since no memory allocation needs
381 p_vout->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
383 intf_DbgMsg("subpicture %p (in destroyed subpicture slot)",
384 &p_vout->p_subpicture[i_subpic] );
386 vlc_mutex_unlock( &p_vout->subpicture_lock );
387 return( &p_vout->p_subpicture[i_subpic] );
389 else if( p_destroyed_subpic == NULL )
391 /* Memory size do not match, but subpicture index will be kept in
392 * case no other place are left */
393 p_destroyed_subpic = &p_vout->p_subpicture[i_subpic];
396 else if( (p_free_subpic == NULL) &&
397 (p_vout->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE ))
399 /* Subpicture is empty and ready for allocation */
400 p_free_subpic = &p_vout->p_subpicture[i_subpic];
404 /* If no free subpictures are available, use a destroyed subpicture */
405 if( (p_free_subpic == NULL) && (p_destroyed_subpic != NULL ) )
407 /* No free subpicture or matching destroyed subpictures have been
408 * found, but a destroyed subpicture is still avalaible */
409 free( p_destroyed_subpic->p_data );
410 p_free_subpic = p_destroyed_subpic;
416 if( p_free_subpic != NULL )
418 /* Allocate memory */
421 case TEXT_SUBPICTURE: /* text subpicture */
422 p_free_subpic->p_data = malloc( i_size + 1 );
424 case DVD_SUBPICTURE: /* DVD subpicture unit */
425 p_free_subpic->p_data = malloc( i_size );
429 intf_DbgMsg("error: unknown subpicture type %d", i_type );
430 p_free_subpic->p_data = NULL;
435 if( p_free_subpic->p_data != NULL )
437 /* Copy subpicture information, set some default values */
438 p_free_subpic->i_type = i_type;
439 p_free_subpic->i_status = RESERVED_SUBPICTURE;
440 p_free_subpic->i_size = i_size;
441 p_free_subpic->i_x = 0;
442 p_free_subpic->i_y = 0;
443 p_free_subpic->i_width = 0;
444 p_free_subpic->i_height = 0;
445 p_free_subpic->i_horizontal_align = CENTER_RALIGN;
446 p_free_subpic->i_vertical_align = CENTER_RALIGN;
450 /* Memory allocation failed : set subpicture as empty */
451 p_free_subpic->i_type = EMPTY_SUBPICTURE;
452 p_free_subpic->i_status = FREE_SUBPICTURE;
453 p_free_subpic = NULL;
454 intf_ErrMsg( "vout error: spu allocation returned %s",
455 strerror( ENOMEM ) );
459 intf_DbgMsg("subpicture %p (in free subpicture slot)", p_free_subpic );
461 vlc_mutex_unlock( &p_vout->subpicture_lock );
462 return( p_free_subpic );
465 /* No free or destroyed subpicture could be found */
466 intf_DbgMsg( "warning: subpicture heap is full" );
467 vlc_mutex_unlock( &p_vout->subpicture_lock );
471 /*****************************************************************************
472 * vout_DestroySubPicture: remove a subpicture from the heap
473 *****************************************************************************
474 * This function frees a previously reserved subpicture.
475 * It is meant to be used when the construction of a picture aborted.
476 * This function does not need locking since reserved subpictures are ignored
477 * by the output thread.
478 *****************************************************************************/
479 void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
482 /* Check if status is valid */
483 if( p_subpic->i_status != RESERVED_SUBPICTURE )
485 intf_DbgMsg("error: subpicture %p has invalid status %d",
486 p_subpic, p_subpic->i_status );
490 p_subpic->i_status = DESTROYED_SUBPICTURE;
493 intf_DbgMsg("subpicture %p", p_subpic);
497 /*****************************************************************************
498 * vout_DisplayPicture: display a picture
499 *****************************************************************************
500 * Remove the reservation flag of a picture, which will cause it to be ready for
501 * display. The picture won't be displayed until vout_DatePicture has been
503 *****************************************************************************/
504 void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
506 vlc_mutex_lock( &p_vout->picture_lock );
507 switch( p_pic->i_status )
509 case RESERVED_PICTURE:
510 p_pic->i_status = RESERVED_DISP_PICTURE;
512 case RESERVED_DATED_PICTURE:
513 p_pic->i_status = READY_PICTURE;
517 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
523 intf_DbgMsg("picture %p", p_pic);
525 vlc_mutex_unlock( &p_vout->picture_lock );
528 /*****************************************************************************
529 * vout_DatePicture: date a picture
530 *****************************************************************************
531 * Remove the reservation flag of a picture, which will cause it to be ready for
532 * display. The picture won't be displayed until vout_DisplayPicture has been
534 *****************************************************************************/
535 void vout_DatePicture( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date )
538 char psz_date[MSTRTIME_MAX_SIZE]; /* date */
541 vlc_mutex_lock( &p_vout->picture_lock );
543 switch( p_pic->i_status )
545 case RESERVED_PICTURE:
546 p_pic->i_status = RESERVED_DATED_PICTURE;
548 case RESERVED_DISP_PICTURE:
549 p_pic->i_status = READY_PICTURE;
553 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
559 intf_DbgMsg("picture %p, display date: %s", p_pic, mstrtime( psz_date, p_pic->date) );
561 vlc_mutex_unlock( &p_vout->picture_lock );
564 /*****************************************************************************
565 * vout_CreatePicture: allocate a picture in the video output heap.
566 *****************************************************************************
567 * This function create a reserved image in the video output heap.
568 * A null pointer is returned if the function fails. This method provides an
569 * already allocated zone of memory in the picture data fields. It needs locking
570 * since several pictures can be created by several producers threads.
571 *****************************************************************************/
572 picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
573 int i_width, int i_height )
575 int i_picture; /* picture index */
576 int i_chroma_width = 0; /* chroma width */
577 picture_t * p_free_picture = NULL; /* first free picture */
578 picture_t * p_destroyed_picture = NULL; /* first destroyed picture */
581 vlc_mutex_lock( &p_vout->picture_lock );
584 * Look for an empty place
586 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
588 if( p_vout->p_picture[i_picture].i_status == DESTROYED_PICTURE )
590 /* Picture is marked for destruction, but is still allocated - note
591 * that if width and type are the same for two pictures, chroma_width
592 * should also be the same */
593 if( (p_vout->p_picture[i_picture].i_type == i_type) &&
594 (p_vout->p_picture[i_picture].i_height == i_height) &&
595 (p_vout->p_picture[i_picture].i_width == i_width) )
597 /* Memory size do match : memory will not be reallocated, and function
598 * can end immediately - this is the best possible case, since no
599 * memory allocation needs to be done */
600 p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
601 p_vout->i_pictures++;
603 intf_DbgMsg("picture %p (in destroyed picture slot)",
604 &p_vout->p_picture[i_picture] );
606 vlc_mutex_unlock( &p_vout->picture_lock );
607 return( &p_vout->p_picture[i_picture] );
609 else if( p_destroyed_picture == NULL )
611 /* Memory size do not match, but picture index will be kept in
612 * case no other place are left */
613 p_destroyed_picture = &p_vout->p_picture[i_picture];
616 else if( (p_free_picture == NULL) &&
617 (p_vout->p_picture[i_picture].i_status == FREE_PICTURE ))
619 /* Picture is empty and ready for allocation */
620 p_free_picture = &p_vout->p_picture[i_picture];
624 /* If no free picture is available, use a destroyed picture */
625 if( (p_free_picture == NULL) && (p_destroyed_picture != NULL ) )
627 /* No free picture or matching destroyed picture has been found, but
628 * a destroyed picture is still avalaible */
629 free( p_destroyed_picture->p_data );
630 p_free_picture = p_destroyed_picture;
636 if( p_free_picture != NULL )
638 /* Allocate memory */
641 case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
642 i_chroma_width = i_width / 2;
643 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
644 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
645 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*4/2;
646 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*5/2;
648 case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
649 i_chroma_width = i_width / 2;
650 p_free_picture->p_data = malloc( i_height * i_chroma_width * 4 * sizeof( yuv_data_t ) );
651 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
652 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
653 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*3;
655 case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
656 i_chroma_width = i_width;
657 p_free_picture->p_data = malloc( i_height * i_chroma_width * 3 * sizeof( yuv_data_t ) );
658 p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
659 p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width;
660 p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
664 intf_DbgMsg("error: unknown picture type %d", i_type );
665 p_free_picture->p_data = NULL;
670 if( p_free_picture->p_data != NULL )
672 /* Copy picture information, set some default values */
673 p_free_picture->i_type = i_type;
674 p_free_picture->i_status = RESERVED_PICTURE;
675 p_free_picture->i_matrix_coefficients = 1;
676 p_free_picture->i_width = i_width;
677 p_free_picture->i_height = i_height;
678 p_free_picture->i_chroma_width = i_chroma_width;
679 p_free_picture->i_size = i_width * i_height;
680 p_free_picture->i_chroma_size = i_chroma_width
682 p_free_picture->i_display_horizontal_offset = 0;
683 p_free_picture->i_display_vertical_offset = 0;
684 p_free_picture->i_display_width = i_width;
685 p_free_picture->i_display_height = i_height;
686 p_free_picture->i_aspect_ratio = AR_SQUARE_PICTURE;
687 p_free_picture->i_refcount = 0;
688 p_vout->i_pictures++;
692 /* Memory allocation failed : set picture as empty */
693 p_free_picture->i_type = EMPTY_PICTURE;
694 p_free_picture->i_status = FREE_PICTURE;
695 p_free_picture = NULL;
696 intf_ErrMsg( "vout error: picture allocation returned %s",
697 strerror( ENOMEM ) );
701 intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
703 vlc_mutex_unlock( &p_vout->picture_lock );
705 /* Initialize mutex */
706 vlc_mutex_init( &(p_free_picture->lock_deccount) );
708 return( p_free_picture );
711 /* No free or destroyed picture could be found */
712 intf_DbgMsg( "warning: picture heap is full" );
713 vlc_mutex_unlock( &p_vout->picture_lock );
717 /*****************************************************************************
718 * vout_DestroyPicture: remove a permanent or reserved picture from the heap
719 *****************************************************************************
720 * This function frees a previously reserved picture or a permanent
721 * picture. It is meant to be used when the construction of a picture aborted.
722 * Note that the picture will be destroyed even if it is linked !
723 *****************************************************************************/
724 void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
726 vlc_mutex_lock( &p_vout->picture_lock );
729 /* Check if picture status is valid */
730 if( (p_pic->i_status != RESERVED_PICTURE) &&
731 (p_pic->i_status != RESERVED_DATED_PICTURE) &&
732 (p_pic->i_status != RESERVED_DISP_PICTURE) )
734 intf_DbgMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
738 p_pic->i_status = DESTROYED_PICTURE;
739 p_vout->i_pictures--;
742 intf_DbgMsg("picture %p", p_pic);
745 /* destroy the lock that had been initialized in CreatePicture */
746 vlc_mutex_destroy( &(p_pic->lock_deccount) );
748 vlc_mutex_unlock( &p_vout->picture_lock );
751 /*****************************************************************************
752 * vout_LinkPicture: increment reference counter of a picture
753 *****************************************************************************
754 * This function increment the reference counter of a picture in the video
755 * heap. It needs a lock since several producer threads can access the picture.
756 *****************************************************************************/
757 void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
759 vlc_mutex_lock( &p_vout->picture_lock );
763 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
766 vlc_mutex_unlock( &p_vout->picture_lock );
769 /*****************************************************************************
770 * vout_UnlinkPicture: decrement reference counter of a picture
771 *****************************************************************************
772 * This function decrement the reference counter of a picture in the video heap.
773 *****************************************************************************/
774 void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
776 vlc_mutex_lock( &p_vout->picture_lock );
780 if( p_pic->i_refcount < 0 )
782 intf_DbgMsg("error: refcount < 0");
783 p_pic->i_refcount = 0;
787 if( (p_pic->i_refcount == 0) && (p_pic->i_status == DISPLAYED_PICTURE) )
789 p_pic->i_status = DESTROYED_PICTURE;
790 p_vout->i_pictures--;
794 intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
797 vlc_mutex_unlock( &p_vout->picture_lock );
800 /*****************************************************************************
801 * vout_SetBuffers: set buffers adresses
802 *****************************************************************************
803 * This function is called by system drivers to set buffers video memory
805 *****************************************************************************/
806 void vout_SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
808 /* No picture previously */
809 p_vout->p_buffer[0].i_pic_x = 0;
810 p_vout->p_buffer[0].i_pic_y = 0;
811 p_vout->p_buffer[0].i_pic_width = 0;
812 p_vout->p_buffer[0].i_pic_height = 0;
813 p_vout->p_buffer[1].i_pic_x = 0;
814 p_vout->p_buffer[1].i_pic_y = 0;
815 p_vout->p_buffer[1].i_pic_width = 0;
816 p_vout->p_buffer[1].i_pic_height = 0;
818 /* The first area covers all the screen */
819 p_vout->p_buffer[0].i_areas = 1;
820 p_vout->p_buffer[0].pi_area_begin[0] = 0;
821 p_vout->p_buffer[0].pi_area_end[0] = p_vout->i_height - 1;
822 p_vout->p_buffer[1].i_areas = 1;
823 p_vout->p_buffer[1].pi_area_begin[0] = 0;
824 p_vout->p_buffer[1].pi_area_end[0] = p_vout->i_height - 1;
827 p_vout->p_buffer[0].p_data = p_buf1;
828 p_vout->p_buffer[1].p_data = p_buf2;
831 /*****************************************************************************
832 * vout_Pixel2RGB: return red, green and blue from pixel value
833 *****************************************************************************
834 * Return color values, in 0-255 range, of the decomposition of a pixel. This
835 * is a slow routine and should only be used for initialization phase.
836 *****************************************************************************/
837 void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
839 *pi_red = i_pixel & p_vout->i_red_mask;
840 *pi_green = i_pixel & p_vout->i_green_mask;
841 *pi_blue = i_pixel & p_vout->i_blue_mask;
844 /* following functions are local */
846 /*****************************************************************************
847 * BinaryLog: computes the base 2 log of a binary value
848 *****************************************************************************
849 * This functions is used by MaskToShift, to get a bit index from a binary
851 *****************************************************************************/
852 static int BinaryLog(u32 i)
877 if (i != ((u32)1 << i_log))
879 intf_DbgMsg("internal error: binary log overflow");
885 /*****************************************************************************
886 * MaskToShift: transform a color mask into right and left shifts
887 *****************************************************************************
888 * This function is used for obtaining color shifts from masks.
889 *****************************************************************************/
890 static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
892 u32 i_low, i_high; /* lower hand higher bits of the mask */
895 i_low = i_mask & (- i_mask); /* lower bit of the mask */
896 i_high = i_mask + i_low; /* higher bit of the mask */
898 /* Transform bits into an index */
899 i_low = BinaryLog (i_low);
900 i_high = BinaryLog (i_high);
902 /* Update pointers and return */
904 *pi_right = (8 - i_high + i_low);
907 /*****************************************************************************
908 * InitThread: initialize video output thread
909 *****************************************************************************
910 * This function is called from RunThread and performs the second step of the
911 * initialization. It returns 0 on success. Note that the thread's flag are not
912 * modified inside this function.
913 *****************************************************************************/
914 static int InitThread( vout_thread_t *p_vout )
917 *p_vout->pi_status = THREAD_START;
919 vlc_mutex_lock( &p_vout->change_lock );
925 /* Initialize output method - this function issues its own error messages */
926 if( p_vout->pf_init( p_vout ) )
931 /* Initialize convertion tables and functions */
932 if( vout_InitYUV( p_vout ) )
934 intf_ErrMsg("vout error: can't allocate YUV translation tables");
938 /* Mark thread as running and return */
939 p_vout->b_active = 1;
940 *p_vout->pi_status = THREAD_READY;
943 intf_DbgMsg("thread ready");
947 /*****************************************************************************
948 * RunThread: video output thread
949 *****************************************************************************
950 * Video output thread. This function does only returns when the thread is
951 * terminated. It handles the pictures arriving in the video heap and the
952 * display device events.
953 *****************************************************************************/
954 static void RunThread( vout_thread_t *p_vout)
956 int i_index; /* index in heap */
957 mtime_t current_date; /* current date */
958 mtime_t display_date; /* display date */
959 boolean_t b_display; /* display flag */
960 picture_t * p_pic; /* picture pointer */
961 subpicture_t * p_subpic; /* subpicture pointer */
966 p_vout->b_error = InitThread( p_vout );
967 if( p_vout->b_error )
969 DestroyThread( p_vout, THREAD_ERROR );
974 * Main loop - it is not executed if an error occured during
977 while( (!p_vout->b_die) && (!p_vout->b_error) )
979 /* Initialize loop variables */
983 current_date = mdate();
986 if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
988 intf_Msg("vout stats: picture heap: %d/%d",
989 p_vout->i_pictures, VOUT_MAX_PICTURES);
994 * Find the picture to display - this operation does not need lock,
995 * since only READY_PICTUREs are handled
997 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
999 if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) &&
1000 ( (p_pic == NULL) ||
1001 (p_vout->p_picture[i_index].date < display_date) ) )
1003 p_pic = &p_vout->p_picture[i_index];
1004 display_date = p_pic->date;
1010 /* Computes FPS rate */
1011 p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ] = display_date;
1013 if( display_date < current_date - p_vout->render_time )
1015 /* Picture is late: it will be destroyed and the thread
1016 * will sleep and go to next picture */
1018 vlc_mutex_lock( &p_vout->picture_lock );
1019 if( p_pic->i_refcount )
1021 p_pic->i_status = DISPLAYED_PICTURE;
1025 p_pic->i_status = DESTROYED_PICTURE;
1026 p_vout->i_pictures--;
1029 "warning: late picture skipped (%p)", p_pic );
1030 vlc_mutex_unlock( &p_vout->picture_lock );
1034 else if( display_date > current_date + VOUT_DISPLAY_DELAY )
1036 /* A picture is ready to be rendered, but its rendering date
1037 * is far from the current one so the thread will perform an
1038 * empty loop as if no picture were found. The picture state
1045 * Find the subpictures to display - this operation does not need
1046 * lock, since only READY_SUBPICTURE are handled. If no picture
1047 * has been selected, display_date will depend on the subpicture.
1048 * We get an easily parsable chained list of subpictures which
1049 * ends with NULL since p_subpic was initialized to NULL.
1051 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1053 if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
1055 p_vout->p_subpicture[i_index].p_next = p_subpic;
1056 p_subpic = &p_vout->p_subpicture[i_index];
1061 * Perform rendering, sleep and display rendered picture
1063 if( p_pic ) /* picture and perhaps subpicture */
1065 b_display = p_vout->b_active;
1066 p_vout->last_display_date = display_date;
1067 p_vout->p_rendered_pic = p_pic;
1072 /* Set picture dimensions and clear buffer */
1073 SetBufferPicture( p_vout, p_pic );
1075 /* FIXME: if b_need_render == 0 we need to do something with
1076 * the subpictures one day. */
1078 if( p_vout->b_need_render && b_display )
1080 /* Render picture and information */
1081 RenderPicture( p_vout, p_pic );
1082 if( p_vout->b_info )
1084 RenderPictureInfo( p_vout, p_pic );
1085 RenderInfo( p_vout );
1089 RenderSubPicture( p_vout, p_subpic );
1093 /* Render interface and subpicture */
1094 if( b_display && p_vout->b_interface && p_vout->b_need_render )
1096 RenderInterface( p_vout );
1100 else if( p_vout->b_active && p_vout->b_need_render
1101 && p_vout->init_display_date == 0)
1103 /* Idle or interface screen alone */
1105 if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
1107 /* Interface has changed, so a new rendering is required - force
1108 * it by setting last idle date to 0 */
1109 p_vout->last_idle_date = 0;
1112 /* Render idle screen and update idle date, then render interface if
1114 b_display = RenderIdle( p_vout );
1117 p_vout->last_idle_date = current_date;
1118 if( p_vout->b_interface )
1120 RenderInterface( p_vout );
1132 * Check for the current time and
1133 * display splash screen if everything is on time
1135 if( p_vout->init_display_date > 0 && p_vout->b_need_render )
1137 if( p_vout->b_active &&
1138 mdate()-p_vout->init_display_date < 5000000)
1140 /* there is something to display ! */
1142 RenderSplash( p_vout );
1145 /* no splash screen ! */
1146 p_vout->init_display_date=0;
1152 * Sleep, wake up and display rendered picture
1155 if( display_date != 0 )
1157 /* Store render time using Bresenham algorithm */
1158 p_vout->render_time += mdate() - current_date;
1159 p_vout->render_time >>= 1;
1162 /* Give back change lock */
1163 vlc_mutex_unlock( &p_vout->change_lock );
1165 /* Sleep a while or until a given date */
1166 if( display_date != 0 )
1168 mwait( display_date - VOUT_MWAIT_TOLERANCE );
1172 msleep( VOUT_IDLE_SLEEP );
1175 /* On awakening, take back lock and send immediately picture to display,
1176 * then swap buffers */
1177 vlc_mutex_lock( &p_vout->change_lock );
1179 intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d", p_pic, p_subpic,
1180 p_vout->i_buffer_index, b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ );
1182 if( b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ )
1184 p_vout->pf_display( p_vout );
1186 p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;
1192 /* Remove picture from heap */
1193 vlc_mutex_lock( &p_vout->picture_lock );
1194 if( p_pic->i_refcount )
1196 p_pic->i_status = DISPLAYED_PICTURE;
1200 p_pic->i_status = DESTROYED_PICTURE;
1201 p_vout->i_pictures--;
1203 vlc_mutex_unlock( &p_vout->picture_lock );
1208 * Check events and manage thread
1210 if( p_vout->pf_manage( p_vout ) | Manage( p_vout ) )
1212 /* A fatal error occured, and the thread must terminate immediately,
1213 * without displaying anything - setting b_error to 1 cause the
1214 * immediate end of the main while() loop. */
1215 p_vout->b_error = 1;
1220 * Error loop - wait until the thread destruction is requested
1222 if( p_vout->b_error )
1224 ErrorThread( p_vout );
1228 EndThread( p_vout );
1229 DestroyThread( p_vout, THREAD_OVER );
1230 intf_DbgMsg( "thread end" );
1233 /*****************************************************************************
1234 * ErrorThread: RunThread() error loop
1235 *****************************************************************************
1236 * This function is called when an error occured during thread main's loop. The
1237 * thread can still receive feed, but must be ready to terminate as soon as
1239 *****************************************************************************/
1240 static void ErrorThread( vout_thread_t *p_vout )
1242 /* Wait until a `die' order */
1243 while( !p_vout->b_die )
1246 msleep( VOUT_IDLE_SLEEP );
1250 /*****************************************************************************
1251 * EndThread: thread destruction
1252 *****************************************************************************
1253 * This function is called when the thread ends after a sucessful
1254 * initialization. It frees all ressources allocated by InitThread.
1255 *****************************************************************************/
1256 static void EndThread( vout_thread_t *p_vout )
1258 int i_index; /* index in heap */
1261 *p_vout->pi_status = THREAD_END;
1265 struct tms cpu_usage;
1266 times( &cpu_usage );
1268 intf_Msg( "vout stats: cpu usage (user: %d, system: %d)",
1269 cpu_usage.tms_utime, cpu_usage.tms_stime );
1273 /* Destroy all remaining pictures and subpictures */
1274 for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
1276 if( p_vout->p_picture[i_index].i_status != FREE_PICTURE )
1278 free( p_vout->p_picture[i_index].p_data );
1282 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1284 if( p_vout->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
1286 free( p_vout->p_subpicture[i_index].p_data );
1290 /* Destroy translation tables */
1291 vout_EndYUV( p_vout );
1292 p_vout->pf_end( p_vout );
1294 /* Release the change lock */
1295 vlc_mutex_unlock( &p_vout->change_lock );
1298 /*****************************************************************************
1299 * DestroyThread: thread destruction
1300 *****************************************************************************
1301 * This function is called when the thread ends. It frees all ressources
1302 * allocated by CreateThread. Status is available at this stage.
1303 *****************************************************************************/
1304 static void DestroyThread( vout_thread_t *p_vout, int i_status )
1306 int *pi_status; /* status adress */
1308 /* Store status adress */
1309 pi_status = p_vout->pi_status;
1311 /* Destroy thread structures allocated by Create and InitThread */
1312 vout_UnloadFont( p_vout->p_default_font );
1313 vout_UnloadFont( p_vout->p_large_font );
1314 p_vout->pf_destroy( p_vout );
1316 /* Destroy the locks */
1317 vlc_mutex_destroy( &p_vout->picture_lock );
1318 vlc_mutex_destroy( &p_vout->subpicture_lock );
1319 vlc_mutex_destroy( &p_vout->change_lock );
1321 /* Release the module */
1322 module_Unneed( p_main->p_bank, p_vout->p_module );
1324 /* Free structure */
1326 *pi_status = i_status;
1329 /*****************************************************************************
1330 * Print: print simple text on a picture
1331 *****************************************************************************
1332 * This function will print a simple text on the picture. It is designed to
1333 * print debugging or general information.
1334 *****************************************************************************/
1335 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 )
1337 int i_text_height; /* total text height */
1338 int i_text_width; /* total text width */
1340 /* Update upper left coordinates according to alignment */
1341 vout_TextSize( p_vout->p_default_font, 0, psz_text, &i_text_width, &i_text_height );
1342 if( !Align( p_vout, &i_x, &i_y, i_text_width, i_text_height, i_h_align, i_v_align ) )
1344 /* Set area and print text */
1345 SetBufferArea( p_vout, i_x, i_y, i_text_width, i_text_height );
1346 vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1347 i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
1348 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1349 p_vout->i_white_pixel, 0, 0,
1354 /*****************************************************************************
1355 * SetBufferArea: activate an area in current buffer
1356 *****************************************************************************
1357 * This function is called when something is rendered on the current buffer.
1358 * It set the area as active and prepare it to be cleared on next rendering.
1359 * Pay attention to the fact that in this functions, i_h is in fact the end y
1360 * coordinate of the new area.
1361 *****************************************************************************/
1362 static void SetBufferArea( vout_thread_t *p_vout, int i_x, int i_y, int i_w, int i_h )
1364 vout_buffer_t * p_buffer; /* current buffer */
1365 int i_area_begin, i_area_end; /* area vertical extension */
1366 int i_area, i_area_copy; /* area index */
1367 int i_area_shift; /* shift distance for areas */
1369 /* Choose buffer and modify h to end of area position */
1370 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1374 * Remove part of the area which is inside the picture - this is done
1375 * by calling again SetBufferArea with the correct areas dimensions.
1377 if( (i_x >= p_buffer->i_pic_x) && (i_x + i_w <= p_buffer->i_pic_x + p_buffer->i_pic_width) )
1379 i_area_begin = p_buffer->i_pic_y;
1380 i_area_end = i_area_begin + p_buffer->i_pic_height - 1;
1382 if( ((i_y >= i_area_begin) && (i_y <= i_area_end)) ||
1383 ((i_h >= i_area_begin) && (i_h <= i_area_end)) ||
1384 ((i_y < i_area_begin) && (i_h > i_area_end)) )
1386 /* Keep the stripe above the picture, if any */
1387 if( i_y < i_area_begin )
1389 SetBufferArea( p_vout, i_x, i_y, i_w, i_area_begin - i_y );
1391 /* Keep the stripe below the picture, if any */
1392 if( i_h > i_area_end )
1394 SetBufferArea( p_vout, i_x, i_area_end, i_w, i_h - i_area_end );
1400 /* Skip some extensions until interesting areas */
1402 (i_area < p_buffer->i_areas) &&
1403 (p_buffer->pi_area_end[i_area] + 1 <= i_y);
1409 if( i_area == p_buffer->i_areas )
1411 /* New area is below all existing ones: just add it at the end of the
1412 * array, if possible - otherwise, append it to the last one */
1413 if( i_area < VOUT_MAX_AREAS )
1415 p_buffer->pi_area_begin[i_area] = i_y;
1416 p_buffer->pi_area_end[i_area] = i_h;
1417 p_buffer->i_areas++;
1422 intf_DbgMsg("area overflow");
1424 p_buffer->pi_area_end[VOUT_MAX_AREAS - 1] = i_h;
1429 i_area_begin = p_buffer->pi_area_begin[i_area];
1430 i_area_end = p_buffer->pi_area_end[i_area];
1432 if( i_y < i_area_begin )
1434 if( i_h >= i_area_begin - 1 )
1436 /* Extend area above */
1437 p_buffer->pi_area_begin[i_area] = i_y;
1441 /* Create a new area above : merge last area if overflow, then
1442 * move all old areas down */
1443 if( p_buffer->i_areas == VOUT_MAX_AREAS )
1446 intf_DbgMsg("areas overflow");
1448 p_buffer->pi_area_end[VOUT_MAX_AREAS - 2] = p_buffer->pi_area_end[VOUT_MAX_AREAS - 1];
1452 p_buffer->i_areas++;
1454 for( i_area_copy = p_buffer->i_areas - 1; i_area_copy > i_area; i_area_copy-- )
1456 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy - 1];
1457 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy - 1];
1459 p_buffer->pi_area_begin[i_area] = i_y;
1460 p_buffer->pi_area_end[i_area] = i_h;
1464 if( i_h > i_area_end )
1466 /* Find further areas which can be merged with the new one */
1467 for( i_area_copy = i_area + 1;
1468 (i_area_copy < p_buffer->i_areas) &&
1469 (p_buffer->pi_area_begin[i_area] <= i_h);
1476 if( i_area_copy != i_area )
1478 /* Merge with last possible areas */
1479 //p_buffer->pi_area_end[i_area] = MAX( i_h, p_buffer->pi_area_end[i_area_copy] );
1481 /* Shift lower areas upward */
1482 i_area_shift = i_area_copy - i_area;
1483 p_buffer->i_areas -= i_area_shift;
1484 for( i_area_copy = i_area + 1; i_area_copy < p_buffer->i_areas; i_area_copy++ )
1486 p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy + i_area_shift];
1487 p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy + i_area_shift];
1492 /* Extend area below */
1493 p_buffer->pi_area_end[i_area] = i_h;
1499 /*****************************************************************************
1500 * SetBufferPicture: clear buffer and set picture area
1501 *****************************************************************************
1502 * This function is called before any rendering. It clears the current
1503 * rendering buffer and set the new picture area. If the picture pointer is
1504 * NULL, then no picture area is defined. Floating operations are avoided since
1505 * some MMX calculations may follow.
1506 *****************************************************************************/
1507 static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
1509 vout_buffer_t * p_buffer; /* current buffer */
1510 int i_pic_x, i_pic_y; /* picture position */
1511 int i_pic_width, i_pic_height; /* picture dimensions */
1512 int i_old_pic_y, i_old_pic_height; /* old picture area */
1513 int i_vout_width, i_vout_height; /* display dimensions */
1514 int i_area; /* area index */
1515 int i_data_index; /* area data index */
1516 int i_data_size; /* area data size, in 256 bytes blocs */
1517 u64 * p_data; /* area data, for clearing */
1518 byte_t * p_data8; /* area data, for clearing (slow) */
1520 /* Choose buffer and set display dimensions */
1521 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1522 i_vout_width = p_vout->i_width;
1523 i_vout_height = p_vout->i_height;
1526 * Computes new picture size
1530 /* Try horizontal scaling first - width must be a mutiple of 16 */
1531 i_pic_width = (( p_vout->b_scale || (p_pic->i_width > i_vout_width)) ?
1532 i_vout_width : p_pic->i_width) & ~0xf;
1533 switch( p_pic->i_aspect_ratio )
1535 case AR_3_4_PICTURE:
1536 i_pic_height = i_pic_width * 3 / 4;
1538 case AR_16_9_PICTURE:
1539 i_pic_height = i_pic_width * 9 / 16;
1541 case AR_221_1_PICTURE:
1542 i_pic_height = i_pic_width * 100 / 221;
1544 case AR_SQUARE_PICTURE:
1546 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1550 /* If picture dimensions using horizontal scaling are too large, use
1551 * vertical scaling. Since width must be a multiple of 16, height is
1552 * adjusted again after. */
1553 if( i_pic_height > i_vout_height )
1555 i_pic_height = ( p_vout->b_scale || (p_pic->i_height > i_vout_height)) ?
1556 i_vout_height : p_pic->i_height;
1557 switch( p_pic->i_aspect_ratio )
1559 case AR_3_4_PICTURE:
1560 i_pic_width = (i_pic_height * 4 / 3) & ~0xf;
1561 i_pic_height = i_pic_width * 3 / 4;
1563 case AR_16_9_PICTURE:
1564 i_pic_width = (i_pic_height * 16 / 9) & ~0xf;
1565 i_pic_height = i_pic_width * 9 / 16;
1567 case AR_221_1_PICTURE:
1568 i_pic_width = (i_pic_height * 221 / 100) & ~0xf;
1569 i_pic_height = i_pic_width * 100 / 221;
1571 case AR_SQUARE_PICTURE:
1573 i_pic_width = (p_pic->i_width * i_pic_height / p_pic->i_height) & ~0xf;
1574 i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
1579 /* Set picture position */
1580 i_pic_x = (p_vout->i_width - i_pic_width) / 2;
1581 i_pic_y = (p_vout->i_height - i_pic_height) / 2;
1586 /* No picture: size is 0 */
1594 * Set new picture size - if it is smaller than the previous one, clear
1595 * around it. Since picture are centered, only their size is tested.
1597 if( (p_buffer->i_pic_width > i_pic_width) || (p_buffer->i_pic_height > i_pic_height) )
1599 i_old_pic_y = p_buffer->i_pic_y;
1600 i_old_pic_height = p_buffer->i_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;
1605 SetBufferArea( p_vout, 0, i_old_pic_y, p_vout->i_width, i_old_pic_height );
1609 p_buffer->i_pic_x = i_pic_x;
1610 p_buffer->i_pic_y = i_pic_y;
1611 p_buffer->i_pic_width = i_pic_width;
1612 p_buffer->i_pic_height = i_pic_height;
1618 for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
1621 intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d", p_pic,
1622 p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
1624 i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
1625 p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
1626 for( i_data_index = i_data_size / 256; i_data_index-- ; )
1628 /* Clear 256 bytes block */
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;
1636 *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
1638 for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
1640 /* Clear remaining 16 bytes blocks */
1641 *p_data++ = 0; *p_data++ = 0;
1643 p_data8 = (byte_t *)p_data;
1644 for( i_data_index = i_data_size % 16; i_data_index--; )
1646 /* Clear remaining bytes */
1654 p_buffer->i_areas = 0;
1657 /*****************************************************************************
1658 * RenderPicture: render a picture
1659 *****************************************************************************
1660 * This function converts a picture from a video heap to a pixel-encoded image
1661 * and copies it to the current rendering buffer. No lock is required, since
1662 * the * rendered picture has been determined as existant, and will only be
1663 * destroyed by the vout thread later.
1664 *****************************************************************************/
1665 static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
1668 char psz_date[MSTRTIME_MAX_SIZE]; /* picture date */
1669 mtime_t render_time; /* picture rendering time */
1671 vout_buffer_t * p_buffer; /* rendering buffer */
1672 byte_t * p_pic_data; /* convertion destination */
1674 /* Get and set rendering information */
1675 p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
1676 p_pic_data = p_buffer->p_data +
1677 p_buffer->i_pic_x * p_vout->i_bytes_per_pixel +
1678 p_buffer->i_pic_y * p_vout->i_bytes_per_line;
1680 render_time = mdate();
1686 * Choose appropriate rendering function and render picture
1688 switch( p_pic->i_type )
1690 case YUV_420_PICTURE:
1691 p_vout->yuv.pf_yuv420( p_vout, p_pic_data,
1692 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1693 p_pic->i_width, p_pic->i_height,
1694 p_buffer->i_pic_width, p_buffer->i_pic_height,
1695 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1696 p_pic->i_matrix_coefficients );
1698 case YUV_422_PICTURE:
1699 p_vout->yuv.pf_yuv422( p_vout, p_pic_data,
1700 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1701 p_pic->i_width, p_pic->i_height,
1702 p_buffer->i_pic_width, p_buffer->i_pic_height,
1703 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1704 p_pic->i_matrix_coefficients );
1706 case YUV_444_PICTURE:
1707 p_vout->yuv.pf_yuv444( p_vout, p_pic_data,
1708 p_pic->p_y, p_pic->p_u, p_pic->p_v,
1709 p_pic->i_width, p_pic->i_height,
1710 p_buffer->i_pic_width, p_buffer->i_pic_height,
1711 p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
1712 p_pic->i_matrix_coefficients );
1716 intf_DbgMsg("error: unknown picture type %d", p_pic->i_type );
1722 /* Print picture date and rendering time */
1723 intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s", p_pic,
1724 p_vout->i_buffer_index, (long) (mdate() - render_time),
1725 mstrtime( psz_date, p_pic->date ));
1729 /*****************************************************************************
1730 * RenderPictureInfo: print additionnal information on a picture
1731 *****************************************************************************
1732 * This function will print information such as fps and other picture
1733 * dependant information.
1734 *****************************************************************************/
1735 static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
1737 char psz_buffer[256]; /* string buffer */
1740 * Print FPS rate in upper right corner
1742 if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
1744 long i_fps = VOUT_FPS_SAMPLES * 1000000 * 10 /
1745 ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1)
1746 % VOUT_FPS_SAMPLES ] -
1747 p_vout->p_fps_sample[ p_vout->c_fps_samples
1748 % VOUT_FPS_SAMPLES ] );
1749 sprintf( psz_buffer, "%li.%i fps", i_fps / 10, (int)i_fps % 10 );
1750 Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
1754 * Print frames count and loop time in upper left corner
1756 sprintf( psz_buffer, "%ld frames, render: %ldus",
1757 (long) p_vout->c_fps_samples, (long) p_vout->render_time );
1758 Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
1762 * Print picture information in lower right corner
1764 sprintf( psz_buffer, "%s picture %dx%d (%dx%d%+d%+d %s) -> %dx%d+%d+%d",
1765 (p_pic->i_type == YUV_420_PICTURE) ? "4:2:0" :
1766 ((p_pic->i_type == YUV_422_PICTURE) ? "4:2:2" :
1767 ((p_pic->i_type == YUV_444_PICTURE) ? "4:4:4" : "ukn-type")),
1768 p_pic->i_width, p_pic->i_height,
1769 p_pic->i_display_width, p_pic->i_display_height,
1770 p_pic->i_display_horizontal_offset, p_pic->i_display_vertical_offset,
1771 (p_pic->i_aspect_ratio == AR_SQUARE_PICTURE) ? "sq" :
1772 ((p_pic->i_aspect_ratio == AR_3_4_PICTURE) ? "4:3" :
1773 ((p_pic->i_aspect_ratio == AR_16_9_PICTURE) ? "16:9" :
1774 ((p_pic->i_aspect_ratio == AR_221_1_PICTURE) ? "2.21:1" : "ukn-ar" ))),
1775 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_width,
1776 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height,
1777 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_x,
1778 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y );
1779 Print( p_vout, 0, 0, RIGHT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1783 /*****************************************************************************
1784 * RenderSplash: render splash picture
1785 *****************************************************************************
1786 * This function will print something on the screen. It will return 0 if
1787 * nothing has been rendered, or 1 if something has been changed on the screen.
1788 * Note that if you absolutely want something to be printed, you will have
1789 * to force it by setting the last idle date to 0.
1790 * Unlike other rendering functions, this one calls the SetBufferPicture
1791 * function when needed.
1792 *****************************************************************************/
1793 int RenderSplash( vout_thread_t *p_vout )
1795 int i_x = 0, i_y = 0; /* text position */
1796 int i_width, i_height; /* text size */
1797 char *psz_text = "VideoLAN Client (" VERSION ")"; /* text to display */
1799 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1800 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1802 // SetBufferPicture( p_vout, NULL );
1803 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1804 &i_width, &i_height );
1805 if( !Align( p_vout, &i_x, &i_y, i_width, i_height, CENTER_RALIGN, CENTER_RALIGN ) )
1807 vout_Print( p_vout->p_large_font,
1808 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1809 i_x * p_vout->i_bytes_per_pixel + (i_y - 16 ) * p_vout->i_bytes_per_line,
1810 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1811 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1812 WIDE_TEXT | OUTLINED_TEXT, psz_text, 100);
1813 SetBufferArea( p_vout, i_x, i_y, i_width, i_height);
1819 /*****************************************************************************
1820 * RenderIdle: render idle picture
1821 *****************************************************************************
1822 * This function will print something on the screen. It will return 0 if
1823 * nothing has been rendered, or 1 if something has been changed on the screen.
1824 * Note that if you absolutely want something to be printed, you will have
1825 * to force it by setting the last idle date to 0.
1826 * Unlike other rendering functions, this one calls the SetBufferPicture
1827 * function when needed.
1828 *****************************************************************************/
1829 int RenderIdle( vout_thread_t *p_vout )
1832 int i_x = 0, i_y = 0; /* text position */
1833 int i_width, i_height; /* text size */
1834 int i_amount = 0; /* amount to draw */
1835 char *psz_text = "Waiting for stream"; /* text to display */
1836 char *psz_wtext = "[................]";
1838 mtime_t current_date; /* current date */
1841 memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
1842 p_vout->i_bytes_per_line * p_vout->i_height, 12);
1845 current_date = mdate();
1846 if( (current_date - p_vout->last_display_date) > VOUT_IDLE_DELAY
1847 // && (current_date - p_vout->last_idle_date) > VOUT_IDLE_DELAY
1850 /* FIXME: idle screen disabled */
1852 SetBufferPicture( p_vout, NULL );
1853 vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
1854 &i_width, &i_height );
1855 if( !Align( p_vout, &i_x, &i_y, i_width, i_height * 2, CENTER_RALIGN, CENTER_RALIGN ) )
1857 i_amount = (int) ((current_date - p_vout->last_display_date ) / 5000LL);
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 * 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_text, (i_amount / 3 ) %110);
1865 vout_Print( p_vout->p_large_font,
1866 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1867 i_x * p_vout->i_bytes_per_pixel + (i_y + 16) * p_vout->i_bytes_per_line,
1868 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1869 p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
1870 WIDE_TEXT | OUTLINED_TEXT, psz_wtext, (i_amount/5)%110 );
1873 SetBufferArea( p_vout, i_x, i_y, i_width, i_height * 2 );
1881 /*****************************************************************************
1882 * RenderInfo: render additionnal information
1883 *****************************************************************************
1884 * This function renders information which do not depend on the current
1886 *****************************************************************************/
1887 static void RenderInfo( vout_thread_t *p_vout )
1890 char psz_buffer[256]; /* string buffer */
1891 int i_ready_pic = 0; /* ready pictures */
1892 int i_reserved_pic = 0; /* reserved pictures */
1893 int i_picture; /* picture index */
1898 * Print thread state in lower left corner
1900 for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
1902 switch( p_vout->p_picture[i_picture].i_status )
1904 case RESERVED_PICTURE:
1905 case RESERVED_DATED_PICTURE:
1906 case RESERVED_DISP_PICTURE:
1914 sprintf( psz_buffer, "pic: %d (%d/%d)/%d",
1915 p_vout->i_pictures, i_reserved_pic, i_ready_pic, VOUT_MAX_PICTURES );
1916 Print( p_vout, 0, 0, LEFT_RALIGN, BOTTOM_RALIGN, psz_buffer );
1920 /*****************************************************************************
1921 * RenderSubPicture: render a subpicture
1922 *****************************************************************************
1923 * This function renders a sub picture unit.
1924 *****************************************************************************/
1925 static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
1927 p_vout_font_t p_font; /* text font */
1928 int i_width, i_height; /* subpicture dimensions */
1930 while( p_subpic != NULL )
1932 switch( p_subpic->i_type )
1934 case DVD_SUBPICTURE: /* DVD subpicture unit */
1935 /* test if the picture really has to be displayed */
1936 if( mdate() < p_subpic->begin_date )
1938 /* not yet, see you later */
1941 if( mdate() > p_subpic->end_date )
1943 /* too late, destroying the subpic */
1944 vout_DestroySubPicture( p_vout, p_subpic );
1947 vout_RenderSPU( &p_vout->p_buffer[ p_vout->i_buffer_index ],
1948 p_subpic, p_vout->i_bytes_per_pixel,
1949 p_vout->i_bytes_per_line );
1951 case TEXT_SUBPICTURE: /* single line text */
1952 /* Select default font if not specified */
1953 p_font = p_subpic->type.text.p_font;
1954 if( p_font == NULL )
1956 p_font = p_vout->p_default_font;
1959 /* Compute text size (width and height fields are ignored)
1961 vout_TextSize( p_font, p_subpic->type.text.i_style,
1962 p_subpic->p_data, &i_width, &i_height );
1963 if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y,
1964 i_width, i_height, p_subpic->i_horizontal_align,
1965 p_subpic->i_vertical_align ) )
1968 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
1969 p_subpic->i_x * p_vout->i_bytes_per_pixel +
1970 p_subpic->i_y * p_vout->i_bytes_per_line,
1971 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
1972 p_subpic->type.text.i_char_color,
1973 p_subpic->type.text.i_border_color,
1974 p_subpic->type.text.i_bg_color,
1975 p_subpic->type.text.i_style, p_subpic->p_data, 100 );
1976 SetBufferArea( p_vout, p_subpic->i_x, p_subpic->i_y,
1977 i_width, i_height );
1983 intf_DbgMsg( "error: unknown subpicture %p type %d",
1984 p_subpic, p_subpic->i_type );
1988 p_subpic = p_subpic->p_next;
1992 /*****************************************************************************
1993 * RenderInterface: render the interface
1994 *****************************************************************************
1995 * This function renders the interface, if any.
1996 *****************************************************************************/
1997 static void RenderInterface( vout_thread_t *p_vout )
1999 int i_height, i_text_height; /* total and text height */
2000 int i_width_1, i_width_2; /* text width */
2001 int i_byte; /* byte index */
2002 const char *psz_text_1 = "[1-9] Channel [i]nfo [c]olor [g/G]amma";
2003 const char *psz_text_2 = "[+/-] Volume [m]ute [s]caling [Q]uit";
2006 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_1, &i_width_1, &i_height );
2007 vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_2, &i_width_2, &i_text_height );
2008 i_height += i_text_height;
2010 /* Render background */
2011 for( i_byte = (p_vout->i_height - i_height) * p_vout->i_bytes_per_line;
2012 i_byte < p_vout->i_height * p_vout->i_bytes_per_line;
2016 p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = p_vout->i_blue_pixel;
2019 /* Render text, if not larger than screen */
2020 if( i_width_1 < p_vout->i_width )
2022 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2023 (p_vout->i_height - i_height) * p_vout->i_bytes_per_line,
2024 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2025 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2026 OUTLINED_TEXT, psz_text_1, 100 );
2028 if( i_width_2 < p_vout->i_width )
2030 vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
2031 (p_vout->i_height - i_height + i_text_height) * p_vout->i_bytes_per_line,
2032 p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
2033 p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
2034 OUTLINED_TEXT, psz_text_2, 100 );
2037 /* Activate modified area */
2038 SetBufferArea( p_vout, 0, p_vout->i_height - i_height, p_vout->i_width, i_height );
2041 /*****************************************************************************
2042 * Manage: manage thread
2043 *****************************************************************************
2044 * This function will handle changes in thread configuration.
2045 *****************************************************************************/
2046 static int Manage( vout_thread_t *p_vout )
2049 if( p_vout->i_changes )
2051 intf_DbgMsg("changes: 0x%x (no display: 0x%x)", p_vout->i_changes,
2052 0 /* p_vout->i_changes & VOUT_NODISPLAY_CHANGE */ );
2056 /* On gamma or grayscale change, rebuild tables */
2057 if( p_vout->i_changes & (VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2060 if( vout_ResetYUV( p_vout ) )
2062 intf_ErrMsg( "vout error: can't rebuild conversion tables" );
2067 /* Clear changes flags which does not need management or have been
2069 p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
2070 VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
2071 VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE |
2072 VOUT_CURSOR_CHANGE | VOUT_FULLSCREEN_CHANGE );
2074 /* Detect unauthorized changes */
2075 if( p_vout->i_changes )
2077 /* Some changes were not acknowledged by p_vout->pf_manage or this
2078 * function, it means they should not be authorized */
2079 intf_ErrMsg( "vout error: unauthorized changes in the vout thread" );
2086 /*****************************************************************************
2087 * Align: align a subpicture in the screen
2088 *****************************************************************************
2089 * This function is used for rendering text or subpictures. It returns non 0
2090 * it the final aera is not fully included in display area. Return coordinates
2092 *****************************************************************************/
2093 static int Align( vout_thread_t *p_vout, int *pi_x, int *pi_y,
2094 int i_width, int i_height, int i_h_align, int i_v_align )
2096 /* Align horizontally */
2100 *pi_x -= i_width / 2;
2103 *pi_x += (p_vout->i_width - i_width) / 2;
2109 *pi_x += p_vout->i_width - i_width;
2113 /* Align vertically */
2117 *pi_y -= i_height / 2;
2120 *pi_y += (p_vout->i_height - i_height) / 2;
2126 *pi_y += p_vout->i_height - i_height;
2128 case SUBTITLE_RALIGN:
2129 *pi_y += (p_vout->i_height + p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y +
2130 p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height - i_height) / 2;
2134 /* Return non 0 if clipping failed */
2135 return( (*pi_x < 0) || (*pi_y < 0) ||
2136 (*pi_x + i_width > p_vout->i_width) || (*pi_y + i_height > p_vout->i_height) );
2139 /*****************************************************************************
2140 * SetPalette: sets an 8 bpp palette
2141 *****************************************************************************
2142 * This function is just a prototype that does nothing. Architectures that
2143 * support palette allocation should override it.
2144 *****************************************************************************/
2145 static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
2146 u16 *green, u16 *blue, u16 *transp )
2148 intf_ErrMsg( "vout error: method does not support palette changing" );