Commit 73354753 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI: implement release_surface_by_id() function.

Inside vaapi.c the function vlc_va_Release() only has a VASurfaceID when
the ffmpeg Frame buffer is no longer needed. The VA Connection struct works
with vlc_va_surface_t pointer, thus a way is needed to find the surface
which belongs to this VASurfaceID. Initially this was coded inside the
vlc_va_Release() functionality, but that exposes details that should be
remain inside va.c file.
parent 613866f9
...@@ -272,6 +272,23 @@ static void release_surface(vlc_va_conn_t *conn, vlc_va_surface_t *surface) ...@@ -272,6 +272,23 @@ static void release_surface(vlc_va_conn_t *conn, vlc_va_surface_t *surface)
vlc_mutex_unlock(&surface->lock); vlc_mutex_unlock(&surface->lock);
} }
static void release_surface_by_id(vlc_va_conn_t *conn, VASurfaceID id)
{
assert( conn );
assert( conn->pool.count > 0 );
assert( conn->pool.p_surfaces );
for( unsigned int i = 0; i < conn->pool.count; i++ )
{
vlc_va_surface_t *p_surface = &conn->pool.p_surfaces[i];
if (!p_surface)
abort();
if( p_surface->i_id == id )
release_surface(conn, p_surface);
}
}
/* Global VAAPI connection state */ /* Global VAAPI connection state */
static vlc_va_conn_t vlc_va_conn = { static vlc_va_conn_t vlc_va_conn = {
.x11 = NULL, .x11 = NULL,
...@@ -296,6 +313,7 @@ static vlc_va_conn_t vlc_va_conn = { ...@@ -296,6 +313,7 @@ static vlc_va_conn_t vlc_va_conn = {
.destroy_surfaces = destroy_surfaces, .destroy_surfaces = destroy_surfaces,
.get_surface = get_surface, .get_surface = get_surface,
.release_surface = release_surface, .release_surface = release_surface,
.release_surface_by_id = release_surface_by_id,
}; };
/* */ /* */
......
...@@ -540,17 +540,7 @@ static void Release( vlc_va_t *p_external, AVFrame *p_ff ) ...@@ -540,17 +540,7 @@ static void Release( vlc_va_t *p_external, AVFrame *p_ff )
p_va->conn->lock(); p_va->conn->lock();
VASurfaceID i_surface_id = (VASurfaceID)(uintptr_t)p_ff->data[3]; VASurfaceID i_surface_id = (VASurfaceID)(uintptr_t)p_ff->data[3];
vlc_va_conn_ReleaseSurfaceById(p_va->conn, i_surface_id);
const unsigned int count = vlc_va_conn_SurfacesCount(p_va->conn);
for( unsigned int i = 0; i < count; i++ )
{
vlc_va_surface_t *p_surface = &p_va->conn->pool.p_surfaces[i];
if (!p_surface)
abort();
if( p_surface->i_id == i_surface_id )
vlc_va_conn_ReleaseSurface(p_va->conn, p_surface);
}
p_va->conn->unlock(); p_va->conn->unlock();
} }
......
...@@ -59,6 +59,7 @@ struct vlc_va_conn_t ...@@ -59,6 +59,7 @@ struct vlc_va_conn_t
vlc_va_surface_t *(*get_surface)(vlc_va_conn_t *conn); vlc_va_surface_t *(*get_surface)(vlc_va_conn_t *conn);
void (*release_surface)(vlc_va_conn_t *conn, vlc_va_surface_t *surface); void (*release_surface)(vlc_va_conn_t *conn, vlc_va_surface_t *surface);
void (*release_surface_by_id)(vlc_va_conn_t *conn, VASurfaceID id);
}; };
/* Initialize shared connection to libva */ /* Initialize shared connection to libva */
...@@ -88,6 +89,11 @@ static inline void vlc_va_conn_ReleaseSurface(vlc_va_conn_t *conn, vlc_va_surfac ...@@ -88,6 +89,11 @@ static inline void vlc_va_conn_ReleaseSurface(vlc_va_conn_t *conn, vlc_va_surfac
conn->release_surface(conn, surface); conn->release_surface(conn, surface);
} }
static inline void vlc_va_conn_ReleaseSurfaceById(vlc_va_conn_t *conn, VASurfaceID surface_id)
{
conn->release_surface_by_id(conn, surface_id);
}
static inline unsigned int vlc_va_conn_SurfacesCount(vlc_va_conn_t *conn) static inline unsigned int vlc_va_conn_SurfacesCount(vlc_va_conn_t *conn)
{ {
return conn->pool.count; return conn->pool.count;
......
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