Commit 92f80c3f authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI: cleanup and small improvements.

parent 848a0b43
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
#include "va.h" #include "va.h"
#include "vaapi.h" #include "vaapi.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static vlc_mutex_t vlc_va_conn_lock = VLC_STATIC_MUTEX; static vlc_mutex_t vlc_va_conn_lock = VLC_STATIC_MUTEX;
static vlc_va_conn_t vlc_va_conn; static vlc_va_conn_t vlc_va_conn;
......
...@@ -395,11 +395,19 @@ static int CreateDecodingContext( vlc_va_sys_t *p_va, void **pp_hw_ctx, vlc_four ...@@ -395,11 +395,19 @@ static int CreateDecodingContext( vlc_va_sys_t *p_va, void **pp_hw_ctx, vlc_four
p_va->image.image_id = VA_INVALID_ID; p_va->image.image_id = VA_INVALID_ID;
continue; continue;
} }
bool b_workaround = false;
const char *psz_driver = getenv("VDPAU_DRIVER");
if( psz_driver && (strcmp(psz_driver, "via") == 0) )
b_workaround = true;
/* Validate that vaGetImage works with this format */ /* Validate that vaGetImage works with this format */
if( vaGetImage( p_va->conn->p_display, VAStatus err;
p_va->conn->pool.p_surfaces[0].i_id, err = vaGetImage( p_va->conn->p_display,
0, 0, i_width, i_height, p_va->conn->pool.p_surfaces[0].i_id,
p_va->image.image_id ) ) 0, 0, i_width, i_height,
p_va->image.image_id );
if( err != VA_STATUS_SUCCESS && !b_workaround )
{ {
vaDestroyImage( p_va->conn->p_display, p_va->image.image_id ); vaDestroyImage( p_va->conn->p_display, p_va->image.image_id );
p_va->image.image_id = VA_INVALID_ID; p_va->image.image_id = VA_INVALID_ID;
...@@ -555,23 +563,24 @@ static void Put(vlc_va_t *p_external, AVFrame *p_ff, picture_t *p_picture ) ...@@ -555,23 +563,24 @@ static void Put(vlc_va_t *p_external, AVFrame *p_ff, picture_t *p_picture )
{ {
vlc_va_sys_t *p_va = p_external->sys; vlc_va_sys_t *p_va = p_external->sys;
p_va->conn->lock(); for (unsigned i = 0; i < AV_NUM_DATA_POINTERS; i++)
{
p_ff->data[i] = NULL;
p_ff->linesize[i] = 0;
}
if (!p_picture->p_sys) if (!p_picture->p_sys)
abort(); abort();
p_va->conn->lock();
picture_sys_t *p_surface = p_picture->p_sys; picture_sys_t *p_surface = p_picture->p_sys;
assert(p_surface->i_refcount == 2); assert(p_surface->i_refcount == 2);
/* */ /* */
for( int i = 0; i < 4; i++ ) p_ff->data[0] = (void *)(uintptr_t)p_surface->i_id; /* must be non-NULL */
{ p_ff->data[3] = (void *)(uintptr_t)p_surface->i_id;
p_ff->data[i] = NULL; p_ff->opaque = (void *)p_picture;
p_ff->linesize[i] = 0;
if( i == 0 || i == 3 )
p_ff->data[i] = (void*)(uintptr_t)p_surface->i_id;/* Yummie */
}
p_va->conn->unlock(); p_va->conn->unlock();
} }
...@@ -725,4 +734,3 @@ static int Create( vlc_va_t *p_va, int i_codec_id, const es_format_t *fmt ) ...@@ -725,4 +734,3 @@ static int Create( vlc_va_t *p_va, int i_codec_id, const es_format_t *fmt )
p_va->query = QuerySurfaceReady; p_va->query = QuerySurfaceReady;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -236,8 +236,8 @@ static int InitializeGLXv13(vout_display_t *vd) ...@@ -236,8 +236,8 @@ static int InitializeGLXv13(vout_display_t *vd)
} }
sys->glwin = None; sys->glwin = None;
if (!CreateWindow(vd, sys->embed, sys->conn, depth, 0 /* ??? */, if (CreateWindow(vd, sys->embed, sys->conn, depth, 0 /* ??? */,
width, height, &sys->window)) width, height, &sys->window) == VLC_SUCCESS)
sys->glwin = glXCreateWindow(dpy, conf, sys->window, NULL ); sys->glwin = glXCreateWindow(dpy, conf, sys->window, NULL );
if (sys->glwin == None) if (sys->glwin == None)
{ {
...@@ -560,11 +560,7 @@ int OpenVaapiGLX(vlc_object_t *obj) ...@@ -560,11 +560,7 @@ int OpenVaapiGLX(vlc_object_t *obj)
CloseVaapiGLX(obj); CloseVaapiGLX(obj);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
#if 1 /* DEBUG CODE */
msg_Dbg(vd, "video output format size %d x %d (%d x %d)",
vd->fmt.i_width, vd->fmt.i_height,
vd->fmt.i_visible_width, vd->fmt.i_visible_height);
#endif
/* */ /* */
vout_display_info_t info = vd->info; vout_display_info_t info = vd->info;
info.is_slow = false; info.is_slow = 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