Commit a2972b3c authored by Vincent Seguin's avatar Vincent Seguin

Nouvelle interface, effacement des zones modifi�es d'une image sur 2,

calcul de la taille optimale d'une image, scaling.

-Le scaling donne de bonnes tailles, mais les conversions YUV ne peuvent
pas suivre pour le moment.
-J'ai peut etre un peu cass� le fb et ggi (trop long � compiler pour tester).
En cas de probl�me, je corrige de suite.
-Les idle screens ("no stream") sont temporairement hors service.
parent 32414c55
......@@ -89,7 +89,7 @@ endif
# Libraries
#
LIB += -lpthread
LIB += -lm
LIN += -lm
ifeq ($(VIDEO),X11)
LIB += -L/usr/X11R6/lib
......
......@@ -228,10 +228,17 @@
#define VOUT_WIDTH_DEFAULT 640
#define VOUT_HEIGHT_DEFAULT 480
/* Default video heap size - remember that a decompressed picture is big
/* Video heap size - remember that a decompressed picture is big
* (~1 Mbyte) before using huge values */
#define VOUT_MAX_PICTURES 10
/* Maximum number of active areas in a rendering buffer. Active areas are areas
* of the picture which need to be cleared before re-using the buffer. If a
* picture, including its many additions such as subtitles, additionnal user
* informations and interface, has too many active areas, some of them are
* joined. */
#define VOUT_MAX_AREAS 5
/* Environment variable for grayscale output mode, and default value */
#define VOUT_GRAYSCALE_VAR "vlc_grayscale"
#define VOUT_GRAYSCALE_DEFAULT 0
......
......@@ -117,6 +117,5 @@ typedef struct subtitle_s
#define FREE_SUBTITLE 0 /* subtitle is free and not allocated */
#define RESERVED_SUBTITLE 1 /* subtitle is allocated and reserved */
#define READY_SUBTITLE 2 /* subtitle is ready for display */
#define DISPLAYED_SUBTITLE 3 /* subtitle has been displayed but is linked */
#define DESTROYED_SUBTITLE 4 /* subtitle is allocated but no more used */
#define DESTROYED_SUBTITLE 3 /* subtitle is allocated but no more used */
......@@ -24,6 +24,27 @@ typedef struct vout_tables_s
} yuv;
} vout_tables_t;
/*******************************************************************************
* vout_buffer_t: rendering buffer
*******************************************************************************
* This structure store informations about a buffer. Buffers are not completely
* cleared between displays, and modified areas needs to be stored.
*******************************************************************************/
typedef struct vout_buffer_s
{
/* Picture area */
int i_pic_x, i_pic_y; /* picture position */
int i_pic_width, i_pic_height; /* picture extension */
/* Other areas - only vertical extensions of areas are stored */
int i_areas; /* number of areas */
int pi_area_begin[VOUT_MAX_AREAS]; /* beginning of area */
int pi_area_end[VOUT_MAX_AREAS]; /* end of area */
/* Picture data */
byte_t * p_data; /* memory address */
} vout_buffer_t;
/*******************************************************************************
* vout_convert_t: convertion function
*******************************************************************************
......@@ -70,7 +91,6 @@ typedef struct vout_thread_s
p_vout_sys_t p_sys; /* system output method */
/* Current display properties */
boolean_t b_grayscale; /* color or grayscale display */
int i_width; /* current output method width */
int i_height; /* current output method height */
int i_bytes_per_line;/* bytes per line (including virtual) */
......@@ -79,14 +99,17 @@ typedef struct vout_thread_s
float f_gamma; /* gamma */
/* Pictures and rendering properties */
boolean_t b_grayscale; /* color or grayscale display */
boolean_t b_info; /* print additionnal informations */
boolean_t b_interface; /* render interface */
boolean_t b_scale; /* allow picture scaling */
#ifdef STATS
/* Statistics - these numbers are not supposed to be accurate, but are a
* good indication of the thread status */
mtime_t render_time; /* last picture render time */
count_t c_fps_samples; /* picture counts */
mtime_t fps_sample[ VOUT_FPS_SAMPLES ]; /* FPS samples dates */
mtime_t p_fps_sample[ VOUT_FPS_SAMPLES ]; /* FPS samples dates */
#endif
/* Running properties */
......@@ -94,6 +117,10 @@ typedef struct vout_thread_s
mtime_t last_picture_date; /* last picture display date */
mtime_t last_display_date; /* last screen display date */
/* Rendering buffers */
int i_buffer_index; /* buffer index */
vout_buffer_t p_buffer[2]; /* buffers properties */
/* Videos heap and translation tables */
picture_t p_picture[VOUT_MAX_PICTURES]; /* pictures */
subtitle_t p_subtitle[VOUT_MAX_PICTURES]; /* subtitles */
......@@ -111,10 +138,12 @@ typedef struct vout_thread_s
* thread changed a variable */
#define VOUT_INFO_CHANGE 0x0001 /* b_info changed */
#define VOUT_GRAYSCALE_CHANGE 0x0002 /* b_grayscale changed */
#define VOUT_SIZE_CHANGE 0x0008 /* size changed */
#define VOUT_DEPTH_CHANGE 0x0010 /* depth changed */
#define VOUT_GAMMA_CHANGE 0x0080 /* gamma changed */
#define VOUT_NODISPLAY_CHANGE 0xffff /* changes which forbidden display */
#define VOUT_INTF_CHANGE 0x0004 /* b_interface changed */
#define VOUT_SCALE_CHANGE 0x0008 /* b_scale changed */
#define VOUT_SIZE_CHANGE 0x0200 /* size changed */
#define VOUT_DEPTH_CHANGE 0x0400 /* depth changed */
#define VOUT_GAMMA_CHANGE 0x0010 /* gamma changed */
#define VOUT_NODISPLAY_CHANGE 0xff00 /* changes which forbidden display */
/*******************************************************************************
* Prototypes
......@@ -132,7 +161,7 @@ void vout_UnlinkPicture ( vout_thread_t *p_vout, picture_t *p_pi
subtitle_t * vout_CreateSubtitle ( vout_thread_t *p_vout, int i_type, int i_size );
void vout_DestroySubtitle ( vout_thread_t *p_vout, subtitle_t *p_sub );
void vout_DisplaySubtitle ( vout_thread_t *p_vout, subtitle_t *p_sub );
void vout_ClearBuffer ( vout_thread_t *p_vout, vout_buffer_t *p_buffer );
......
......@@ -12,7 +12,6 @@ void vout_SysEnd ( p_vout_thread_t p_vout );
void vout_SysDestroy ( p_vout_thread_t p_vout );
int vout_SysManage ( p_vout_thread_t p_vout );
void vout_SysDisplay ( p_vout_thread_t p_vout );
void * vout_SysGetPicture ( p_vout_thread_t p_vout );
......@@ -15,14 +15,15 @@
/*******************************************************************************
* Prototypes
*******************************************************************************/
p_vout_font_t vout_LoadFont ( char *psz_name );
p_vout_font_t vout_LoadFont ( const char *psz_name );
void vout_UnloadFont ( p_vout_font_t p_font );
void vout_TextSize ( p_vout_font_t p_font, int i_style, char *psz_text,
void vout_TextSize ( p_vout_font_t p_font, int i_style,
const char *psz_text,
int *pi_width, int *pi_height );
void vout_Print ( p_vout_font_t p_font, byte_t *p_pic, int i_depth,
int i_bytes_per_pixel, u32 i_char_color,
u32 i_border_color, u32 i_bg_color,
int i_style, char *psz_text );
void vout_Print ( p_vout_font_t p_font, byte_t *p_pic,
int i_bytes_per_pixel, int i_bytes_per_line,
u32 i_char_color, u32 i_border_color, u32 i_bg_color,
int i_style, const char *psz_text );
......
......@@ -228,7 +228,16 @@ int intf_ProcessKey( intf_thread_t *p_intf, int i_key )
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
break;
case ' ': /* toggle info */
case ' ': /* toggle interface */
if( p_intf->p_vout != NULL )
{
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->b_interface = !p_intf->p_vout->b_interface;
p_intf->p_vout->i_changes |= VOUT_INTF_CHANGE;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
break;
case 'i': /* toggle info */
if( p_intf->p_vout != NULL )
{
vlc_mutex_lock( &p_intf->p_vout->change_lock );
......@@ -237,7 +246,16 @@ int intf_ProcessKey( intf_thread_t *p_intf, int i_key )
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
break;
default: /* unknown key */
case 's': /* toggle scaling */
if( p_intf->p_vout != NULL )
{
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->b_scale = !p_intf->p_vout->b_scale;
p_intf->p_vout->i_changes |= VOUT_SCALE_CHANGE;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
break;
default: /* unknown key */
return( 1 );
}
......
......@@ -443,11 +443,13 @@ static void Usage( void )
/* Interfaces keys */
intf_Msg("Interface keys: most interfaces accept the following commands:\n" \
" [space] \ttoggle interface\n"
" [esc], q \tquit\n" \
" 0 - 9 \tselect channel\n" \
" +, -, m \tchange volume, mute\n" \
" g, G, c \tchange gamma, toggle grayscale\n" \
" 0 - 9 \tselect channel\n" \
" [space] \ttoggle info printing\n" \
" i \ttoggle info printing\n" \
" s \ttoggle picture scaling\n" \
);
}
......
......@@ -41,25 +41,11 @@ typedef struct vout_sys_s
{
/* System informations */
int i_fb_dev; /* framebuffer device handle */
size_t i_page_size; /* page size */
struct fb_var_screeninfo var_info; /* framebuffer mode informations */
/* Video memory */
byte_t * p_video;
/* User settings */
boolean_t b_shm; /* shared memory extension flag */
/* Font information */
int i_char_bytes_per_line; /* character width (bytes) */
int i_char_height; /* character height (lines) */
int i_char_interspacing;/* space between centers (pixels) */
byte_t * pi_font; /* pointer to font data */
/* Display buffers information */
int i_buffer_index; /* buffer index */
void * p_image[2]; /* image */
byte_t * p_video; /* base adress */
size_t i_page_size; /* page size */
} vout_sys_t;
/******************************************************************************
......@@ -98,32 +84,18 @@ int vout_SysCreate( vout_thread_t *p_vout, char *psz_display, int i_root_window
/******************************************************************************
* vout_SysInit: initialize framebuffer video thread output method
******************************************************************************
* This function creates the images needed by the output thread. It is called
* at the beginning of the thread, but also each time the display is resized.
******************************************************************************/
int vout_SysInit( vout_thread_t *p_vout )
{
// Blank both screens
memset( p_vout->p_sys->p_video, 0x00, 2*p_vout->p_sys->i_page_size );
//memset( p_vout->p_sys->p_image[0], 0xf0, p_vout->p_sys->i_page_size );
//memset( p_vout->p_sys->p_image[1], 0x0f, p_vout->p_sys->i_page_size );
/* Set buffer index to 0 */
p_vout->p_sys->i_buffer_index = 0;
return( 0 );
}
/******************************************************************************
* vout_SysEnd: terminate FB video thread output method
******************************************************************************
* Destroy the FB images created by vout_SysInit. It is called at the end of
* the thread, but also each time the window is resized.
******************************************************************************/
void vout_SysEnd( vout_thread_t *p_vout )
{
intf_DbgMsg("%p\n", p_vout );
{
;
}
/******************************************************************************
......@@ -141,19 +113,10 @@ void vout_SysDestroy( vout_thread_t *p_vout )
* vout_SysManage: handle FB events
******************************************************************************
* This function should be called regularly by video output thread. It manages
* console events and allows screen resizing. It returns a non null value on
* error.
* console events. It returns a non null value on error.
******************************************************************************/
int vout_SysManage( vout_thread_t *p_vout )
{
/* XXX */
if( p_vout->i_changes & VOUT_SIZE_CHANGE )
{
intf_DbgMsg("resizing window\n");
p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
FBBlankDisplay( p_vout );
}
return 0;
}
......@@ -165,10 +128,6 @@ int vout_SysManage( vout_thread_t *p_vout )
******************************************************************************/
void vout_SysDisplay( vout_thread_t *p_vout )
{
/* Swap buffers */
//p_vout->p_sys->i_buffer_index = ++p_vout->p_sys->i_buffer_index & 1;
p_vout->p_sys->i_buffer_index = 0;
/* tout est bien affich, on peut changer les 2 crans */
p_vout->p_sys->var_info.xoffset = 0;
p_vout->p_sys->var_info.yoffset =
......@@ -179,16 +138,6 @@ void vout_SysDisplay( vout_thread_t *p_vout )
ioctl( p_vout->p_sys->i_fb_dev, FBIOPAN_DISPLAY, &p_vout->p_sys->var_info );
}
/******************************************************************************
* vout_SysGetPicture: get current display buffer informations
******************************************************************************
* This function returns the address of the current display buffer.
******************************************************************************/
void * vout_SysGetPicture( vout_thread_t *p_vout )
{
return( p_vout->p_sys->p_image[ p_vout->p_sys->i_buffer_index ] );
}
/* following functions are local */
/******************************************************************************
......@@ -291,8 +240,12 @@ static int FBOpenDisplay( vout_thread_t *p_vout )
close( p_vout->p_sys->i_fb_dev );
return( 1 );
}
p_vout->p_sys->p_image[ 0 ] = p_vout->p_sys->p_video;
p_vout->p_sys->p_image[ 1 ] = p_vout->p_sys->p_video + p_vout->p_sys->i_page_size;
/* Set and initialize buffers */
p_vout->p_buffer[0].p_data = p_vout->p_sys->p_video;
p_vout->p_buffer[1].p_data = p_vout->p_sys->p_video + p_vout->p_sys->i_page_size;
vout_ClearBuffer( p_vout, &p_vout->p_buffer[0] );
vout_ClearBuffer( p_vout, &p_vout->p_buffer[1] );
intf_DbgMsg("framebuffer type=%d, visual=%d, ypanstep=%d, ywrap=%d, accel=%d\n",
fix_info.type, fix_info.visual, fix_info.ypanstep, fix_info.ywrapstep, fix_info.accel );
......@@ -310,20 +263,6 @@ static int FBOpenDisplay( vout_thread_t *p_vout )
******************************************************************************/
static void FBCloseDisplay( vout_thread_t *p_vout )
{
// Free font info
free( p_vout->p_sys->pi_font );
// Destroy window and close display
close( p_vout->p_sys->i_fb_dev );
}
/******************************************************************************
* FBBlankDisplay: render a blank screen
******************************************************************************
* This function is called by all other rendering functions when they arrive on
* a non blanked screen.
******************************************************************************/
static void FBBlankDisplay( vout_thread_t *p_vout )
{
memset( p_vout->p_sys->p_video, 0x00, 2*p_vout->p_sys->i_page_size );
}
......@@ -33,13 +33,8 @@ typedef struct vout_sys_s
ggi_visual_t p_display; /* display device */
/* Buffers informations */
int i_buffer_index; /* buffer index */
ggi_directbuffer * p_buffer[2]; /* buffers */
boolean_t b_must_acquire; /* must be acquired before writing */
/* Characters size */
int i_char_width;
int i_char_height;
} vout_sys_t;
/*******************************************************************************
......@@ -72,7 +67,6 @@ int vout_SysCreate( vout_thread_t *p_vout, char *psz_display, int i_root_window
free( p_vout->p_sys );
return( 1 );
}
return( 0 );
}
......@@ -84,10 +78,9 @@ int vout_SysCreate( vout_thread_t *p_vout, char *psz_display, int i_root_window
int vout_SysInit( vout_thread_t *p_vout )
{
/* Acquire first buffer */
p_vout->p_sys->i_buffer_index = 0;
if( p_vout->p_sys->b_must_acquire )
{
ggiResourceAcquire( p_vout->p_sys->p_buffer[ 0 ]->resource, GGI_ACTYPE_WRITE );
ggiResourceAcquire( p_vout->p_sys->p_buffer[ p_vout->i_buffer_index ]->resource, GGI_ACTYPE_WRITE );
}
return( 0 );
......@@ -103,7 +96,7 @@ void vout_SysEnd( vout_thread_t *p_vout )
/* Release buffer */
if( p_vout->p_sys->b_must_acquire )
{
ggiResourceRelease( p_vout->p_sys->p_buffer[ p_vout->p_sys->i_buffer_index ]->resource );
ggiResourceRelease( p_vout->p_sys->p_buffer[ p_vout->i_buffer_index ]->resource );
}
}
......@@ -140,64 +133,20 @@ void vout_SysDisplay( vout_thread_t *p_vout )
/* Change display frame */
if( p_vout->p_sys->b_must_acquire )
{
ggiResourceRelease( p_vout->p_sys->p_buffer[ p_vout->p_sys->i_buffer_index ]->resource );
ggiResourceRelease( p_vout->p_sys->p_buffer[ p_vout->i_buffer_index ]->resource );
}
ggiFlush( p_vout->p_sys->p_display ); // ??
ggiSetDisplayFrame( p_vout->p_sys->p_display,
p_vout->p_sys->p_buffer[ p_vout->p_sys->i_buffer_index ]->frame );
p_vout->p_sys->p_buffer[ p_vout->i_buffer_index ]->frame );
/* Swap buffers and change write frame */
p_vout->p_sys->i_buffer_index = ++p_vout->p_sys->i_buffer_index & 1;
if( p_vout->p_sys->b_must_acquire )
{
ggiResourceAcquire( p_vout->p_sys->p_buffer[ p_vout->p_sys->i_buffer_index ]->resource,
ggiResourceAcquire( p_vout->p_sys->p_buffer[ (p_vout->i_buffer_index + 1) & 1]->resource,
GGI_ACTYPE_WRITE );
}
ggiSetWriteFrame( p_vout->p_sys->p_display,
p_vout->p_sys->p_buffer[ p_vout->p_sys->i_buffer_index ]->frame );
}
/*******************************************************************************
* vout_SysGetPicture: get current display buffer informations
*******************************************************************************
* This function returns the address of the current display buffer.
*******************************************************************************/
void * vout_SysGetPicture( vout_thread_t *p_vout )
{
return( p_vout->p_sys->p_buffer[ p_vout->p_sys->i_buffer_index ]->write );
}
/*******************************************************************************
* vout_SysPrint: print simple text on a picture
*******************************************************************************
* This function will print a simple text on the picture. It is designed to
* print debugging or general informations, not to render subtitles.
*******************************************************************************/
void vout_SysPrint( vout_thread_t *p_vout, int i_x, int i_y, int i_halign,
int i_valign, unsigned char *psz_text )
{
/* Update upper left coordinates according to alignment */
switch( i_halign )
{
case 0: /* centered */
i_x -= p_vout->p_sys->i_char_width * strlen( psz_text ) / 2;
break;
case 1: /* right aligned */
i_x -= p_vout->p_sys->i_char_width * strlen( psz_text );
break;
}
switch( i_valign )
{
case 0: /* centered */
i_y -= p_vout->p_sys->i_char_height / 2;
break;
case 1: /* bottom aligned */
i_y -= p_vout->p_sys->i_char_height;
break;
}
/* Print text */
ggiPuts( p_vout->p_sys->p_display, i_x, i_y, psz_text );
p_vout->p_sys->p_buffer[ (p_vout->i_buffer_index + 1) & 1]->frame );
}
/*******************************************************************************
......@@ -373,6 +322,12 @@ static int GGIOpenDisplay( vout_thread_t *p_vout, char *psz_display )
break;
}
/* Set and initialize buffers */
p_vout->p_buffer[0].p_data = p_vout->p_sys->p_buffer[ 0 ]->write;
p_vout->p_buffer[1].p_data = p_vout->p_sys->p_buffer[ 1 ]->write;
vout_ClearBuffer( p_vout, &p_vout->p_buffer[0] );
vout_ClearBuffer( p_vout, &p_vout->p_buffer[1] );
return( 0 );
}
......
This diff is collapsed.
......@@ -175,7 +175,7 @@ static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border, b
* This function will try to open a .psf font and load it. It will return
* NULL on error.
*******************************************************************************/
vout_font_t *vout_LoadFont( char *psz_name )
vout_font_t *vout_LoadFont( const char *psz_name )
{
int i_char, i_line; /* character and line indexes */
int i_file; /* source file */
......@@ -305,7 +305,7 @@ void vout_UnloadFont( vout_font_t *p_font )
* This function is used to align text. It returns the width and height of a
* given text.
*******************************************************************************/
void vout_TextSize( vout_font_t *p_font, int i_style, char *psz_text, int *pi_width, int *pi_height )
void vout_TextSize( vout_font_t *p_font, int i_style, const char *psz_text, int *pi_width, int *pi_height )
{
switch( p_font->i_type )
{
......@@ -333,7 +333,7 @@ void vout_TextSize( vout_font_t *p_font, int i_style, char *psz_text, int *pi_wi
* loaded bitmap font.
*******************************************************************************/
void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int i_bytes_per_line,
u32 i_char_color, u32 i_border_color, u32 i_bg_color, int i_style, char *psz_text )
u32 i_char_color, u32 i_border_color, u32 i_bg_color, int i_style, const char *psz_text )
{
byte_t *p_char, *p_border; /* character and border mask data */
int i_char_mask, i_border_mask, i_bg_mask; /* masks */
......
......@@ -48,7 +48,6 @@ typedef struct vout_sys_s
GC gc; /* graphic context instance handler */
/* Display buffers and shared memory information */
int i_buffer_index; /* buffer index */
XImage * p_ximage[2]; /* XImage pointer */
XShmSegmentInfo shm_info[2]; /* shared memory zone information */
} vout_sys_t;
......@@ -157,8 +156,11 @@ int vout_SysInit( vout_thread_t *p_vout )
/* Set bytes per line */
p_vout->i_bytes_per_line = p_vout->p_sys->p_ximage[0]->bytes_per_line;
/* Set buffer index to 0 */
p_vout->p_sys->i_buffer_index = 0;
/* Set and initialize buffers */
p_vout->p_buffer[0].p_data = p_vout->p_sys->p_ximage[ 0 ]->data;
p_vout->p_buffer[1].p_data = p_vout->p_sys->p_ximage[ 1 ]->data;
vout_ClearBuffer( p_vout, &p_vout->p_buffer[0] );
vout_ClearBuffer( p_vout, &p_vout->p_buffer[1] );
return( 0 );
}
......@@ -222,7 +224,7 @@ int vout_SysManage( vout_thread_t *p_vout )
intf_ErrMsg("error: can't resize display\n");
return( 1 );
}
intf_Msg("Video display resized to %dx%d\n", p_vout->i_width, p_vout->i_height);
intf_Msg("Video display resized (%dx%d)\n", p_vout->i_width, p_vout->i_height);
}
return 0;
......@@ -240,10 +242,10 @@ void vout_SysDisplay( vout_thread_t *p_vout )
{
/* Display rendered image using shared memory extension */
XShmPutImage(p_vout->p_sys->p_display, p_vout->p_sys->window, p_vout->p_sys->gc,
p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ],
p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ],
0, 0, 0, 0,
p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ]->width,
p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ]->height, True);
p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->width,
p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->height, True);
/* Send the order to the X server */
XFlush(p_vout->p_sys->p_display);
......@@ -251,27 +253,14 @@ void vout_SysDisplay( vout_thread_t *p_vout )
else /* regular X11 capabilities are used */
{
XPutImage(p_vout->p_sys->p_display, p_vout->p_sys->window, p_vout->p_sys->gc,
p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ],
p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ],
0, 0, 0, 0,
p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ]->width,
p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ]->height);
p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->width,
p_vout->p_sys->p_ximage[ p_vout->i_buffer_index ]->height);
/* Send the order to the X server */
XFlush(p_vout->p_sys->p_display);
}
/* Swap buffers */
p_vout->p_sys->i_buffer_index = ++p_vout->p_sys->i_buffer_index & 1;
}
/*******************************************************************************
* vout_SysGetPicture: get current display buffer informations
*******************************************************************************
* This function returns the address of the current display buffer.
*******************************************************************************/
void * vout_SysGetPicture( vout_thread_t *p_vout )
{
return( p_vout->p_sys->p_ximage[ p_vout->p_sys->i_buffer_index ]->data );
}
/* following functions are local */
......
......@@ -10,8 +10,8 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <errno.h>
#include <math.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
......@@ -46,6 +46,7 @@ const int MATRIX_COEFFICIENTS_TABLE[8][4] =
*******************************************************************************/
static int BinaryLog ( u32 i );
static void MaskToShift ( int *pi_right, int *pi_left, u32 i_mask );
static void SetGammaTable ( int *pi_table, double f_gamma );
static void SetTables ( vout_thread_t *p_vout );
static void ConvertY4Gray16 ( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
......@@ -387,24 +388,38 @@ static void MaskToShift (int *pi_right, int *pi_left, u32 i_mask)
}
/*******************************************************************************
* SetTables: compute tables and set function pointers
* SetGammaTable: return intensity table transformed by gamma curve.
*******************************************************************************
* pi_table is a table of 256 entries from 0 to 255.
*******************************************************************************/
static void SetGammaTable( int *pi_table, double f_gamma )
{
int i_y; /* base intensity */
/* Use exp(gamma) instead of gamma */
f_gamma = exp(f_gamma );
/* Build gamma table */
for( i_y = 0; i_y < 256; i_y++ )
{
pi_table[ i_y ] = pow( (double)i_y / 256, f_gamma ) * 256;
}
}
/*******************************************************************************
* SetTables: compute tables and set function pointers
+ *******************************************************************************/
static void SetTables( vout_thread_t *p_vout )
{
u8 i_gamma[256]; /* gamma table */
int pi_gamma[256]; /* gamma table */
int i_index; /* index in tables */
int i_red_right, i_red_left; /* red shifts */
int i_green_right, i_green_left; /* green shifts */
int i_blue_right, i_blue_left; /* blue shifts */
/*
* Build gamma table
*/
for( i_index = 0; i_index < 256; i_index++ )
{
i_gamma[i_index] = 255. * pow( (double)i_index / 255., exp(p_vout->f_gamma) );
}
/* Build gamma table */
SetGammaTable( pi_gamma, p_vout->f_gamma );
/*
* Set color masks and shifts
*/
......@@ -447,9 +462,9 @@ static void SetTables( vout_thread_t *p_vout )
for( i_index = -384; i_index < 640; i_index++)
{
p_vout->tables.yuv.gray16.p_gray[ i_index ] =
((i_gamma[CLIP_BYTE( i_index )] >> i_red_right) << i_red_left) |
((i_gamma[CLIP_BYTE( i_index )] >> i_green_right) << i_green_left) |
((i_gamma[CLIP_BYTE( i_index )] >> i_blue_right) << i_blue_left);
((pi_gamma[CLIP_BYTE( i_index )] >> i_red_right) << i_red_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_green_right) << i_green_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_blue_right) << i_blue_left);
}
break;
case 24:
......@@ -458,9 +473,9 @@ static void SetTables( vout_thread_t *p_vout )
for( i_index = -384; i_index < 640; i_index++)
{
p_vout->tables.yuv.gray32.p_gray[ i_index ] =
((i_gamma[CLIP_BYTE( i_index )] >> i_red_right) << i_red_left) |
((i_gamma[CLIP_BYTE( i_index )] >> i_green_right) << i_green_left) |
((i_gamma[CLIP_BYTE( i_index )] >> i_blue_right) << i_blue_left);
((pi_gamma[CLIP_BYTE( i_index )] >> i_red_right) << i_red_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_green_right) << i_green_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_blue_right) << i_blue_left);
}
break;
}
......@@ -477,9 +492,9 @@ static void SetTables( vout_thread_t *p_vout )
p_vout->tables.yuv.rgb16.p_blue = (u16 *)p_vout->tables.p_base + 2*1024 + 384;
for( i_index = -384; i_index < 640; i_index++)
{
p_vout->tables.yuv.rgb16.p_red[i_index] = (i_gamma[CLIP_BYTE(i_index)]>>i_red_right)<<i_red_left;
p_vout->tables.yuv.rgb16.p_green[i_index] = (i_gamma[CLIP_BYTE(i_index)]>>i_green_right)<<i_green_left;