Commit e967b401 authored by Timo Rothenpieler's avatar Timo Rothenpieler Committed by Rafaël Carré

vaapi: Use vaDeriveImage instead of vaGetImage if available

Signed-off-by: default avatarRafaël Carré <funman@videolan.org>
parent 7e51f279
...@@ -85,6 +85,7 @@ typedef struct ...@@ -85,6 +85,7 @@ typedef struct
VAImage image; VAImage image;
copy_cache_t image_cache; copy_cache_t image_cache;
bool b_supports_derive;
} vlc_va_vaapi_t; } vlc_va_vaapi_t;
static vlc_va_vaapi_t *vlc_va_vaapi_Get( void *p_va ) static vlc_va_vaapi_t *vlc_va_vaapi_Get( void *p_va )
...@@ -188,6 +189,8 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id ) ...@@ -188,6 +189,8 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id )
p_va->i_surface_count = i_surface_count; p_va->i_surface_count = i_surface_count;
p_va->b_supports_derive = false;
if( asprintf( &p_va->va.description, "VA API version %d.%d", if( asprintf( &p_va->va.description, "VA API version %d.%d",
p_va->i_version_major, p_va->i_version_minor ) < 0 ) p_va->i_version_major, p_va->i_version_minor ) < 0 )
p_va->va.description = NULL; p_va->va.description = NULL;
...@@ -205,6 +208,10 @@ static void DestroySurfaces( vlc_va_vaapi_t *p_va ) ...@@ -205,6 +208,10 @@ static void DestroySurfaces( vlc_va_vaapi_t *p_va )
CopyCleanCache( &p_va->image_cache ); CopyCleanCache( &p_va->image_cache );
vaDestroyImage( p_va->p_display, p_va->image.image_id ); vaDestroyImage( p_va->p_display, p_va->image.image_id );
} }
else if(p_va->b_supports_derive)
{
CopyCleanCache( &p_va->image_cache );
}
if( p_va->i_context_id != VA_INVALID_ID ) if( p_va->i_context_id != VA_INVALID_ID )
vaDestroyContext( p_va->p_display, p_va->i_context_id ); vaDestroyContext( p_va->p_display, p_va->i_context_id );
...@@ -277,6 +284,13 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t ...@@ -277,6 +284,13 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
goto error; goto error;
} }
VAImage testImage;
if(vaDeriveImage(p_va->p_display, pi_surface_id[0], &testImage) == VA_STATUS_SUCCESS)
{
p_va->b_supports_derive = true;
vaDestroyImage(p_va->p_display, testImage.image_id);
}
vlc_fourcc_t i_chroma = 0; vlc_fourcc_t i_chroma = 0;
VAImageFormat fmt; VAImageFormat fmt;
for( int i = 0; i < i_fmt_count; i++ ) for( int i = 0; i < i_fmt_count; i++ )
...@@ -310,6 +324,12 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t ...@@ -310,6 +324,12 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
goto error; goto error;
*pi_chroma = i_chroma; *pi_chroma = i_chroma;
if(p_va->b_supports_derive)
{
vaDestroyImage( p_va->p_display, p_va->image.image_id );
p_va->image.image_id = VA_INVALID_ID;
}
if( unlikely(CopyInitCache( &p_va->image_cache, i_width )) ) if( unlikely(CopyInitCache( &p_va->image_cache, i_width )) )
goto error; goto error;
...@@ -368,14 +388,18 @@ static int Extract( vlc_va_t *p_external, picture_t *p_picture, AVFrame *p_ff ) ...@@ -368,14 +388,18 @@ static int Extract( vlc_va_t *p_external, picture_t *p_picture, AVFrame *p_ff )
#endif #endif
return VLC_EGENERIC; return VLC_EGENERIC;
/* XXX vaDeriveImage may be better but it is not supported by if(p_va->b_supports_derive)
* my setup. {
*/ if(vaDeriveImage(p_va->p_display, i_surface_id, &(p_va->image)) != VA_STATUS_SUCCESS)
return VLC_EGENERIC;
if( vaGetImage( p_va->p_display, i_surface_id, }
0, 0, p_va->i_surface_width, p_va->i_surface_height, else
p_va->image.image_id) ) {
return VLC_EGENERIC; if( vaGetImage( p_va->p_display, i_surface_id,
0, 0, p_va->i_surface_width, p_va->i_surface_height,
p_va->image.image_id) )
return VLC_EGENERIC;
}
void *p_base; void *p_base;
if( vaMapBuffer( p_va->p_display, p_va->image.buf, &p_base ) ) if( vaMapBuffer( p_va->p_display, p_va->image.buf, &p_base ) )
...@@ -420,6 +444,12 @@ static int Extract( vlc_va_t *p_external, picture_t *p_picture, AVFrame *p_ff ) ...@@ -420,6 +444,12 @@ static int Extract( vlc_va_t *p_external, picture_t *p_picture, AVFrame *p_ff )
if( vaUnmapBuffer( p_va->p_display, p_va->image.buf ) ) if( vaUnmapBuffer( p_va->p_display, p_va->image.buf ) )
return VLC_EGENERIC; return VLC_EGENERIC;
if(p_va->b_supports_derive)
{
vaDestroyImage( p_va->p_display, p_va->image.image_id );
p_va->image.image_id = VA_INVALID_ID;
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int Get( vlc_va_t *p_external, AVFrame *p_ff ) static int Get( vlc_va_t *p_external, AVFrame *p_ff )
......
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