Commit dd50e81c authored by Laurent Aimar's avatar Laurent Aimar

Clean up crop/aspect ratio changes and associated video format.

parent 27fa51a4
......@@ -40,10 +40,6 @@ enum {
/* Controls */
VOUT_CONTROL_SOURCE_ASPECT,
VOUT_CONTROL_SOURCE_CROP_BORDER,
VOUT_CONTROL_SOURCE_CROP_RATIO,
VOUT_CONTROL_SOURCE_CROP_WINDOW,
/* OSD */
VOUT_CONTROL_OSD_MESSAGE,
......@@ -64,6 +60,11 @@ enum {
VOUT_CONTROL_ON_TOP, /* bool */
VOUT_CONTROL_DISPLAY_FILLED, /* bool */
VOUT_CONTROL_ZOOM, /* pair */
VOUT_CONTROL_ASPECT_RATIO, /* pair */
VOUT_CONTROL_CROP_BORDER, /* border */
VOUT_CONTROL_CROP_RATIO, /* pair */
VOUT_CONTROL_CROP_WINDOW, /* window */
};
typedef struct {
......@@ -86,17 +87,6 @@ typedef struct {
int channel;
char *string;
} message;
#if 0
struct {
int channel;
char *string;
text_style_t *style;
int flags;
int hmargin;
int vmargin;
mtime_t start;
mtime_t stop;
} text;
struct {
unsigned left;
unsigned top;
......@@ -109,17 +99,6 @@ typedef struct {
unsigned width;
unsigned height;
} window;
struct {
int channel;
int type;
float position;
} slider;
struct {
int channel;
int icon;
} icon;
subpicture_t *subpicture;
#endif
} u;
} vout_control_cmd_t;
......
......@@ -525,9 +525,6 @@ static void VoutDisplayEventMouse(vout_display_t *vd, int event, va_list args)
if (!vd->info.has_hide_mouse)
osys->mouse.last_moved = mdate();
/* */
vlc_mutex_unlock(&osys->lock);
/* */
vout_SendEventMouseVisible(osys->vout);
#ifdef ALLOW_DUMMY_VOUT
......@@ -535,6 +532,7 @@ static void VoutDisplayEventMouse(vout_display_t *vd, int event, va_list args)
#else
vout_SendDisplayEventMouse(osys->vout, &m);
#endif
vlc_mutex_unlock(&osys->lock);
}
static void VoutDisplayEvent(vout_display_t *vd, int event, va_list args)
......@@ -1412,7 +1410,7 @@ void vout_SendDisplayEventMouse(vout_thread_t *vout, const vlc_mouse_t *m)
vlc_mouse_t tmp;
/* The check on p_spu is needed as long as ALLOW_DUMMY_VOUT is defined */
if (vout->p->p_spu && spu_ProcessMouse( vout->p->p_spu, m, &vout->p->fmt_out))
if (vout->p->p_spu && spu_ProcessMouse( vout->p->p_spu, m, &vout->p->display.vd->source))
return;
vlc_mutex_lock( &vout->p->vfilter_lock );
......
This diff is collapsed.
......@@ -49,9 +49,7 @@ struct vout_thread_sys_t
config_chain_t *p_cfg;
/* */
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) */
video_format_t original; /* Original format ie coming from the decoder */
/* Thread & synchronization */
vlc_thread_t thread;
......@@ -129,27 +127,17 @@ struct vout_thread_sys_t
vout_chrono_t render; /**< picture render time estimator */
vlc_mutex_t change_lock; /**< thread change lock */
uint16_t i_changes; /**< changes made to the thread.
\see \ref vout_changes */
};
/** \defgroup vout_changes Flags for changes
* These flags are set in the vout_thread_t::i_changes field when another
* thread changed a variable
* @{
*/
/** cropping parameters changed */
#define VOUT_CROP_CHANGE 0x1000
/** aspect ratio changed */
#define VOUT_ASPECT_CHANGE 0x2000
/**@}*/
/* TODO to move them to vlc_vout.h */
void vout_ControlChangeFullscreen(vout_thread_t *, bool fullscreen);
void vout_ControlChangeOnTop(vout_thread_t *, bool is_on_top);
void vout_ControlChangeDisplayFilled(vout_thread_t *, bool is_filled);
void vout_ControlChangeZoom(vout_thread_t *, int num, int den);
void vout_ControlChangeSampleAspectRatio(vout_thread_t *, unsigned num, unsigned den);
void vout_ControlChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
void vout_ControlChangeCropWindow(vout_thread_t *, int x, int y, int width, int height);
void vout_ControlChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
/* */
void vout_IntfInit( vout_thread_t * );
......
This diff is collapsed.
......@@ -66,7 +66,7 @@ int vout_OpenWrapper(vout_thread_t *vout, const char *name)
sys->display.title = var_CreateGetNonEmptyString(vout, "video-title");
/* */
video_format_t source = vout->p->fmt_render;
video_format_t source = vout->p->original;
source.i_visible_width = source.i_width;
source.i_visible_height = source.i_height;
source.i_x_offset = 0;
......@@ -131,37 +131,8 @@ int vout_InitWrapper(vout_thread_t *vout)
{
vout_thread_sys_t *sys = vout->p;
vout_display_t *vd = sys->display.vd;
/* */
video_format_t source = vd->source;
vout->p->fmt_out.i_chroma = source.i_chroma;
vout->p->fmt_out.i_width =
vout->p->fmt_out.i_visible_width = source.i_width;
vout->p->fmt_out.i_height =
vout->p->fmt_out.i_visible_height = source.i_height;
if (source.i_sar_num > 0 && source.i_sar_den > 0) {
vlc_ureduce(&vout->p->fmt_out.i_sar_num, &vout->p->fmt_out.i_sar_den,
source.i_sar_num, source.i_sar_den, 0);
} else {
vout->p->fmt_out.i_sar_num = 1;
vout->p->fmt_out.i_sar_den = 1;
}
vout->p->fmt_out.i_sar_num = source.i_sar_num;
vout->p->fmt_out.i_sar_den = source.i_sar_den;
vout->p->fmt_out.i_x_offset = 0;
vout->p->fmt_out.i_y_offset = 0;
vout->p->fmt_out.i_rmask = source.i_rmask;
vout->p->fmt_out.i_gmask = source.i_gmask;
vout->p->fmt_out.i_bmask = source.i_bmask;
video_format_FixRgb(&vout->p->fmt_out);
if (vout->p->fmt_in.i_visible_width != source.i_visible_width ||
vout->p->fmt_in.i_visible_height != source.i_visible_height ||
vout->p->fmt_in.i_x_offset != source.i_x_offset ||
vout->p->fmt_in.i_y_offset != source.i_y_offset )
sys->i_changes |= VOUT_CROP_CHANGE;
/* XXX For non dr case, the current vout implementation force us to
* create at most 1 direct picture (otherwise the buffers will be kept
* referenced even through the Init/End.
......@@ -213,44 +184,6 @@ int vout_ManageWrapper(vout_thread_t *vout)
vout_thread_sys_t *sys = vout->p;
vout_display_t *vd = sys->display.vd;
while (sys->i_changes & (VOUT_ASPECT_CHANGE |
VOUT_CROP_CHANGE)) {
/* */
if (sys->i_changes & VOUT_ASPECT_CHANGE) {
vout->p->fmt_out.i_sar_num = vout->p->fmt_in.i_sar_num;
vout->p->fmt_out.i_sar_den = vout->p->fmt_in.i_sar_den;
vout_SetDisplayAspect(vd, vout->p->fmt_in.i_sar_num, vout->p->fmt_in.i_sar_den);
sys->i_changes &= ~VOUT_ASPECT_CHANGE;
}
if (sys->i_changes & VOUT_CROP_CHANGE) {
const video_format_t crop = vout->p->fmt_in;
const video_format_t org = vout->p->fmt_render;
/* FIXME because of rounding errors, the reconstructed ratio is wrong */
unsigned num = 0;
unsigned den = 0;
if (crop.i_x_offset == org.i_x_offset &&
crop.i_visible_width == org.i_visible_width &&
crop.i_y_offset == org.i_y_offset + (org.i_visible_height - crop.i_visible_height)/2) {
vlc_ureduce(&num, &den,
crop.i_visible_width * crop.i_sar_num,
crop.i_visible_height * crop.i_sar_den, 0);
} else if (crop.i_y_offset == org.i_y_offset &&
crop.i_visible_height == org.i_visible_height &&
crop.i_x_offset == org.i_x_offset + (org.i_visible_width - crop.i_visible_width)/2) {
vlc_ureduce(&num, &den,
crop.i_visible_width * crop.i_sar_num,
crop.i_visible_height * crop.i_sar_den, 0);
}
vout_SetDisplayCrop(vd, num, den,
crop.i_x_offset, crop.i_y_offset,
crop.i_visible_width, crop.i_visible_height);
sys->i_changes &= ~VOUT_CROP_CHANGE;
}
}
bool reset_display_pool = sys->display.use_dr && vout_AreDisplayPicturesInvalid(vd);
vout_ManageDisplay(vd, !sys->display.use_dr || reset_display_pool);
......
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