Commit 2646cc96 authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi_x11.c: fix scaling.

vout_display_NewWindow() expects that wnd_cfg.width and wnd_cfg.height are the
fullscreen size of current display. Otherwise scaling to larger sizes then the
decoded picture size is not going to work.
parent d27eed3c
......@@ -91,6 +91,9 @@ struct vout_display_sys_t
unsigned int i_display_order;
bool visible; /* whether to draw */
/* */
Window window;
};
static picture_pool_t *Pool (vout_display_t *, unsigned);
......@@ -299,12 +302,20 @@ static vout_window_t *MakeWindow (vout_display_t *vd)
{
vout_window_cfg_t wnd_cfg;
/* FIXME: Correct vout_window_t display size
* looks like it assumes fullscreen for
* vout_display_PlacePicture() to work as expected. */
unsigned int width, height;
int screen = DefaultScreen(vd->sys->conn->p_display_x11);
width = DisplayWidth(vd->sys->conn->p_display_x11, screen);
height = DisplayHeight(vd->sys->conn->p_display_x11, screen);
memset (&wnd_cfg, 0, sizeof (wnd_cfg));
wnd_cfg.type = VOUT_WINDOW_TYPE_XID;
wnd_cfg.x = var_InheritInteger (vd, "video-x");
wnd_cfg.y = var_InheritInteger (vd, "video-y");
wnd_cfg.width = vd->cfg->display.width;
wnd_cfg.height = vd->cfg->display.height;
wnd_cfg.width = width;
wnd_cfg.height = height;
vout_window_t *wnd = vout_display_NewWindow (vd, &wnd_cfg);
if (wnd == NULL)
......@@ -312,6 +323,28 @@ static vout_window_t *MakeWindow (vout_display_t *vd)
return wnd;
}
static int GetWindowSize(vout_display_t *vd, unsigned int *pi_width, unsigned int *pi_height)
{
vout_display_sys_t *sys = vd->sys;
Status status;
Window root_window;
int x, y;
unsigned int bw, depth;
status = XGetGeometry(sys->conn->p_display_x11,
sys->embed->handle.xid,
&root_window,
&x, &y, pi_width, pi_height,
&bw, &depth);
if (status == 0)
{
msg_Err(vd, "failed getting geometry");
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
/**
* Probe the X server.
*/
......@@ -340,15 +373,15 @@ int OpenVaapiX11 (vlc_object_t *obj)
sys->visible = false;
sys->embed = MakeWindow(vd);
if (unlikely(sys->embed == NULL))
goto error;
/* Create a VA display */
sys->conn = vlc_va_Initialize(sys->embed->display.x11);
sys->conn = vlc_va_Initialize(NULL);
if (!sys->conn)
goto error;
sys->embed = MakeWindow(vd);
if (unlikely(sys->embed == NULL))
goto error;
if (FindVAFourCC(vd) != VLC_SUCCESS)
goto error;
......@@ -385,8 +418,12 @@ int OpenVaapiX11 (vlc_object_t *obj)
if (is_fullscreen && vout_window_SetFullScreen (sys->embed, true))
is_fullscreen = false;
vout_display_SendEventFullscreen (vd, is_fullscreen);
vout_display_SendEventDisplaySize (vd, vd->cfg->display.width, vd->cfg->display.height, is_fullscreen);
unsigned int width, height;
if (GetWindowSize(vd, &width, &height) == VLC_SUCCESS)
{
vout_window_SetSize (sys->embed, width, height);
vout_display_SendEventDisplaySize (vd, width, height, is_fullscreen);
}
return VLC_SUCCESS;
error:
......@@ -399,13 +436,10 @@ void CloseVaapiX11 (vlc_object_t *obj)
vout_display_t *vd = (vout_display_t *) obj;
vout_display_sys_t *sys = (vout_display_sys_t *) vd->sys;
if (sys->conn)
if (sys->conn && sys->conn->p_display_x11)
{
if (sys->conn->p_display_x11)
{
XFlush(sys->conn->p_display_x11);
XSync(sys->conn->p_display_x11, False);
}
XFlush(sys->conn->p_display_x11);
XSync(sys->conn->p_display_x11, False);
}
if (sys->embed)
......@@ -466,8 +500,6 @@ static int Control (vout_display_t *vd, int query, va_list ap)
case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
{
/* I am not sure it is always necessary, but it is way simpler ... */
/* FIXME: adjust picture size */
const vout_display_cfg_t *cfg;
const video_format_t *source;
bool is_forced = false;
......
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