diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c index b22b24824dfd2f9a3414b11d5e679e0b72be5880..c4e3e00c58903cf6dc5e774f197be34045ef1c88 100644 --- a/modules/codec/avcodec/dxva2.c +++ b/modules/codec/avcodec/dxva2.c @@ -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")); diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h index 8753212683ee4ff17814a6fea3b25d7a43fa9bfa..8ed093dac2931aa1afb8bb24f7a940fa588f65d1 100644 --- a/modules/codec/avcodec/va.h +++ b/modules/codec/avcodec/va.h @@ -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 - diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c index cc7eaca4445cfdd8547a60999b436de91b4032ad..450f379dcc993aec31364fef0fb5c8d702388346 100644 --- a/modules/codec/avcodec/vaapi.c +++ b/modules/codec/avcodec/vaapi.c @@ -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 ) ) { diff --git a/modules/codec/avcodec/vda.c b/modules/codec/avcodec/vda.c index c8c08734adfde3c44bc0072ff1ad7ab5d22e1207..b8cb1592f779716955564d180c08f119b9453beb 100644 --- a/modules/codec/avcodec/vda.c +++ b/modules/codec/avcodec/vda.c @@ -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; diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c index 738f69ed88fff9b32a3722fb0cbe68fd4e5c141c..042764df4b1df7467acc338471085af7f56a2b73 100644 --- a/modules/codec/avcodec/video.c +++ b/modules/codec/avcodec/video.c @@ -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" );