Postby oviano » 08 May 2017 16:35
I will share a sample as soon as I can put one together.
Actually, I have also come across the same problem as in your original post.
I've traced it through and I think I can see what is going on.
In va.c there is this code:
vlc_fourcc_t chroma;
vlc_fourcc_t expected = vlc_va_GetChroma( pix_fmt, avctx->sw_pix_fmt );
va->setup(va, &chroma);
if (chroma != expected)
{ /* Mismatch, cannot work, fail */
msg_Dbg( obj, "chroma mismatch %4.4s expected %4.4s",
(const char*)&chroma, (const char*) &expected );
vlc_va_Delete(va, avctx);
I think this is always going to produce a mismatch when using libvlc and trying to use dxva because inside va->setup (dxva2.c) is this code...
static void Setup(vlc_va_t *va, vlc_fourcc_t *chroma)
{
vlc_va_sys_t *sys = va->sys;
*chroma = sys->filter == NULL ? sys->i_chroma : VLC_CODEC_YV12;
}
...in this situation, sys_filter will have been created due to this code...
if (p_sys == NULL)
{
msg_Dbg(va, "DXVA2 : p_sys is NULL, so creating filter");
sys->filter = CreateFilter( VLC_OBJECT(va), fmt, sys->i_chroma);
if (sys->filter == NULL) {
msg_Dbg(va, "DXVA2 : couldn't create filter");
goto error;
}
}
...i.e. p_sys is NULL.
I need to investigate some more but I think the chroma mismatch check should be wrapped in a check for p_sys, like this:
if (p_sys) {
vlc_fourcc_t chroma;
vlc_fourcc_t expected = vlc_va_GetChroma( pix_fmt, avctx->sw_pix_fmt );
va->setup(va, &chroma);
if (chroma != expected)
{ /* Mismatch, cannot work, fail */
msg_Dbg( obj, "chroma mismatch %4.4s expected %4.4s",
(const char*)&chroma, (const char*) &expected );
vlc_va_Delete(va, avctx);
va = NULL;
}
}
However, if we wanted to actually have the opaque DXVA decoded surface passed to the vmem callback a similar manner to how I am doing on iOS using the CVPN, then we actually don't want to create the filter anyway because we don't want it converted.
Even if we do want it converted, I would have expected that a filter would get created automatically anyway when we asked for a different chroma to DXA9.
So I wonder why DXVA2 and D3D11VA are creating these filters automatically, there must be a reason somewhere else?