[vlc-devel] [PATCH] avcodec: only assume DXVA2 is used if it's forced

Rémi Denis-Courmont remi at remlab.net
Tue Mar 31 13:04:19 CEST 2015


Le 2015-03-31 13:06, Steve Lhomme a écrit :
>> No, the format is not *fully* known at this point, at least not
>> systematically. libavcodec provides the final format only upon 
>> get_format() or
>> get_buffer() callback invocation. (In the latter case, it means that 
>> hardware
>> acceleration is not supported.)
>>
>> Hardware capability checking can only happen within 
>> ffmpeg_GetFormat(),
>> specifically vlc_va_New().
>
> Looking at the FFMpeg code, this is only called when starting to
> decode a frame. At this stage the threading model is already picked.

Sure - that is pretty much what I wrote. The hardware decoder needs to 
operate correctly with threads, even if the extra threads are wasteful.

> Our ffmpeg_GetFormat() is called with a list of possible output pixel
> formats the codec can handle.


> When we do the FF_THREAD_FRAME toggling, we already which codec is
> going to be used.

The only thing you know for sure is the codec. You don't necessarily 
know the profile, level, resolution and DPB size, all of which are 
relevant when checking hardware capabilities. Indeed for AVC and HEVC, 
the profile and level can change dynamically (not sure about other 
codecs).

> Unfortunately they don't always provide a hardcoded list of output
> formats they support (at least not H264).

It is not unfortunate. It is impossible. There is no hardware decoder 
that supports all profiles and levels of AVC.

> So we cannot use that codec object to try to find out
> if DXVA2 is going to be used or not.
>
> That only leaves us to guess if DXVA2 is going to be used or not. 
> I'll
> submit a better patch.

You can try to second-guess the effect of the avcodec-hw setting. But:
1) That will force single thread software decoding for higher codec 
profiles, likely rendering those computationally intensive streams 
unplayable.
2) It cannot be future-proof w.r.t. hypothetical other hwaccel plugins 
on the same platform (e.g. using Intel's or NVIDIA's respective 
frameworks).

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list