Commit 6a258c95 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: unify interface for video acceleration

parent f95cb82f
......@@ -496,8 +496,12 @@ static void Close(vlc_va_t *external)
free(va);
}
vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id)
vlc_va_t *vlc_va_New(vlc_object_t *log, int pixfmt, int codec_id,
const es_format_t *fmt)
{
if( pixfmt != PIX_FMT_DXVA2_VLD )
return NULL;
vlc_va_dxva2_t *va = calloc(1, sizeof(*va));
if (!va)
return NULL;
......@@ -505,6 +509,7 @@ vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id)
/* */
va->log = log;
va->codec_id = codec_id;
(void) fmt;
/* Load dll*/
va->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL"));
......
......@@ -58,9 +58,6 @@ static inline void vlc_va_Delete(vlc_va_t *va)
va->close(va);
}
vlc_va_t *vlc_va_NewVaapi(vlc_object_t *obj, int codec_id);
vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id);
vlc_va_t *vlc_va_NewVDA( vlc_object_t *log, int i_codec_id,void *p_extra, int i_extra);
vlc_va_t *vlc_va_New(vlc_object_t *, int pix, int codec, const es_format_t *);
#endif
......@@ -506,8 +506,13 @@ static void Delete( vlc_va_t *p_external )
}
/* */
vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id )
vlc_va_t *vlc_va_New( vlc_object_t *obj, int pixfmt, int i_codec_id,
const es_format_t *fmt )
{
/* Only VLD supported */
if( pixfmt != PIX_FMT_VAAPI_VLD )
return NULL;
if( !vlc_xlib_init( obj ) )
{
msg_Warn( obj, "Ignoring VA API" );
......@@ -519,6 +524,7 @@ vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id )
return NULL;
p_va->log = obj;
(void) fmt;
if( Open( p_va, i_codec_id ) )
{
......
......@@ -44,7 +44,7 @@ typedef struct
vlc_va_t va;
struct vda_context hw_ctx;
uint8_t *p_extradata;
const uint8_t *p_extradata;
int i_extradata;
vlc_fourcc_t i_chroma;
......@@ -242,12 +242,13 @@ static void Close( vlc_va_t *p_external )
free( p_va );
}
vlc_va_t *vlc_va_NewVDA( vlc_object_t *p_log, int i_codec_id, void *p_extra, int i_extra )
vlc_va_t *vlc_va_New( vlc_object_t *p_log, int pixfmt, int i_codec_id,
const es_format_t *fmt )
{
if( i_codec_id != CODEC_ID_H264 )
if( pixfmt != PIX_FMT_VDA_VLD || i_codec_id != CODEC_ID_H264 )
return NULL;
if( !p_extra || i_extra < 7 )
if( fmt->p_extra == NULL || fmt->i_extra < 7 )
{
msg_Warn( p_log, "VDA requires extradata." );
return NULL;
......@@ -258,8 +259,8 @@ vlc_va_t *vlc_va_NewVDA( vlc_object_t *p_log, int i_codec_id, void *p_extra, int
return NULL;
p_va->p_log = p_log;
p_va->p_extradata = p_extra;
p_va->i_extradata = i_extra;
p_va->p_extradata = fmt->p_extra;
p_va->i_extradata = fmt->i_extra;
p_va->va.setup = Setup;
p_va->va.get = Get;
......
......@@ -1144,31 +1144,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
msg_Dbg( p_dec, "Available decoder output format %d (%s)", pi_fmt[i],
name ? name : "unknown" );
vlc_va_t *p_va = NULL;
#ifdef HAVE_AVCODEC_VAAPI
/* Only VLD supported */
if( pi_fmt[i] == PIX_FMT_VAAPI_VLD )
{
msg_Dbg( p_dec, "Trying VA API" );
p_va = vlc_va_NewVaapi( VLC_OBJECT(p_dec), p_sys->i_codec_id );
}
#endif
#ifdef HAVE_AVCODEC_DXVA2
if( pi_fmt[i] == PIX_FMT_DXVA2_VLD )
{
msg_Dbg( p_dec, "Trying DXVA2" );
p_va = vlc_va_NewDxva2( VLC_OBJECT(p_dec), p_sys->i_codec_id );
}
#endif
#ifdef HAVE_AVCODEC_VDA
if( pi_fmt[i] == PIX_FMT_VDA_VLD )
{
msg_Dbg( p_dec, "Trying VDA" );
p_va = vlc_va_NewVDA( VLC_OBJECT(p_dec), p_sys->i_codec_id, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
}
#endif
vlc_va_t *p_va = vlc_va_New( VLC_OBJECT(p_dec), pi_fmt[i], p_sys->i_codec_id, &p_dec->fmt_in );
if( p_va == NULL )
{
msg_Dbg( p_dec, "acceleration not available" );
......
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