[FFmpeg-devel] [RFC] d3dva security hw+threads

Anton Khirnov anton at khirnov.net
Mon Sep 5 19:13:02 EEST 2022


Quoting Lukas Fellechner (2022-09-05 17:50:26)
> > Gesendet: Freitag, 02. September 2022 um 01:46 Uhr
> > Von: "Timo Rothenpieler" <timo at rothenpieler.org>
> > An: ffmpeg-devel at ffmpeg.org
> > Betreff: Re: [FFmpeg-devel] [RFC] d3dva security hw+threads
> > On 02.09.2022 01:32, Michael Niedermayer wrote:
> >> Hi all
> >>
> >> Theres a use after free issue in H.264 Decoding on d3d11va with multiple threads
> >> I dont have the hardware/platform nor do i know the hw decoding code so i made
> >> no attempt to fix this beyond asking others to ...
> >
> > hwaccel with multiple threads being broken is not exactly a surprise.
> > So we could just disable that, and always have it be one single thread?
> 
> I am using FFmpeg as decoder library in a video player, either with sw decoding
> or d3d11va. Originally, I had threads set to auto in all cases. While it worked
> for some codecs such as H.264, it produced garbage output for other codecs.
> I think VP8/VP9 are severly broken with threading+d3d11va. So I had to manually
> set threads to 1, if using hwaccel. Only then I had stable output for all codecs.

Does this still happen with recent code? Using frame threading with
hwaccel is a supported use case and should work, any breakage is a bug
that should be fixed in libavcodec.

> Using multithreading together with hwaccel really does not make any sense.
> All the work is done by the GPU, not by the CPU. And the GPU will parallelize
> internally where possible. Adding CPU multithreading will not help at all.
> 
> IMHO the best would be to completely disable threading when hwaccel is in use.

The problem is that in general you cannot know beforehand whether
hwaccel will be usable. What's more, since stream parameters can change
dynamically, you can have a stream where some segments are decodable
with hwaccel, but some are not.

In this case you typically want lavc to use hwaccel wherever possible
and frame-threaded software decoding otherwise, switching back and forth
as needed. This is what is actually meant by "hwaccel with multiple
threads" --- actual hwaccel decoding is already serialized in
libavcodec.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list