Commit 38ac8544 authored by Laurent Aimar's avatar Laurent Aimar

Moved most of private vout_thread_t fields out of vlc_vout.h

parent b67a5864
......@@ -76,64 +76,14 @@ struct vout_thread_t
{
VLC_COMMON_MEMBERS
/** \name Thread properties and locks */
/**@{*/
vlc_mutex_t picture_lock; /**< picture heap lock */
vlc_mutex_t change_lock; /**< thread change lock */
/**@}*/
/** \name Current display properties */
/**@{*/
uint16_t i_changes; /**< changes made to the thread.
\see \ref vout_changes */
unsigned b_fullscreen:1; /**< toogle fullscreen display */
unsigned b_on_top:1; /**< stay always on top of other windows */
/**@}*/
/** \name Video heap and translation tables */
/**@{*/
picture_heap_t render; /**< rendered pictures */
picture_heap_t output; /**< direct buffers */
video_format_t fmt_render; /* render format (from the decoder) */
video_format_t fmt_in; /* input (modified render) format */
video_format_t fmt_out; /* output format (for the video output) */
/**@}*/
/* Picture heap */
picture_t p_picture[2*VOUT_MAX_PICTURES+1]; /**< pictures */
/* Private vout_thread data */
vout_thread_sys_t *p;
};
#define I_OUTPUTPICTURES p_vout->output.i_pictures
#define PP_OUTPUTPICTURE p_vout->output.pp_picture
#define I_RENDERPICTURES p_vout->render.i_pictures
#define PP_RENDERPICTURE p_vout->render.pp_picture
/** \defgroup vout_changes Flags for changes
* These flags are set in the vout_thread_t::i_changes field when another
* thread changed a variable
* @{
*/
/** b_autoscale changed */
#define VOUT_SCALE_CHANGE 0x0008
/** b_on_top changed */
#define VOUT_ON_TOP_CHANGE 0x0010
/** b_fullscreen changed */
#define VOUT_FULLSCREEN_CHANGE 0x0040
/** i_zoom changed */
#define VOUT_ZOOM_CHANGE 0x0080
/** cropping parameters changed */
#define VOUT_CROP_CHANGE 0x1000
/** aspect ratio changed */
#define VOUT_ASPECT_CHANGE 0x2000
/** change/recreate picture buffers */
#define VOUT_PICTURE_BUFFERS_CHANGE 0x4000
/**@}*/
/* Alignment flags */
#define VOUT_ALIGN_LEFT 0x0001
#define VOUT_ALIGN_RIGHT 0x0002
......
This diff is collapsed.
......@@ -113,8 +113,49 @@ struct vout_thread_sys_t
/* */
vlc_mouse_t mouse;
/* */
vlc_mutex_t picture_lock; /**< picture heap lock */
vlc_mutex_t change_lock; /**< thread change lock */
uint16_t i_changes; /**< changes made to the thread.
\see \ref vout_changes */
unsigned b_fullscreen:1; /**< toogle fullscreen display */
unsigned b_on_top:1; /**< stay always on top of other windows */
picture_heap_t render; /**< rendered pictures */
picture_heap_t output; /**< direct buffers */
picture_t p_picture[2*VOUT_MAX_PICTURES+1]; /**< pictures */
};
#define I_OUTPUTPICTURES p_vout->p->output.i_pictures
#define PP_OUTPUTPICTURE p_vout->p->output.pp_picture
#define I_RENDERPICTURES p_vout->p->render.i_pictures
#define PP_RENDERPICTURE p_vout->p->render.pp_picture
/** \defgroup vout_changes Flags for changes
* These flags are set in the vout_thread_t::i_changes field when another
* thread changed a variable
* @{
*/
/** b_autoscale changed */
#define VOUT_SCALE_CHANGE 0x0008
/** b_on_top changed */
#define VOUT_ON_TOP_CHANGE 0x0010
/** b_fullscreen changed */
#define VOUT_FULLSCREEN_CHANGE 0x0040
/** i_zoom changed */
#define VOUT_ZOOM_CHANGE 0x0080
/** cropping parameters changed */
#define VOUT_CROP_CHANGE 0x1000
/** aspect ratio changed */
#define VOUT_ASPECT_CHANGE 0x2000
/** change/recreate picture buffers */
#define VOUT_PICTURE_BUFFERS_CHANGE 0x4000
/**@}*/
/* */
int vout_AllocatePicture( vlc_object_t *, picture_t *, uint32_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den );
#define vout_AllocatePicture(a,b,c,d,e,f,g) \
......
......@@ -344,7 +344,7 @@ void vout_IntfInit( vout_thread_t *p_vout )
if( var_CreateGetBoolCommand( p_vout, "fullscreen" ) )
{
/* user requested fullscreen */
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
p_vout->p->i_changes |= VOUT_FULLSCREEN_CHANGE;
}
text.psz_string = _("Fullscreen");
var_Change( p_vout, "fullscreen", VLC_VAR_SETTEXT, &text, NULL );
......@@ -791,7 +791,7 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
}
crop_end:
p_vout->i_changes |= VOUT_CROP_CHANGE;
p_vout->p->i_changes |= VOUT_CROP_CHANGE;
msg_Dbg( p_vout, "cropping picture %ix%i to %i,%i,%ix%i",
p_vout->fmt_in.i_width, p_vout->fmt_in.i_height,
......@@ -839,7 +839,7 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
p_vout->fmt_in.i_sar_den *= p_vout->p->i_par_num;
}
p_vout->i_changes |= VOUT_ASPECT_CHANGE;
p_vout->p->i_changes |= VOUT_ASPECT_CHANGE;
msg_Dbg( p_vout, "new aspect-ratio %i:%i, sample aspect-ratio %i:%i",
p_vout->fmt_in.i_sar_num * p_vout->fmt_in.i_width,
......@@ -860,18 +860,18 @@ static int ScalingCallback( vlc_object_t *p_this, char const *psz_cmd,
vout_thread_t *p_vout = (vout_thread_t *)p_this;
(void)oldval; (void)newval; (void)p_data;
vlc_mutex_lock( &p_vout->change_lock );
vlc_mutex_lock( &p_vout->p->change_lock );
if( !strcmp( psz_cmd, "autoscale" ) )
{
p_vout->i_changes |= VOUT_SCALE_CHANGE;
p_vout->p->i_changes |= VOUT_SCALE_CHANGE;
}
else if( !strcmp( psz_cmd, "scale" ) )
{
p_vout->i_changes |= VOUT_ZOOM_CHANGE;
p_vout->p->i_changes |= VOUT_ZOOM_CHANGE;
}
vlc_mutex_unlock( &p_vout->change_lock );
vlc_mutex_unlock( &p_vout->p->change_lock );
return VLC_SUCCESS;
}
......@@ -881,10 +881,10 @@ static int OnTopCallback( vlc_object_t *p_this, char const *psz_cmd,
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
vlc_mutex_lock( &p_vout->change_lock );
p_vout->i_changes |= VOUT_ON_TOP_CHANGE;
p_vout->b_on_top = newval.b_bool;
vlc_mutex_unlock( &p_vout->change_lock );
vlc_mutex_lock( &p_vout->p->change_lock );
p_vout->p->i_changes |= VOUT_ON_TOP_CHANGE;
p_vout->p->b_on_top = newval.b_bool;
vlc_mutex_unlock( &p_vout->p->change_lock );
(void)psz_cmd; (void)oldval; (void)p_data;
return VLC_SUCCESS;
......@@ -899,7 +899,7 @@ static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd,
if( oldval.b_bool == newval.b_bool )
return VLC_SUCCESS; /* no-op */
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
p_vout->p->i_changes |= VOUT_FULLSCREEN_CHANGE;
val.b_bool = true;
var_Set( p_vout, "intf-change", val );
......
......@@ -52,7 +52,7 @@
*/
void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->picture_lock );
vlc_mutex_lock( &p_vout->p->picture_lock );
if( p_pic->i_status == RESERVED_PICTURE )
{
......@@ -67,7 +67,7 @@ void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
p_vout->p->i_picture_qtype = p_pic->i_qtype;
p_vout->p->b_picture_interlaced = !p_pic->b_progressive;
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
}
/**
......@@ -84,10 +84,10 @@ int vout_CountPictureAvailable( vout_thread_t *p_vout )
int i_free = 0;
int i_pic;
vlc_mutex_lock( &p_vout->picture_lock );
vlc_mutex_lock( &p_vout->p->picture_lock );
for( i_pic = 0; i_pic < I_RENDERPICTURES; i_pic++ )
{
picture_t *p_pic = PP_RENDERPICTURE[(p_vout->render.i_last_used_pic + i_pic + 1) % I_RENDERPICTURES];
picture_t *p_pic = PP_RENDERPICTURE[(p_vout->p->render.i_last_used_pic + i_pic + 1) % I_RENDERPICTURES];
switch( p_pic->i_status )
{
......@@ -103,7 +103,7 @@ int vout_CountPictureAvailable( vout_thread_t *p_vout )
break;
}
}
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
return i_free;
}
......@@ -118,14 +118,14 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
picture_t * p_freepic = NULL; /* first free picture */
/* Get lock */
vlc_mutex_lock( &p_vout->picture_lock );
vlc_mutex_lock( &p_vout->p->picture_lock );
/*
* Look for an empty place in the picture heap.
*/
for( i_pic = 0; i_pic < I_RENDERPICTURES; i_pic++ )
{
p_pic = PP_RENDERPICTURE[(p_vout->render.i_last_used_pic + i_pic + 1)
p_pic = PP_RENDERPICTURE[(p_vout->p->render.i_last_used_pic + i_pic + 1)
% I_RENDERPICTURES];
switch( p_pic->i_status )
......@@ -142,16 +142,16 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
p_pic->i_nb_fields = i_nb_fields;
p_pic->b_top_field_first = b_top_field_first;
p_vout->render.i_last_used_pic =
( p_vout->render.i_last_used_pic + i_pic + 1 )
p_vout->p->render.i_last_used_pic =
( p_vout->p->render.i_last_used_pic + i_pic + 1 )
% I_RENDERPICTURES;
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
return( p_pic );
case FREE_PICTURE:
/* Picture is empty and ready for allocation */
p_vout->render.i_last_used_pic =
( p_vout->render.i_last_used_pic + i_pic + 1 )
p_vout->p->render.i_last_used_pic =
( p_vout->p->render.i_last_used_pic + i_pic + 1 )
% I_RENDERPICTURES;
p_freepic = p_pic;
break;
......@@ -195,14 +195,14 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
msg_Err( p_vout, "picture allocation failed" );
}
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
return( p_freepic );
}
/* No free or destroyed picture could be found, but the decoder
* will try again in a while. */
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
return( NULL );
}
......@@ -210,7 +210,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
/* */
static void DestroyPicture( vout_thread_t *p_vout, picture_t *p_picture )
{
vlc_assert_locked( &p_vout->picture_lock );
vlc_assert_locked( &p_vout->p->picture_lock );
p_picture->i_status = DESTROYED_PICTURE;
picture_CleanupQuant( p_picture );
......@@ -231,13 +231,13 @@ void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
#ifndef NDEBUG
/* Check if picture status is valid */
vlc_mutex_lock( &p_vout->picture_lock );
vlc_mutex_lock( &p_vout->p->picture_lock );
if( p_pic->i_status != RESERVED_PICTURE )
{
msg_Err( p_vout, "picture to destroy %p has invalid status %d",
p_pic, p_pic->i_status );
}
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
#endif
vout_DropPicture( p_vout, p_pic );
......@@ -246,7 +246,7 @@ void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
/* */
void vout_UsePictureLocked( vout_thread_t *p_vout, picture_t *p_picture )
{
vlc_assert_locked( &p_vout->picture_lock );
vlc_assert_locked( &p_vout->p->picture_lock );
if( p_picture->i_refcount > 0 )
{
/* Pretend we displayed the picture, but don't destroy
......@@ -263,7 +263,7 @@ void vout_UsePictureLocked( vout_thread_t *p_vout, picture_t *p_picture )
/* */
void vout_DropPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->picture_lock );
vlc_mutex_lock( &p_vout->p->picture_lock );
if( p_pic->i_status == READY_PICTURE )
{
......@@ -276,7 +276,7 @@ void vout_DropPicture( vout_thread_t *p_vout, picture_t *p_pic )
vout_UsePictureLocked( p_vout, p_pic );
}
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
}
/**
......@@ -287,9 +287,9 @@ void vout_DropPicture( vout_thread_t *p_vout, picture_t *p_pic )
*/
void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->picture_lock );
vlc_mutex_lock( &p_vout->p->picture_lock );
p_pic->i_refcount++;
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
}
/**
......@@ -299,7 +299,7 @@ void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
*/
void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
vlc_mutex_lock( &p_vout->picture_lock );
vlc_mutex_lock( &p_vout->p->picture_lock );
if( p_pic->i_refcount > 0 )
p_pic->i_refcount--;
......@@ -311,7 +311,7 @@ void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
( p_pic->i_status == DISPLAYED_PICTURE || p_pic->i_status == RESERVED_PICTURE ) )
DestroyPicture( p_vout, p_pic );
vlc_mutex_unlock( &p_vout->picture_lock );
vlc_mutex_unlock( &p_vout->p->picture_lock );
}
/**
......@@ -346,7 +346,7 @@ picture_t *vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
/* The picture buffer is in slow memory. We'll use
* the "2 * VOUT_MAX_PICTURES + 1" picture as a temporary
* one for subpictures rendering. */
p_render = &p_vout->p_picture[2 * VOUT_MAX_PICTURES];
p_render = &p_vout->p->p_picture[2 * VOUT_MAX_PICTURES];
if( p_render->i_status == FREE_PICTURE )
{
vout_AllocatePicture( VLC_OBJECT(p_vout),
......
......@@ -163,9 +163,9 @@ int vout_InitWrapper(vout_thread_t *vout)
vout->fmt_in.i_visible_height != source.i_visible_height ||
vout->fmt_in.i_x_offset != source.i_x_offset ||
vout->fmt_in.i_y_offset != source.i_y_offset )
vout->i_changes |= VOUT_CROP_CHANGE;
vout->p->i_changes |= VOUT_CROP_CHANGE;
if (vout->b_on_top)
if (vout->p->b_on_top)
vout_SetWindowState(vd, VOUT_WINDOW_STATE_ABOVE);
/* XXX For non dr case, the current vout implementation force us to
......@@ -175,14 +175,14 @@ int vout_InitWrapper(vout_thread_t *vout)
sys->use_dr = !vout_IsDisplayFiltered(vd);
const bool allow_dr = !vd->info.has_pictures_invalid && sys->use_dr;
const int picture_max = allow_dr ? VOUT_MAX_PICTURES : 1;
for (vout->output.i_pictures = 0;
vout->output.i_pictures < picture_max;
vout->output.i_pictures++) {
for (vout->p->output.i_pictures = 0;
vout->p->output.i_pictures < picture_max;
vout->p->output.i_pictures++) {
/* Find an empty picture slot */
picture_t *picture = NULL;
for (int index = 0; index < VOUT_MAX_PICTURES; index++) {
if (vout->p_picture[index].i_status == FREE_PICTURE) {
picture = &vout->p_picture[index];
if (vout->p->p_picture[index].i_status == FREE_PICTURE) {
picture = &vout->p->p_picture[index];
break;
}
}
......@@ -218,7 +218,7 @@ int vout_InitWrapper(vout_thread_t *vout)
picture->i_status = DESTROYED_PICTURE;
picture->i_type = DIRECT_PICTURE;
vout->output.pp_picture[vout->output.i_pictures] = picture;
vout->p->output.pp_picture[vout->p->output.i_pictures] = picture;
}
return VLC_SUCCESS;
}
......@@ -231,7 +231,7 @@ void vout_EndWrapper(vout_thread_t *vout)
vout_sys_t *sys = vout->p->p_sys;
for (int i = 0; i < VOUT_MAX_PICTURES; i++) {
picture_t *picture = &vout->p_picture[i];
picture_t *picture = &vout->p->p_picture[i];
if (picture->i_type != DIRECT_PICTURE)
continue;
......@@ -256,29 +256,29 @@ int vout_ManageWrapper(vout_thread_t *vout)
vout_sys_t *sys = vout->p->p_sys;
vout_display_t *vd = sys->vd;
while (vout->i_changes & (VOUT_FULLSCREEN_CHANGE |
while (vout->p->i_changes & (VOUT_FULLSCREEN_CHANGE |
VOUT_ASPECT_CHANGE |
VOUT_ZOOM_CHANGE |
VOUT_SCALE_CHANGE |
VOUT_ON_TOP_CHANGE |
VOUT_CROP_CHANGE)) {
/* */
if (vout->i_changes & VOUT_FULLSCREEN_CHANGE) {
vout->b_fullscreen = !vout->b_fullscreen;
if (vout->p->i_changes & VOUT_FULLSCREEN_CHANGE) {
vout->p->b_fullscreen = !vout->p->b_fullscreen;
var_SetBool(vout, "fullscreen", vout->b_fullscreen);
vout_SetDisplayFullscreen(vd, vout->b_fullscreen);
vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
var_SetBool(vout, "fullscreen", vout->p->b_fullscreen);
vout_SetDisplayFullscreen(vd, vout->p->b_fullscreen);
vout->p->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
}
if (vout->i_changes & VOUT_ASPECT_CHANGE) {
if (vout->p->i_changes & VOUT_ASPECT_CHANGE) {
vout->fmt_out.i_sar_num = vout->fmt_in.i_sar_num;
vout->fmt_out.i_sar_den = vout->fmt_in.i_sar_den;
vout_SetDisplayAspect(vd, vout->fmt_in.i_sar_num, vout->fmt_in.i_sar_den);
vout->i_changes &= ~VOUT_ASPECT_CHANGE;
vout->p->i_changes &= ~VOUT_ASPECT_CHANGE;
}
if (vout->i_changes & VOUT_ZOOM_CHANGE) {
if (vout->p->i_changes & VOUT_ZOOM_CHANGE) {
const float zoom = var_GetFloat(vout, "scale");
unsigned den = ZOOM_FP_FACTOR;
......@@ -290,23 +290,23 @@ int vout_ManageWrapper(vout_thread_t *vout)
vout_SetDisplayZoom(vd, num, den);
vout->i_changes &= ~VOUT_ZOOM_CHANGE;
vout->p->i_changes &= ~VOUT_ZOOM_CHANGE;
}
if (vout->i_changes & VOUT_SCALE_CHANGE) {
if (vout->p->i_changes & VOUT_SCALE_CHANGE) {
const bool is_display_filled = var_GetBool(vout, "autoscale");
vout_SetDisplayFilled(vd, is_display_filled);
vout->i_changes &= ~VOUT_SCALE_CHANGE;
vout->p->i_changes &= ~VOUT_SCALE_CHANGE;
}
if (vout->i_changes & VOUT_ON_TOP_CHANGE) {
vout_SetWindowState(vd, vout->b_on_top
if (vout->p->i_changes & VOUT_ON_TOP_CHANGE) {
vout_SetWindowState(vd, vout->p->b_on_top
? VOUT_WINDOW_STATE_ABOVE
: VOUT_WINDOW_STATE_NORMAL);
vout->i_changes &= ~VOUT_ON_TOP_CHANGE;
vout->p->i_changes &= ~VOUT_ON_TOP_CHANGE;
}
if (vout->i_changes & VOUT_CROP_CHANGE) {
if (vout->p->i_changes & VOUT_CROP_CHANGE) {
const video_format_t crop = vout->fmt_in;
const video_format_t org = vout->fmt_render;
/* FIXME because of rounding errors, the reconstructed ratio is wrong */
......@@ -328,13 +328,13 @@ int vout_ManageWrapper(vout_thread_t *vout)
vout_SetDisplayCrop(vd, num, den,
crop.i_x_offset, crop.i_y_offset,
crop.i_visible_width, crop.i_visible_height);
vout->i_changes &= ~VOUT_CROP_CHANGE;
vout->p->i_changes &= ~VOUT_CROP_CHANGE;
}
}
if (sys->use_dr && vout_AreDisplayPicturesInvalid(vd)) {
vout->i_changes |= VOUT_PICTURE_BUFFERS_CHANGE;
vout->p->i_changes |= VOUT_PICTURE_BUFFERS_CHANGE;
}
vout_ManageDisplay(vd, !sys->use_dr);
return VLC_SUCCESS;
......
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