Commit 28115de8 authored by Vincent Seguin's avatar Vincent Seguin

Mise place du scaling, episode II

Alignement am�lior�
Effacement 'intelligent' des zones modifi�es
Correction d'une memory corruption
Structure d'acceuil pour les subpictures
ggi et fb fonctionnent (pas mieux qu'avant, mais ils compilent)

Ca rame. C'est normal, c'est la YUV en C qui est utilis�e. C'est aussi normal
parce que l'effacement, �a prends un peu de temps (et �a c'est d�finitif).
Ce n'est pas beau: normal, il n'y a que du croping pour le moment, le scaling
arrive.
parent 46acf499
......@@ -260,7 +260,6 @@
/* Time during which the thread will sleep if it has nothing to
* display (in micro-seconds) */
/* ?? this constant will probably evolve to a calculated value */
#define VOUT_IDLE_SLEEP 20000
/* Maximum lap of time allowed between the beginning of rendering and
......@@ -268,11 +267,10 @@
* late, the thread will perform an idle loop. This time should be
* at least VOUT_IDLE_SLEEP plus the time required to render a few
* images, to avoid trashing of decoded images */
/* ?? this constant will probably evolve to a calculated value */
#define VOUT_DISPLAY_DELAY 500000
/* Delay (in microseconds) between increments in idle levels */
#define VOUT_IDLE_DELAY 5000000000000
/* Delay (in microseconds) before an idle screen is displayed */
#define VOUT_IDLE_DELAY 5000000
/* Number of pictures required to computes the FPS rate */
#define VOUT_FPS_SAMPLES 20
......
......@@ -87,14 +87,14 @@ typedef struct picture_s
#define AR_221_1_PICTURE 4 /* 2.21:1 picture (movie) */
/*******************************************************************************
* spu_t: video sub picture unit
* subpicture_t: video sub picture unit
*******************************************************************************
* Any sub picture unit destined to be displayed by a video output thread should
* be stored in this structure from it's creation to it's effective display.
* Subtitle type and flags should only be modified by the output thread. Note
* that an empty subtitle MUST have its flags set to 0.
*******************************************************************************/
typedef struct spu_s
typedef struct subpicture_s
{
/* Type and flags - should NOT be modified except by the vout thread */
int i_type; /* spu type */
......@@ -104,18 +104,44 @@ typedef struct spu_s
mtime_t begin_date; /* beginning of display date */
mtime_t end_date; /* end of display date */
/* Display properties - these properties are only indicative and may be
* changed by the video output thread */
int i_x; /* offset from alignment position */
int i_y; /* offset from alignment position */
int i_width; /* picture width */
int i_height; /* picture height */
int i_horizontal_align; /* horizontal alignment */
int i_vertical_align; /* vertical alignment */
/* Sub picture unit data - data can always be freely modified. p_data itself
* (the pointer) should NEVER be modified. */
void * p_data; /* spu data */
} spu_t;
} subpicture_t;
/* SPU types */
#define EMPTY_SPU 0 /* subtitle slot is empty and available */
#define RLE_SPU 100 /* RLE encoded subtitle */
/* Subpicture type */
#define EMPTY_SUBPICTURE 0 /* subtitle slot is empty and available */
#define RLE_SUBPICTURE 100 /* RLE encoded subtitle */
#define TEXT_SUBPICTURE 200 /* iso8859-1 text subtitle */
/* Subpicture status */
#define FREE_SPU 0 /* subtitle is free and not allocated */
#define RESERVED_SPU 1 /* subtitle is allocated and reserved */
#define READY_SPU 2 /* subtitle is ready for display */
#define DESTROYED_SPU 3 /* subtitle is allocated but no more used */
#define FREE_SUBPICTURE 0 /* subpicture is free and not allocated */
#define RESERVED_SUBPICTURE 1 /* subpicture is allocated and reserved */
#define READY_SUBPICTURE 2 /* subpicture is ready for display */
#define DESTROYED_SUBPICTURE 3 /* subpicture is allocated but no more used */
/* Alignment types */
#define RIGHT_ALIGN 10 /* x is absolute for right */
#define LEFT_ALIGN 11 /* x is absolute for left */
#define RIGHT_RALIGN 12 /* x is relative for right from right */
#define LEFT_RALIGN 13 /* x is relative for left from left */
#define CENTER_ALIGN 20 /* x, y are absolute for center */
#define CENTER_RALIGN 21 /* x, y are relative for center from center */
#define BOTTOM_ALIGN 30 /* y is absolute for bottom */
#define TOP_ALIGN 31 /* y is absolute for top */
#define BOTTOM_RALIGN 32 /* y is relative for bottom from bottom */
#define TOP_RALIGN 33 /* y is relative for top from top */
#define SUBTITLE_RALIGN 34 /* y is relative for center from subtitle */
......@@ -8,12 +8,41 @@
*******************************************************************************/
/*******************************************************************************
* vout_tables_t: pre-calculated convertion tables
* vout_yuv_convert_t: YUV convertion function
*******************************************************************************
* This is the prototype common to all convertion functions. The type of p_pic
* will change depending of the screen depth treated.
* Parameters:
* p_vout video output thread
* p_pic picture address
* p_y, p_u, p_v Y,U,V samples addresses
* i_width, i_height Y samples extension
* i_skip Y pixels to skip at the end of a line
* i_pic_width, i_pic_height picture extension
* i_pic_skip pixels to skip at the end of a line
* i_matrix_coefficients matrix coefficients
* Conditions:
* i_width % 16 == 0
*******************************************************************************/
typedef void (vout_yuv_convert_t)( p_vout_thread_t p_vout, void *p_pic,
yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
int i_width, int i_height, int i_skip,
int i_pic_width, int i_pic_height, int i_pic_skip,
int i_matrix_coefficients );
/*******************************************************************************
* vout_yuv_t: pre-calculated YUV convertion tables
*******************************************************************************
* These tables are used by convertion and scaling functions.
*******************************************************************************/
typedef struct vout_tables_s
typedef struct vout_yuv_s
{
/* Convertion functions */
vout_yuv_convert_t * p_Convert420; /* YUV 4:2:0 converter */
vout_yuv_convert_t * p_Convert422; /* YUV 4:2:2 converter */
vout_yuv_convert_t * p_Convert444; /* YUV 4:4:4 converter */
/* Pre-calculated convertion tables */
void * p_base; /* base for all translation tables */
union
{
......@@ -21,8 +50,17 @@ typedef struct vout_tables_s
struct { u32 *p_red, *p_green, *p_blue; } rgb32; /* color 24, 32 bpp */
struct { u16 *p_gray; } gray16; /* gray 15, 16 bpp */
struct { u32 *p_gray; } gray32; /* gray 24, 32 bpp */
} yuv;
} vout_tables_t;
} yuv;
union
{
u16 * p_rgb16;
u32 * p_rgb32;
} yuv2;//??
/* Temporary convertion buffer - this buffer may be used by convertion
* functions and should be 2 screen lines width */
void * p_buffer; /* convertion buffer */
} vout_yuv_t;
/*******************************************************************************
* vout_buffer_t: rendering buffer
......@@ -45,31 +83,6 @@ typedef struct vout_buffer_s
byte_t * p_data; /* memory address */
} vout_buffer_t;
/*******************************************************************************
* vout_convert_t: convertion function
*******************************************************************************
* This is the prototype common to all convertion functions. The type of p_pic
* will change depending of the screen depth treated.
* Parameters:
* p_vout video output thread
* p_pic picture address (start address in picture)
* p_y, p_u, p_v Y,U,V samples addresses
* i_width Y samples width
* i_height Y samples height
* i_eol number of Y samples to reach the next line
* i_pic_eol number or pixels to reach the next line
* i_scale if non 0, vertical scaling is 1 - 1/i_scale
* i_matrix_coefficients matrix coefficients
* Conditions:
* start x + i_width < picture width
* start y + i_height * (scaling factor) < picture height
* i_width % 16 == 0
*******************************************************************************/
typedef void (vout_convert_t)( p_vout_thread_t p_vout, void *p_pic,
yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
int i_width, int i_height, int i_eol, int i_pic_eol,
int i_scale, int i_matrix_coefficients );
/*******************************************************************************
* vout_thread_t: video output thread descriptor
*******************************************************************************
......@@ -85,12 +98,13 @@ typedef struct vout_thread_s
boolean_t b_active; /* `active' flag */
vlc_thread_t thread_id; /* id for pthread functions */
vlc_mutex_t picture_lock; /* picture heap lock */
vlc_mutex_t spu_lock; /* subtitle heap lock */
vlc_mutex_t subpicture_lock; /* subpicture heap lock */
vlc_mutex_t change_lock; /* thread change lock */
int * pi_status; /* temporary status flag */
p_vout_sys_t p_sys; /* system output method */
/* Current display properties */
u16 i_changes; /* changes made to the thread */
int i_width; /* current output method width */
int i_height; /* current output method height */
int i_bytes_per_line;/* bytes per line (including virtual) */
......@@ -104,6 +118,10 @@ typedef struct vout_thread_s
boolean_t b_interface; /* render interface */
boolean_t b_scale; /* allow picture scaling */
/* Idle screens management */
mtime_t last_display_date; /* last non idle display date */
mtime_t last_idle_date; /* last idle display date */
#ifdef STATS
/* Statistics - these numbers are not supposed to be accurate, but are a
* good indication of the thread status */
......@@ -112,22 +130,14 @@ typedef struct vout_thread_s
mtime_t p_fps_sample[ VOUT_FPS_SAMPLES ]; /* FPS samples dates */
#endif
/* Running properties */
u16 i_changes; /* changes made to the thread */
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 */
spu_t p_spu[VOUT_MAX_PICTURES]; /* subtitles */
vout_tables_t tables; /* translation tables */
vout_convert_t * p_ConvertYUV420; /* YUV 4:2:0 converter */
vout_convert_t * p_ConvertYUV422; /* YUV 4:2:2 converter */
vout_convert_t * p_ConvertYUV444; /* YUV 4:4:4 converter */
subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /* subpictures */
vout_yuv_t yuv; /* translation tables */
/* Bitmap fonts */
p_vout_font_t p_default_font; /* default font */
......@@ -143,6 +153,7 @@ typedef struct vout_thread_s
#define VOUT_SIZE_CHANGE 0x0200 /* size changed */
#define VOUT_DEPTH_CHANGE 0x0400 /* depth changed */
#define VOUT_GAMMA_CHANGE 0x0010 /* gamma changed */
#define VOUT_YUV_CHANGE 0x0800 /* change yuv tables */
#define VOUT_NODISPLAY_CHANGE 0xff00 /* changes which forbidden display */
/*******************************************************************************
......@@ -158,15 +169,8 @@ void vout_DisplayPicture ( vout_thread_t *p_vout, picture_t *p_pi
void vout_DatePicture ( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date );
void vout_LinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
void vout_UnlinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
spu_t * vout_CreateSubPictureUnit ( vout_thread_t *p_vout, int i_type, int i_size );
void vout_DestroySubPictureUnit ( vout_thread_t *p_vout, spu_t *p_spu );
void vout_DisplaySubPictureUnit ( vout_thread_t *p_vout, spu_t *p_spu );
void vout_ClearBuffer ( vout_thread_t *p_vout, vout_buffer_t *p_buffer );
subpicture_t * vout_CreateSubPicture ( vout_thread_t *p_vout, int i_type, int i_size );
void vout_DestroySubPicture ( vout_thread_t *p_vout, subpicture_t *p_subpic );
void vout_DisplaySubPicture ( vout_thread_t *p_vout, subpicture_t *p_subpic );
void vout_SetBuffers ( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 );
......@@ -7,7 +7,7 @@
* They may be ignored or interpreted by higher level functions */
#define WIDE_TEXT 1 /* interspacing is doubled */
#define ITALIC_TEXT 2 /* italic */
#define TRANSPARENT_TEXT 4 /* transparent text */
#define OPAQUE_TEXT 4 /* text with background */
#define OUTLINED_TEXT 8 /* border around letters */
#define VOID_TEXT 16 /* no foreground */
......
......@@ -9,9 +9,9 @@
/*******************************************************************************
* Prototypes
*******************************************************************************/
int vout_InitTables ( vout_thread_t *p_vout );
int vout_ResetTables ( vout_thread_t *p_vout );
void vout_EndTables ( vout_thread_t *p_vout );
int vout_InitYUV ( vout_thread_t *p_vout );
int vout_ResetYUV ( vout_thread_t *p_vout );
void vout_EndYUV ( vout_thread_t *p_vout );
/*******************************************************************************
* External prototypes
......
......@@ -250,7 +250,7 @@ int intf_ProcessKey( intf_thread_t *p_intf, int i_key )
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->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 );
}
......
......@@ -53,8 +53,6 @@ typedef struct vout_sys_s
******************************************************************************/
static int FBOpenDisplay ( vout_thread_t *p_vout );
static void FBCloseDisplay ( vout_thread_t *p_vout );
static void FBBlankDisplay ( vout_thread_t *p_vout );
/******************************************************************************
* vout_SysCreate: allocates FB video thread output method
......@@ -221,7 +219,7 @@ static int FBOpenDisplay( vout_thread_t *p_vout )
break;
default: /* unsupported screen depth */
intf_ErrMsg("vout error: screen depth %i is not supported\n",
intf_ErrMsg("vout error: screen depth %d is not supported\n",
p_vout->i_screen_depth);
return( 1 );
break;
......@@ -242,16 +240,10 @@ static int FBOpenDisplay( vout_thread_t *p_vout )
}
/* 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] );
vout_SetBuffers( p_vout, p_vout->p_sys->p_video,
p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
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 );
intf_Msg("vout: framebuffer display initialized (%s), %dx%d depth=%d bpp\n",
fix_info.id, p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth );
return( 0 );
}
......
......@@ -258,16 +258,6 @@ static int GGIOpenDisplay( vout_thread_t *p_vout, char *psz_display )
}
#endif
/* Get font size */
if( ggiGetCharSize( p_vout->p_sys->p_display, &p_vout->p_sys->i_char_width,
&p_vout->p_sys->i_char_height ) )
{
intf_ErrMsg("error: can't get font size\n");
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
}
/* Set graphic context colors */
col_fg.r = col_fg.g = col_fg.b = -1;
col_bg.r = col_bg.g = col_bg.b = 0;
......@@ -323,10 +313,7 @@ static int GGIOpenDisplay( vout_thread_t *p_vout, char *psz_display )
}
/* 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] );
vout_SetBuffers( p_vout, p_vout->p_sys->p_buffer[ 0 ]->write, p_vout->p_sys->p_buffer[ 1 ]->write );
return( 0 );
}
......
This diff is collapsed.
......@@ -369,9 +369,9 @@ void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int
}
/* Choose masks and copy font data to local variables */
i_char_mask = (i_style & VOID_TEXT) ? 0 : 0xff;
i_border_mask = (i_style & OUTLINED_TEXT) ? 0xff : 0;
i_bg_mask = (i_style & TRANSPARENT_TEXT) ? 0 : 0xff;
i_char_mask = (i_style & VOID_TEXT) ? 0 : 0xff;
i_border_mask = (i_style & OUTLINED_TEXT) ? 0xff : 0;
i_bg_mask = (i_style & OPAQUE_TEXT) ? 0xff : 0;
i_font_bytes_per_line = p_font->i_bytes_per_line;
i_font_height = p_font->i_height;
......
......@@ -153,14 +153,10 @@ int vout_SysInit( vout_thread_t *p_vout )
}
}
/* Set bytes per line */
/* Set bytes per line and initialize buffers */
p_vout->i_bytes_per_line = p_vout->p_sys->p_ximage[0]->bytes_per_line;
/* 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] );
vout_SetBuffers( p_vout, p_vout->p_sys->p_ximage[ 0 ]->data,
p_vout->p_sys->p_ximage[ 1 ]->data );
return( 0 );
}
......@@ -224,6 +220,10 @@ int vout_SysManage( vout_thread_t *p_vout )
intf_ErrMsg("error: can't resize display\n");
return( 1 );
}
/* Tell the video output thread that it will need to rebuild YUV
* tables. This is needed since convertion buffer size may have changed */
p_vout->i_changes |= VOUT_YUV_CHANGE;
intf_Msg("Video display resized (%dx%d)\n", p_vout->i_width, p_vout->i_height);
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment