Commit 1337cbe7 authored by Jean-Paul Saman's avatar Jean-Paul Saman

VAAPI-XCB: move FindVAFourCC() to common code.

Move FindVAFourCC() to common code file.
parent e3a7fd1f
......@@ -105,50 +105,7 @@ static void DisplayPicture(vout_display_t *, picture_t *, subpicture_t *);
static int Control(vout_display_t *, int, va_list);
static void Manage(vout_display_t *);
/* VA API support functions */
static int FindVAFourCC(vlc_va_conn_t *vaconn, VAImageFormat *fmt,
vlc_fourcc_t *i_chroma, int32_t *i_bits_per_pixel)
{
vaconn->lock();
/* Find and create a supported image chroma */
int i_fmt_count = vaMaxNumImageFormats(vaconn->p_display);
VAImageFormat *p_fmt = calloc(i_fmt_count, sizeof(*p_fmt));
if( !p_fmt )
goto error;
if( vaQueryImageFormats(vaconn->p_display, p_fmt, &i_fmt_count) )
{
free( p_fmt );
goto error;
}
*i_chroma = 0;
*i_bits_per_pixel = 0;
for( int i = 0; i < i_fmt_count; i++ )
{
if( p_fmt[i].fourcc == VA_FOURCC( 'Y', 'V', '1', '2' ) ||
p_fmt[i].fourcc == VA_FOURCC( 'I', '4', '2', '0' ) ||
p_fmt[i].fourcc == VA_FOURCC( 'N', 'V', '1', '2' ) )
{
memcpy((void*)fmt, (void*)&p_fmt[i], sizeof(VAImageFormat));
*i_chroma = VLC_CODEC_YV12;
*i_bits_per_pixel = p_fmt[i].bits_per_pixel;
break;
}
}
free( p_fmt );
if( *i_chroma == 0 )
goto error;
vaconn->unlock();
return VLC_SUCCESS;
error:
vaconn->unlock();
return VLC_EGENERIC;
}
/* */
static vout_window_t *MakeWindow(vout_display_t *vd)
{
vout_window_cfg_t wnd_cfg;
......
......@@ -188,6 +188,50 @@ out_warning:
return VLC_EGENERIC;
}
/* VA API support functions */
int FindVAFourCC(vlc_va_conn_t *vaconn, VAImageFormat *fmt,
vlc_fourcc_t *i_chroma, int32_t *i_bits_per_pixel)
{
vaconn->lock();
/* Find and create a supported image chroma */
int i_fmt_count = vaMaxNumImageFormats(vaconn->p_display);
VAImageFormat *p_fmt = calloc(i_fmt_count, sizeof(*p_fmt));
if( !p_fmt )
goto error;
if( vaQueryImageFormats(vaconn->p_display, p_fmt, &i_fmt_count) )
{
free( p_fmt );
goto error;
}
*i_chroma = 0;
*i_bits_per_pixel = 0;
for( int i = 0; i < i_fmt_count; i++ )
{
if( p_fmt[i].fourcc == VA_FOURCC( 'Y', 'V', '1', '2' ) ||
p_fmt[i].fourcc == VA_FOURCC( 'I', '4', '2', '0' ) ||
p_fmt[i].fourcc == VA_FOURCC( 'N', 'V', '1', '2' ) )
{
memcpy((void*)fmt, (void*)&p_fmt[i], sizeof(VAImageFormat));
*i_chroma = VLC_CODEC_YV12;
*i_bits_per_pixel = p_fmt[i].bits_per_pixel;
break;
}
}
free( p_fmt );
if( *i_chroma == 0 )
goto error;
vaconn->unlock();
return VLC_SUCCESS;
error:
vaconn->unlock();
return VLC_EGENERIC;
}
static inline void vaapi_fixup_alpha(uint8_t *p_pixel, size_t i_size)
{
for (size_t p = 0; p < i_size; p += 4)
......
......@@ -22,6 +22,7 @@
/* Check if subtitle format is supported by VA API */
int VASubtitleFourCC(vlc_va_conn_t *vaconn, const unsigned int vafourcc, VAImageFormat *sub_fmt, int *flags);
int FindVAFourCC(vlc_va_conn_t *vaconn, VAImageFormat *fmt, vlc_fourcc_t *i_chroma, int32_t *i_bits_per_pixel);
/* */
typedef struct vasubpicture_cache_t vasubpicture_cache_t;
......
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