+ p_sys->p_va = vlc_va_NewVaapi( p_sys->i_codec_id );
+ if( !p_sys->p_va )
+ msg_Warn( p_dec, "Failed to open VA API" );
+#else
+ continue;
+#endif
+ }
+#ifdef HAVE_AVCODEC_DXVA2
+ if( pi_fmt[i] == PIX_FMT_DXVA2_VLD )
+ {
+ msg_Dbg( p_dec, "Trying DXVA2" );
+ p_sys->p_va = vlc_va_NewDxva2( VLC_OBJECT(p_dec), p_sys->i_codec_id );
+ if( !p_sys->p_va )
+ msg_Warn( p_dec, "Failed to open DXVA2" );
+ }
+#endif
+
+ if( p_sys->p_va &&
+ p_sys->p_context->width > 0 && p_sys->p_context->height > 0 )
+ {
+ /* We try to call vlc_va_Setup when possible to detect errors when
+ * possible (later is too late) */
+ if( vlc_va_Setup( p_sys->p_va,
+ &p_sys->p_context->hwaccel_context,
+ &p_dec->fmt_out.video.i_chroma,
+ p_sys->p_context->width, p_sys->p_context->height ) )