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

codec/avcodec/vaapi*: Smooth subtitle subpicture display.

The subtitle subpictures are regenerated for each call to vd->Prepare.
This is not very efficient and results in flickering display of subtitles.
Implement a VASubpicture's cache to solve the flickering.
parent 78d2cc9e
...@@ -216,6 +216,7 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t ...@@ -216,6 +216,7 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
p_surface->i_id = pi_surface_id[i]; p_surface->i_id = pi_surface_id[i];
p_surface->i_refcount = 0; p_surface->i_refcount = 0;
p_surface->i_order = 0; p_surface->i_order = 0;
p_surface->i_cache = VA_INVALID_ID;
} }
/* Create a context */ /* Create a context */
...@@ -429,8 +430,6 @@ static int DisplayPicture( vlc_va_t *p_external, picture_t *p_picture, AVFrame * ...@@ -429,8 +430,6 @@ static int DisplayPicture( vlc_va_t *p_external, picture_t *p_picture, AVFrame *
if( !p_picture->p_sys->surface ) if( !p_picture->p_sys->surface )
abort(); abort();
assert(p_picture->p_sys->surface->subpicture == NULL);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -462,13 +461,6 @@ static int Get( vlc_va_t *p_external, AVFrame *p_ff ) ...@@ -462,13 +461,6 @@ static int Get( vlc_va_t *p_external, AVFrame *p_ff )
p_surface->i_refcount++; p_surface->i_refcount++;
p_surface->i_order = p_va->i_surface_order++; p_surface->i_order = p_va->i_surface_order++;
if (p_surface->subpicture)
SubpictureDestroy( p_va->conn, &p_surface->i_id,
p_surface->subpicture, p_surface->i_sub );
p_surface->subpicture = NULL;
p_surface->i_sub = 0;
/* */ /* */
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
...@@ -513,45 +505,6 @@ static void Delete( vlc_va_t *p_external ) ...@@ -513,45 +505,6 @@ static void Delete( vlc_va_t *p_external )
free( p_va ); free( p_va );
} }
/* */
void SubpictureDestroy( vlc_va_conn_t *p_connection, VASurfaceID *i_surface_id,
vlc_va_subpicture_t *subpicture, const int i_sub )
{
VAStatus status;
for( int i = 0; i < i_sub; i++ )
{
if( ((*i_surface_id) != VA_INVALID_SURFACE) &&
(subpicture[i].i_id != VA_INVALID_ID) )
{
status = vaDeassociateSubpicture( p_connection->p_display, subpicture[i].i_id,
i_surface_id, 1) ;
assert( status == VA_STATUS_SUCCESS );
}
if( subpicture[i].i_id != VA_INVALID_ID )
{
status = vaDestroySubpicture( p_connection->p_display,
subpicture[i].i_id );
assert( status == VA_STATUS_SUCCESS );
}
if( subpicture[i].image.image_id != VA_INVALID_ID )
{
status = vaDestroyImage( p_connection->p_display,
subpicture[i].image.image_id );
assert( status == VA_STATUS_SUCCESS );
}
subpicture[i].image.image_id = VA_INVALID_ID;
subpicture[i].image.buf = VA_INVALID_ID;
subpicture[i].i_id = VA_INVALID_ID;
}
/* */
free( subpicture );
}
/* */ /* */
vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id ) vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id )
{ {
......
...@@ -27,12 +27,6 @@ struct vlc_va_conn_t ...@@ -27,12 +27,6 @@ struct vlc_va_conn_t
int i_ref_count; /* for internal use only */ int i_ref_count; /* for internal use only */
}; };
typedef struct
{
VASubpictureID i_id; /* VASubpictureIDs */
VAImage image;
} vlc_va_subpicture_t;
typedef struct typedef struct
{ {
VASurfaceID i_id; VASurfaceID i_id;
...@@ -40,8 +34,7 @@ typedef struct ...@@ -40,8 +34,7 @@ typedef struct
unsigned int i_order; unsigned int i_order;
/* subpicture */ /* subpicture */
vlc_va_subpicture_t *subpicture; unsigned int i_cache;
unsigned int i_sub; /* number of vlc_va_subpicures_t */
} vlc_va_surface_t; } vlc_va_surface_t;
struct picture_sys_t struct picture_sys_t
...@@ -50,7 +43,4 @@ struct picture_sys_t ...@@ -50,7 +43,4 @@ struct picture_sys_t
vlc_va_surface_t *surface; vlc_va_surface_t *surface;
}; };
void SubpictureDestroy( vlc_va_conn_t *p_connection, VASurfaceID *i_surface_id,
vlc_va_subpicture_t *subpicture, const int i_sub );
#endif #endif
This diff is collapsed.
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